prettier: Package and patch dynamic dependency
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
{
|
||||
fetchFromGitHub,
|
||||
fetchPnpmDeps,
|
||||
lib,
|
||||
makeBinaryWrapper,
|
||||
nodejs,
|
||||
pnpmConfigHook,
|
||||
pnpm_9,
|
||||
stdenv,
|
||||
versionCheckHook,
|
||||
yarn-berry,
|
||||
@@ -68,7 +71,64 @@ let
|
||||
pathAbsoluteNaive -> ${pathAbsoluteNaive}
|
||||
pathAbsoluteFallback -> ${pathAbsoluteFallback}
|
||||
'' throw "${plugin.pname}: does not provide parse-able entry point";
|
||||
|
||||
yarnHash = "sha256-WncAReGKs9cZvPTf87bKKOrmte5ORyHOb5pTAgHsb8M=";
|
||||
|
||||
prettier-oxc-wasm-parser = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "binding-wasm32-wasi";
|
||||
version = "0.99.0";
|
||||
|
||||
src = builtins.fetchTarball {
|
||||
url = "https://registry.npmjs.org/@oxc-parser/${finalAttrs.pname}/-/${finalAttrs.pname}-${finalAttrs.version}.tgz";
|
||||
sha256 = "05ndf32qlx5qnrp0r4jrgb8219mihvha68b1jcvk24ys76gpmxpm";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs
|
||||
pnpmConfigHook
|
||||
pnpm_9
|
||||
];
|
||||
|
||||
prePnpmInstall = ''
|
||||
install --mode=644 -T ${./pnpm-lock_prettier-oxc-wasm-parser.yaml} ./pnpm-lock.yaml
|
||||
'';
|
||||
|
||||
pnpmDeps = fetchPnpmDeps {
|
||||
inherit (finalAttrs)
|
||||
pname
|
||||
version
|
||||
src
|
||||
prePnpmInstall
|
||||
;
|
||||
|
||||
pnpm = pnpm_9;
|
||||
fetcherVersion = 2;
|
||||
hash = "sha256-i3zxUTy8vRo+Scn+ZQkZ2/j9emjurCNR4Cz8C8XsHjQ=";
|
||||
};
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir $out
|
||||
cp -r . $out/
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
doInstallCheck = false;
|
||||
|
||||
meta = {
|
||||
description = "Oxc Parser Node API";
|
||||
homepage = "https://oxc.rs/docs/guide/usage/parser";
|
||||
license = "MIT";
|
||||
};
|
||||
});
|
||||
in
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "prettier";
|
||||
@@ -90,8 +150,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
missingHashes = ./missing-hashes.json;
|
||||
|
||||
offlineCache = yarn-berry.fetchYarnBerryDeps {
|
||||
inherit (finalAttrs) src missingHashes patches;
|
||||
inherit (finalAttrs) src missingHashes;
|
||||
hash = yarnHash;
|
||||
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
@@ -104,6 +165,18 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
runHook preInstall
|
||||
|
||||
yarn install --immutable
|
||||
|
||||
mkdir -p .tmp/prettier-oxc-wasm-parser/node_modules/@oxc-parser
|
||||
|
||||
cp -r ${prettier-oxc-wasm-parser.out} .tmp/prettier-oxc-wasm-parser/node_modules/@oxc-parser/binding-wasm32-wasi
|
||||
|
||||
find .tmp/prettier-oxc-wasm-parser -type f -exec chmod u+w {} \;
|
||||
find .tmp/prettier-oxc-wasm-parser -type d -exec chmod u+w {} \;
|
||||
|
||||
sed --in-place --expression '/^\s\+const installDirectory = await install(version);$/ {
|
||||
s#await install(version)#new URL("../../.tmp/prettier-oxc-wasm-parser", import.meta.url)#;
|
||||
}' scripts/build/build-oxc-wasm-parser.js
|
||||
|
||||
yarn build --clean
|
||||
|
||||
mkdir -p $out/lib/node_modules
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@napi-rs/wasm-runtime':
|
||||
specifier: ^1.0.7
|
||||
version: 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
|
||||
|
||||
packages:
|
||||
|
||||
'@emnapi/core@1.10.0':
|
||||
resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
|
||||
|
||||
'@emnapi/runtime@1.10.0':
|
||||
resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==}
|
||||
|
||||
'@emnapi/wasi-threads@1.2.1':
|
||||
resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.4':
|
||||
resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==}
|
||||
peerDependencies:
|
||||
'@emnapi/core': ^1.7.1
|
||||
'@emnapi/runtime': ^1.7.1
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
|
||||
tslib@2.8.1:
|
||||
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||
|
||||
snapshots:
|
||||
|
||||
'@emnapi/core@1.10.0':
|
||||
dependencies:
|
||||
'@emnapi/wasi-threads': 1.2.1
|
||||
tslib: 2.8.1
|
||||
|
||||
'@emnapi/runtime@1.10.0':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@emnapi/wasi-threads@1.2.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
'@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)':
|
||||
dependencies:
|
||||
'@emnapi/core': 1.10.0
|
||||
'@emnapi/runtime': 1.10.0
|
||||
'@tybys/wasm-util': 0.10.1
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
|
||||
tslib@2.8.1: {}
|
||||
Reference in New Issue
Block a user