@qpqjs/user-script 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js +69 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js +20 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +79 -0
- package/lib/commonjs/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
- package/lib/commonjs/actionProcessor/index.d.ts +4 -0
- package/lib/commonjs/actionProcessor/index.js +21 -0
- package/lib/commonjs/actionProcessor/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js +3 -0
- package/lib/commonjs/actionProcessor/logic/BuiltUserScript.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +9 -0
- package/lib/commonjs/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js +22 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js +3 -0
- package/lib/commonjs/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +30 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js +53 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js +9 -0
- package/lib/commonjs/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js +41 -0
- package/lib/commonjs/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js +148 -0
- package/lib/commonjs/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js +20 -0
- package/lib/commonjs/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/index.d.ts +12 -0
- package/lib/commonjs/actionProcessor/logic/index.js +29 -0
- package/lib/commonjs/actionProcessor/logic/index.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js +13 -0
- package/lib/commonjs/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js +23 -0
- package/lib/commonjs/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js +6 -0
- package/lib/commonjs/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js +6 -0
- package/lib/commonjs/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
- package/lib/commonjs/build/UserScriptBuildError.d.ts +12 -0
- package/lib/commonjs/build/UserScriptBuildError.js +26 -0
- package/lib/commonjs/build/UserScriptBuildError.js.map +1 -0
- package/lib/commonjs/build/UserScriptBuildResult.d.ts +4 -0
- package/lib/commonjs/build/UserScriptBuildResult.js +3 -0
- package/lib/commonjs/build/UserScriptBuildResult.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js +6 -0
- package/lib/commonjs/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.d.ts +4 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.js +17 -0
- package/lib/commonjs/build/__fixtures__/basic/src/main.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.js +7 -0
- package/lib/commonjs/build/__fixtures__/builtin/src/main.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js +6 -0
- package/lib/commonjs/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js +7 -0
- package/lib/commonjs/build/__fixtures__/nonFunction/src/main.js.map +1 -0
- package/lib/commonjs/build/assertUserScriptExports.d.ts +6 -0
- package/lib/commonjs/build/assertUserScriptExports.js +20 -0
- package/lib/commonjs/build/assertUserScriptExports.js.map +1 -0
- package/lib/commonjs/build/buildUserScript.d.ts +15 -0
- package/lib/commonjs/build/buildUserScript.js +55 -0
- package/lib/commonjs/build/buildUserScript.js.map +1 -0
- package/lib/commonjs/build/checkUserScriptOutput.d.ts +7 -0
- package/lib/commonjs/build/checkUserScriptOutput.js +17 -0
- package/lib/commonjs/build/checkUserScriptOutput.js.map +1 -0
- package/lib/commonjs/build/createUserScriptExternals.d.ts +11 -0
- package/lib/commonjs/build/createUserScriptExternals.js +34 -0
- package/lib/commonjs/build/createUserScriptExternals.js.map +1 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.d.ts +15 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.js +49 -0
- package/lib/commonjs/build/getUserScriptRspackConfig.js.map +1 -0
- package/lib/commonjs/build/index.d.ts +13 -0
- package/lib/commonjs/build/index.js +30 -0
- package/lib/commonjs/build/index.js.map +1 -0
- package/lib/commonjs/build/loadRspackModule.d.ts +8 -0
- package/lib/commonjs/build/loadRspackModule.js +51 -0
- package/lib/commonjs/build/loadRspackModule.js.map +1 -0
- package/lib/commonjs/build/resolveUserScriptEntry.d.ts +2 -0
- package/lib/commonjs/build/resolveUserScriptEntry.js +20 -0
- package/lib/commonjs/build/resolveUserScriptEntry.js.map +1 -0
- package/lib/commonjs/build/runUserScriptRspack.d.ts +7 -0
- package/lib/commonjs/build/runUserScriptRspack.js +32 -0
- package/lib/commonjs/build/runUserScriptRspack.js.map +1 -0
- package/lib/commonjs/build/userScriptTsRule.d.ts +6 -0
- package/lib/commonjs/build/userScriptTsRule.js +21 -0
- package/lib/commonjs/build/userScriptTsRule.js.map +1 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +9 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +6 -0
- package/lib/commonjs/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
- package/lib/commonjs/config/defineUserScriptBuilder.d.ts +7 -0
- package/lib/commonjs/config/defineUserScriptBuilder.js +16 -0
- package/lib/commonjs/config/defineUserScriptBuilder.js.map +1 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.d.ts +7 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.js +18 -0
- package/lib/commonjs/config/getUserScriptBuilderApiLayer.js.map +1 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.d.ts +6 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.js +33 -0
- package/lib/commonjs/config/getUserScriptBuilderLayerDir.js.map +1 -0
- package/lib/commonjs/config/index.d.ts +5 -0
- package/lib/commonjs/config/index.js +22 -0
- package/lib/commonjs/config/index.js.map +1 -0
- package/lib/commonjs/index.d.ts +3 -0
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.d.ts +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js +56 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.d.ts +3 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js +8 -0
- package/lib/esm/actionProcessor/getUserScriptBuildActionProcessors.js.map +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.d.ts +1 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js +66 -0
- package/lib/esm/actionProcessor/getUserScriptBuildFromZipActionProcessor.js.map +1 -0
- package/lib/esm/actionProcessor/index.d.ts +4 -0
- package/lib/esm/actionProcessor/index.js +5 -0
- package/lib/esm/actionProcessor/index.js.map +1 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.d.ts +4 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.js +2 -0
- package/lib/esm/actionProcessor/logic/BuiltUserScript.js.map +1 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js +6 -0
- package/lib/esm/actionProcessor/logic/USER_SCRIPT_SOURCE_LIMITS.js.map +1 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.d.ts +10 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js +19 -0
- package/lib/esm/actionProcessor/logic/UserScriptArchiveError.js.map +1 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js +2 -0
- package/lib/esm/actionProcessor/logic/UserScriptSourceFile.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.d.ts +8 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js +27 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCheckPublishedOutput.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.d.ts +9 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js +50 -0
- package/lib/esm/actionProcessor/logic/askUserScriptCollectSource.js.map +1 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.d.ts +3 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js +6 -0
- package/lib/esm/actionProcessor/logic/askUserScriptPublishOutput.js.map +1 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.d.ts +9 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js +25 -0
- package/lib/esm/actionProcessor/logic/buildUserScriptInTempDir.js.map +1 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.d.ts +8 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.js +132 -0
- package/lib/esm/actionProcessor/logic/extractUserScriptZip.js.map +1 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.d.ts +7 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js +16 -0
- package/lib/esm/actionProcessor/logic/getUserScriptBuildErrorType.js.map +1 -0
- package/lib/esm/actionProcessor/logic/index.d.ts +12 -0
- package/lib/esm/actionProcessor/logic/index.js +13 -0
- package/lib/esm/actionProcessor/logic/index.js.map +1 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.d.ts +5 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.js +9 -0
- package/lib/esm/actionProcessor/logic/isSafeProjectPath.js.map +1 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.d.ts +3 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js +16 -0
- package/lib/esm/actionProcessor/logic/materialiseUserScriptSource.js.map +1 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.d.ts +2 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js +3 -0
- package/lib/esm/build/USER_SCRIPT_ENTRY_CANDIDATES.js.map +1 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.d.ts +2 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js +3 -0
- package/lib/esm/build/USER_SCRIPT_OUTPUT_FILENAME.js.map +1 -0
- package/lib/esm/build/UserScriptBuildError.d.ts +12 -0
- package/lib/esm/build/UserScriptBuildError.js +23 -0
- package/lib/esm/build/UserScriptBuildError.js.map +1 -0
- package/lib/esm/build/UserScriptBuildResult.d.ts +4 -0
- package/lib/esm/build/UserScriptBuildResult.js +2 -0
- package/lib/esm/build/UserScriptBuildResult.js.map +1 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.d.ts +1 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js +2 -0
- package/lib/esm/build/__fixtures__/basic/src/helpers/formatSum.js.map +1 -0
- package/lib/esm/build/__fixtures__/basic/src/main.d.ts +4 -0
- package/lib/esm/build/__fixtures__/basic/src/main.js +11 -0
- package/lib/esm/build/__fixtures__/basic/src/main.js.map +1 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.d.ts +1 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.js +3 -0
- package/lib/esm/build/__fixtures__/builtin/src/main.js.map +1 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.d.ts +1 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.js +2 -0
- package/lib/esm/build/__fixtures__/noEntry/src/notMain.js.map +1 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.d.ts +2 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.js +3 -0
- package/lib/esm/build/__fixtures__/nonFunction/src/main.js.map +1 -0
- package/lib/esm/build/assertUserScriptExports.d.ts +6 -0
- package/lib/esm/build/assertUserScriptExports.js +16 -0
- package/lib/esm/build/assertUserScriptExports.js.map +1 -0
- package/lib/esm/build/buildUserScript.d.ts +15 -0
- package/lib/esm/build/buildUserScript.js +39 -0
- package/lib/esm/build/buildUserScript.js.map +1 -0
- package/lib/esm/build/checkUserScriptOutput.d.ts +7 -0
- package/lib/esm/build/checkUserScriptOutput.js +10 -0
- package/lib/esm/build/checkUserScriptOutput.js.map +1 -0
- package/lib/esm/build/createUserScriptExternals.d.ts +11 -0
- package/lib/esm/build/createUserScriptExternals.js +30 -0
- package/lib/esm/build/createUserScriptExternals.js.map +1 -0
- package/lib/esm/build/getUserScriptRspackConfig.d.ts +15 -0
- package/lib/esm/build/getUserScriptRspackConfig.js +42 -0
- package/lib/esm/build/getUserScriptRspackConfig.js.map +1 -0
- package/lib/esm/build/index.d.ts +13 -0
- package/lib/esm/build/index.js +14 -0
- package/lib/esm/build/index.js.map +1 -0
- package/lib/esm/build/loadRspackModule.d.ts +8 -0
- package/lib/esm/build/loadRspackModule.js +38 -0
- package/lib/esm/build/loadRspackModule.js.map +1 -0
- package/lib/esm/build/resolveUserScriptEntry.d.ts +2 -0
- package/lib/esm/build/resolveUserScriptEntry.js +13 -0
- package/lib/esm/build/resolveUserScriptEntry.js.map +1 -0
- package/lib/esm/build/runUserScriptRspack.d.ts +7 -0
- package/lib/esm/build/runUserScriptRspack.js +19 -0
- package/lib/esm/build/runUserScriptRspack.js.map +1 -0
- package/lib/esm/build/userScriptTsRule.d.ts +6 -0
- package/lib/esm/build/userScriptTsRule.js +17 -0
- package/lib/esm/build/userScriptTsRule.js.map +1 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.d.ts +5 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js +6 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_MODULES.js.map +1 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.d.ts +2 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js +3 -0
- package/lib/esm/config/USER_SCRIPT_BUILDER_LAYER_NAME.js.map +1 -0
- package/lib/esm/config/defineUserScriptBuilder.d.ts +7 -0
- package/lib/esm/config/defineUserScriptBuilder.js +12 -0
- package/lib/esm/config/defineUserScriptBuilder.js.map +1 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.d.ts +7 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.js +14 -0
- package/lib/esm/config/getUserScriptBuilderApiLayer.js.map +1 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.d.ts +6 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.js +26 -0
- package/lib/esm/config/getUserScriptBuilderLayerDir.js.map +1 -0
- package/lib/esm/config/index.d.ts +5 -0
- package/lib/esm/config/index.js +6 -0
- package/lib/esm/config/index.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -0
- package/package.json +49 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FEDERATED_SHARED_PACKAGE_NAMES } from '@qpqjs/core';
|
|
2
|
+
import { builtinModules } from 'module';
|
|
3
|
+
const sharedPackageNames = FEDERATED_SHARED_PACKAGE_NAMES;
|
|
4
|
+
const isNodeBuiltin = (request) => request.startsWith('node:') || builtinModules.includes(request);
|
|
5
|
+
// A subpath of a shared package would bundle a second copy of it beside the host's.
|
|
6
|
+
const isSharedPackageSubpath = (request) => sharedPackageNames.some((name) => request.startsWith(`${name}/`));
|
|
7
|
+
/**
|
|
8
|
+
* The externals rule for a user-script build: the shared framework packages and the
|
|
9
|
+
* service's own script modules (`hostModuleNames`, from defineUserScriptModule) stay
|
|
10
|
+
* external (the host provides them at run time), Node builtins are refused here with
|
|
11
|
+
* the importing file named, because the loader would refuse them at run time anyway,
|
|
12
|
+
* and everything else is bundled.
|
|
13
|
+
*/
|
|
14
|
+
export const createUserScriptExternals = (hostModuleNames = []) => ({ request, contextInfo }, callback) => {
|
|
15
|
+
if (!request) {
|
|
16
|
+
return callback();
|
|
17
|
+
}
|
|
18
|
+
if (sharedPackageNames.includes(request) || hostModuleNames.includes(request)) {
|
|
19
|
+
return callback(undefined, `commonjs ${request}`);
|
|
20
|
+
}
|
|
21
|
+
const importer = contextInfo?.issuer || 'the entry';
|
|
22
|
+
if (isNodeBuiltin(request)) {
|
|
23
|
+
return callback(new Error(`[${importer}] imports the Node builtin [${request}], which a user script cannot use`));
|
|
24
|
+
}
|
|
25
|
+
if (isSharedPackageSubpath(request)) {
|
|
26
|
+
return callback(new Error(`[${importer}] imports [${request}]; import the package root instead so the host's copy is used`));
|
|
27
|
+
}
|
|
28
|
+
return callback();
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=createUserScriptExternals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUserScriptExternals.js","sourceRoot":"","sources":["../../../src/build/createUserScriptExternals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAKxC,MAAM,kBAAkB,GAAsB,8BAA8B,CAAC;AAE7E,MAAM,aAAa,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAEpH,oFAAoF;AACpF,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AAE/H;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,CAAC,kBAAqC,EAAE,EAAE,EAAE,CAC5C,CAAC,EAAE,OAAO,EAAE,WAAW,EAA4B,EAAE,QAA2B,EAAQ,EAAE;IACxF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC;IAED,IAAI,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9E,OAAO,QAAQ,CAAC,SAAS,EAAE,YAAY,OAAO,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,EAAE,MAAM,IAAI,WAAW,CAAC;IAEpD,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,QAAQ,+BAA+B,OAAO,mCAAmC,CAAC,CAAC,CAAC;IACpH,CAAC;IAED,IAAI,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,IAAI,QAAQ,cAAc,OAAO,+DAA+D,CAAC,CAAC,CAAC;IAC/H,CAAC;IAED,OAAO,QAAQ,EAAE,CAAC;AACpB,CAAC,CAAC","sourcesContent":["import { FEDERATED_SHARED_PACKAGE_NAMES } from '@qpqjs/core';\n\nimport { builtinModules } from 'module';\nimport type { ExternalItemFunctionData } from '@rspack/core';\n\ntype ExternalsCallback = (error?: Error, result?: string) => void;\n\nconst sharedPackageNames: readonly string[] = FEDERATED_SHARED_PACKAGE_NAMES;\n\nconst isNodeBuiltin = (request: string): boolean => request.startsWith('node:') || builtinModules.includes(request);\n\n// A subpath of a shared package would bundle a second copy of it beside the host's.\nconst isSharedPackageSubpath = (request: string): boolean => sharedPackageNames.some((name) => request.startsWith(`${name}/`));\n\n/**\n * The externals rule for a user-script build: the shared framework packages and the\n * service's own script modules (`hostModuleNames`, from defineUserScriptModule) stay\n * external (the host provides them at run time), Node builtins are refused here with\n * the importing file named, because the loader would refuse them at run time anyway,\n * and everything else is bundled.\n */\nexport const createUserScriptExternals =\n (hostModuleNames: readonly string[] = []) =>\n ({ request, contextInfo }: ExternalItemFunctionData, callback: ExternalsCallback): void => {\n if (!request) {\n return callback();\n }\n\n if (sharedPackageNames.includes(request) || hostModuleNames.includes(request)) {\n return callback(undefined, `commonjs ${request}`);\n }\n\n const importer = contextInfo?.issuer || 'the entry';\n\n if (isNodeBuiltin(request)) {\n return callback(new Error(`[${importer}] imports the Node builtin [${request}], which a user script cannot use`));\n }\n\n if (isSharedPackageSubpath(request)) {\n return callback(new Error(`[${importer}] imports [${request}]; import the package root instead so the host's copy is used`));\n }\n\n return callback();\n };\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Configuration } from '@rspack/core';
|
|
2
|
+
export type UserScriptRspackConfigOptions = {
|
|
3
|
+
projectDir: string;
|
|
4
|
+
entryPath: string;
|
|
5
|
+
outDir: string;
|
|
6
|
+
sourceMap: boolean;
|
|
7
|
+
hostModuleNames?: readonly string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The rspack config that bundles a script project into one CommonJS `main.js`: the
|
|
11
|
+
* author's files and npm packages folded in, the shared framework packages external,
|
|
12
|
+
* no chunks, and a source map only when asked for, embedded in `main.js`. TypeScript goes
|
|
13
|
+
* through swc, so nothing is type checked here.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getUserScriptRspackConfig: ({ projectDir, entryPath, outDir, sourceMap, hostModuleNames, }: UserScriptRspackConfigOptions) => Configuration;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { createUserScriptExternals } from './createUserScriptExternals';
|
|
3
|
+
import { USER_SCRIPT_OUTPUT_FILENAME } from './USER_SCRIPT_OUTPUT_FILENAME';
|
|
4
|
+
import { userScriptTsRule } from './userScriptTsRule';
|
|
5
|
+
/**
|
|
6
|
+
* The rspack config that bundles a script project into one CommonJS `main.js`: the
|
|
7
|
+
* author's files and npm packages folded in, the shared framework packages external,
|
|
8
|
+
* no chunks, and a source map only when asked for, embedded in `main.js`. TypeScript goes
|
|
9
|
+
* through swc, so nothing is type checked here.
|
|
10
|
+
*/
|
|
11
|
+
export const getUserScriptRspackConfig = ({ projectDir, entryPath, outDir, sourceMap, hostModuleNames = [], }) => ({
|
|
12
|
+
context: projectDir,
|
|
13
|
+
mode: 'production',
|
|
14
|
+
target: 'node',
|
|
15
|
+
entry: { main: entryPath },
|
|
16
|
+
output: {
|
|
17
|
+
path: outDir,
|
|
18
|
+
filename: USER_SCRIPT_OUTPUT_FILENAME,
|
|
19
|
+
library: { type: 'commonjs2' },
|
|
20
|
+
clean: true,
|
|
21
|
+
},
|
|
22
|
+
externals: [createUserScriptExternals(hostModuleNames)],
|
|
23
|
+
externalsType: 'commonjs',
|
|
24
|
+
// The build is ONE file, so a map can only ride inside it. The output is read from a
|
|
25
|
+
// drive, never served, so the size an inline map adds does not matter.
|
|
26
|
+
devtool: sourceMap ? 'inline-source-map' : false,
|
|
27
|
+
optimization: {
|
|
28
|
+
minimize: false,
|
|
29
|
+
splitChunks: false,
|
|
30
|
+
runtimeChunk: false,
|
|
31
|
+
},
|
|
32
|
+
resolve: {
|
|
33
|
+
extensions: ['.ts', '.tsx', '.js', '.json'],
|
|
34
|
+
modules: [path.join(projectDir, 'node_modules'), 'node_modules'],
|
|
35
|
+
},
|
|
36
|
+
module: {
|
|
37
|
+
// A dynamic import must land in the one file, not a sibling chunk.
|
|
38
|
+
parser: { javascript: { dynamicImportMode: 'eager' } },
|
|
39
|
+
rules: [userScriptTsRule()],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=getUserScriptRspackConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptRspackConfig.js","sourceRoot":"","sources":["../../../src/build/getUserScriptRspackConfig.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAatD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EACxC,UAAU,EACV,SAAS,EACT,MAAM,EACN,SAAS,EACT,eAAe,GAAG,EAAE,GACU,EAAiB,EAAE,CAAC,CAAC;IACnD,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,MAAM;IAEd,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAE1B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,2BAA2B;QACrC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;QAC9B,KAAK,EAAE,IAAI;KACZ;IAED,SAAS,EAAE,CAAC,yBAAyB,CAAC,eAAe,CAAC,CAAC;IACvD,aAAa,EAAE,UAAU;IAEzB,qFAAqF;IACrF,uEAAuE;IACvE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK;IAChD,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB;IAED,OAAO,EAAE;QACP,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;QAC3C,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE,cAAc,CAAC;KACjE;IAED,MAAM,EAAE;QACN,mEAAmE;QACnE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,EAAE;QACtD,KAAK,EAAE,CAAC,gBAAgB,EAAE,CAAC;KAC5B;CACF,CAAC,CAAC","sourcesContent":["import path from 'path';\nimport type { Configuration } from '@rspack/core';\n\nimport { createUserScriptExternals } from './createUserScriptExternals';\nimport { USER_SCRIPT_OUTPUT_FILENAME } from './USER_SCRIPT_OUTPUT_FILENAME';\nimport { userScriptTsRule } from './userScriptTsRule';\n\nexport type UserScriptRspackConfigOptions = {\n projectDir: string;\n // Absolute path of the entry file (see resolveUserScriptEntry).\n entryPath: string;\n outDir: string;\n // Embed a source map in main.js; never a separate .map file.\n sourceMap: boolean;\n // The service's own script modules (defineUserScriptModule), kept external like the shared packages.\n hostModuleNames?: readonly string[];\n};\n\n/**\n * The rspack config that bundles a script project into one CommonJS `main.js`: the\n * author's files and npm packages folded in, the shared framework packages external,\n * no chunks, and a source map only when asked for, embedded in `main.js`. TypeScript goes\n * through swc, so nothing is type checked here.\n */\nexport const getUserScriptRspackConfig = ({\n projectDir,\n entryPath,\n outDir,\n sourceMap,\n hostModuleNames = [],\n}: UserScriptRspackConfigOptions): Configuration => ({\n context: projectDir,\n mode: 'production',\n target: 'node',\n\n entry: { main: entryPath },\n\n output: {\n path: outDir,\n filename: USER_SCRIPT_OUTPUT_FILENAME,\n library: { type: 'commonjs2' },\n clean: true,\n },\n\n externals: [createUserScriptExternals(hostModuleNames)],\n externalsType: 'commonjs',\n\n // The build is ONE file, so a map can only ride inside it. The output is read from a\n // drive, never served, so the size an inline map adds does not matter.\n devtool: sourceMap ? 'inline-source-map' : false,\n optimization: {\n minimize: false,\n splitChunks: false,\n runtimeChunk: false,\n },\n\n resolve: {\n extensions: ['.ts', '.tsx', '.js', '.json'],\n modules: [path.join(projectDir, 'node_modules'), 'node_modules'],\n },\n\n module: {\n // A dynamic import must land in the one file, not a sibling chunk.\n parser: { javascript: { dynamicImportMode: 'eager' } },\n rules: [userScriptTsRule()],\n },\n});\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './assertUserScriptExports';
|
|
2
|
+
export * from './buildUserScript';
|
|
3
|
+
export * from './checkUserScriptOutput';
|
|
4
|
+
export * from './createUserScriptExternals';
|
|
5
|
+
export * from './getUserScriptRspackConfig';
|
|
6
|
+
export * from './loadRspackModule';
|
|
7
|
+
export * from './resolveUserScriptEntry';
|
|
8
|
+
export * from './runUserScriptRspack';
|
|
9
|
+
export * from './USER_SCRIPT_ENTRY_CANDIDATES';
|
|
10
|
+
export * from './USER_SCRIPT_OUTPUT_FILENAME';
|
|
11
|
+
export * from './UserScriptBuildError';
|
|
12
|
+
export * from './UserScriptBuildResult';
|
|
13
|
+
export * from './userScriptTsRule';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './assertUserScriptExports';
|
|
2
|
+
export * from './buildUserScript';
|
|
3
|
+
export * from './checkUserScriptOutput';
|
|
4
|
+
export * from './createUserScriptExternals';
|
|
5
|
+
export * from './getUserScriptRspackConfig';
|
|
6
|
+
export * from './loadRspackModule';
|
|
7
|
+
export * from './resolveUserScriptEntry';
|
|
8
|
+
export * from './runUserScriptRspack';
|
|
9
|
+
export * from './USER_SCRIPT_ENTRY_CANDIDATES';
|
|
10
|
+
export * from './USER_SCRIPT_OUTPUT_FILENAME';
|
|
11
|
+
export * from './UserScriptBuildError';
|
|
12
|
+
export * from './UserScriptBuildResult';
|
|
13
|
+
export * from './userScriptTsRule';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/build/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './assertUserScriptExports';\nexport * from './buildUserScript';\nexport * from './checkUserScriptOutput';\nexport * from './createUserScriptExternals';\nexport * from './getUserScriptRspackConfig';\nexport * from './loadRspackModule';\nexport * from './resolveUserScriptEntry';\nexport * from './runUserScriptRspack';\nexport * from './USER_SCRIPT_ENTRY_CANDIDATES';\nexport * from './USER_SCRIPT_OUTPUT_FILENAME';\nexport * from './UserScriptBuildError';\nexport * from './UserScriptBuildResult';\nexport * from './userScriptTsRule';\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type RspackModule = typeof import('@rspack/core');
|
|
2
|
+
/**
|
|
3
|
+
* Loads @rspack/core, which ships as ES modules only, from CommonJS code that may be
|
|
4
|
+
* bundled and running on a lambda with rspack on a layer: resolve the entry with Node's
|
|
5
|
+
* require (NODE_PATH aware), require it where Node allows that, otherwise import it by
|
|
6
|
+
* file URL. Loaded once per process.
|
|
7
|
+
*/
|
|
8
|
+
export declare const loadRspackModule: () => Promise<RspackModule>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
3
|
+
// Node refuses require() of an ES module on versions before 22.12, or when the module
|
|
4
|
+
// graph awaits at top level; both mean "use import() instead".
|
|
5
|
+
const REQUIRE_ESM_ERROR_CODES = ['ERR_REQUIRE_ESM', 'ERR_REQUIRE_ASYNC_MODULE'];
|
|
6
|
+
// Inside a bundle `require` is the bundler's own and cannot see a layer-provided package;
|
|
7
|
+
// Node's real require can, and honours NODE_PATH, which is how a lambda layer is found.
|
|
8
|
+
const getNodeRequire = () => (typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : createRequire(__filename));
|
|
9
|
+
// Built at run time so neither tsc (which rewrites a literal import() to require() in
|
|
10
|
+
// CommonJS output) nor the bundler can turn it into a require.
|
|
11
|
+
const importByUrl = new Function('url', 'return import(url)');
|
|
12
|
+
const isRequireEsmError = (error) => REQUIRE_ESM_ERROR_CODES.includes(error?.code ?? '');
|
|
13
|
+
const requireOrImport = async () => {
|
|
14
|
+
const nodeRequire = getNodeRequire();
|
|
15
|
+
const entry = nodeRequire.resolve('@rspack/core');
|
|
16
|
+
try {
|
|
17
|
+
return nodeRequire(entry);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (!isRequireEsmError(error))
|
|
21
|
+
throw error;
|
|
22
|
+
return importByUrl(pathToFileURL(entry).href);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
let loading;
|
|
26
|
+
/**
|
|
27
|
+
* Loads @rspack/core, which ships as ES modules only, from CommonJS code that may be
|
|
28
|
+
* bundled and running on a lambda with rspack on a layer: resolve the entry with Node's
|
|
29
|
+
* require (NODE_PATH aware), require it where Node allows that, otherwise import it by
|
|
30
|
+
* file URL. Loaded once per process.
|
|
31
|
+
*/
|
|
32
|
+
export const loadRspackModule = () => {
|
|
33
|
+
if (!loading) {
|
|
34
|
+
loading = requireOrImport();
|
|
35
|
+
}
|
|
36
|
+
return loading;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=loadRspackModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadRspackModule.js","sourceRoot":"","sources":["../../../src/build/loadRspackModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAOpC,sFAAsF;AACtF,+DAA+D;AAC/D,MAAM,uBAAuB,GAAG,CAAC,iBAAiB,EAAE,0BAA0B,CAAC,CAAC;AAEhF,0FAA0F;AAC1F,wFAAwF;AACxF,MAAM,cAAc,GAAG,GAAgB,EAAE,CAAC,CAAC,OAAO,uBAAuB,KAAK,UAAU,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;AAEhJ,sFAAsF;AACtF,+DAA+D;AAC/D,MAAM,WAAW,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAA2C,CAAC;AAExG,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAAW,EAAE,CAAC,uBAAuB,CAAC,QAAQ,CAAE,KAA2B,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;AAElI,MAAM,eAAe,GAAG,KAAK,IAA2B,EAAE;IACxD,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAElD,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,KAAK,CAAiB,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC;QAC3C,OAAO,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAEF,IAAI,OAA0C,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAA0B,EAAE;IAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,eAAe,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import { createRequire } from 'module';\nimport { pathToFileURL } from 'url';\n\nexport type RspackModule = typeof import('@rspack/core');\n\n// The bundler's escape hatch for the host's real `require`; undefined outside a bundle.\ndeclare const __non_webpack_require__: NodeRequire | undefined;\n\n// Node refuses require() of an ES module on versions before 22.12, or when the module\n// graph awaits at top level; both mean \"use import() instead\".\nconst REQUIRE_ESM_ERROR_CODES = ['ERR_REQUIRE_ESM', 'ERR_REQUIRE_ASYNC_MODULE'];\n\n// Inside a bundle `require` is the bundler's own and cannot see a layer-provided package;\n// Node's real require can, and honours NODE_PATH, which is how a lambda layer is found.\nconst getNodeRequire = (): NodeRequire => (typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : createRequire(__filename));\n\n// Built at run time so neither tsc (which rewrites a literal import() to require() in\n// CommonJS output) nor the bundler can turn it into a require.\nconst importByUrl = new Function('url', 'return import(url)') as (url: string) => Promise<RspackModule>;\n\nconst isRequireEsmError = (error: unknown): boolean => REQUIRE_ESM_ERROR_CODES.includes((error as { code?: string })?.code ?? '');\n\nconst requireOrImport = async (): Promise<RspackModule> => {\n const nodeRequire = getNodeRequire();\n const entry = nodeRequire.resolve('@rspack/core');\n\n try {\n return nodeRequire(entry) as RspackModule;\n } catch (error) {\n if (!isRequireEsmError(error)) throw error;\n return importByUrl(pathToFileURL(entry).href);\n }\n};\n\nlet loading: Promise<RspackModule> | undefined;\n\n/**\n * Loads @rspack/core, which ships as ES modules only, from CommonJS code that may be\n * bundled and running on a lambda with rspack on a layer: resolve the entry with Node's\n * require (NODE_PATH aware), require it where Node allows that, otherwise import it by\n * file URL. Loaded once per process.\n */\nexport const loadRspackModule = (): Promise<RspackModule> => {\n if (!loading) {\n loading = requireOrImport();\n }\n return loading;\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { USER_SCRIPT_ENTRY_CANDIDATES } from './USER_SCRIPT_ENTRY_CANDIDATES';
|
|
4
|
+
import { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';
|
|
5
|
+
/** The absolute entry path of a script project, or a NoEntry error naming what was looked for. */
|
|
6
|
+
export const resolveUserScriptEntry = (projectDir) => {
|
|
7
|
+
const found = USER_SCRIPT_ENTRY_CANDIDATES.map((candidate) => path.join(projectDir, candidate)).find((candidate) => fs.existsSync(candidate));
|
|
8
|
+
if (!found) {
|
|
9
|
+
throw new UserScriptBuildError(UserScriptBuildErrorCode.NoEntry, `No script entry in [${projectDir}]: expected one of ${USER_SCRIPT_ENTRY_CANDIDATES.join(', ')}`);
|
|
10
|
+
}
|
|
11
|
+
return found;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=resolveUserScriptEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveUserScriptEntry.js","sourceRoot":"","sources":["../../../src/build/resolveUserScriptEntry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAExF,kGAAkG;AAClG,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,UAAkB,EAAU,EAAE;IACnE,MAAM,KAAK,GAAG,4BAA4B,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IAE9I,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,oBAAoB,CAC5B,wBAAwB,CAAC,OAAO,EAChC,uBAAuB,UAAU,sBAAsB,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjG,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { USER_SCRIPT_ENTRY_CANDIDATES } from './USER_SCRIPT_ENTRY_CANDIDATES';\nimport { UserScriptBuildError, UserScriptBuildErrorCode } from './UserScriptBuildError';\n\n/** The absolute entry path of a script project, or a NoEntry error naming what was looked for. */\nexport const resolveUserScriptEntry = (projectDir: string): string => {\n const found = USER_SCRIPT_ENTRY_CANDIDATES.map((candidate) => path.join(projectDir, candidate)).find((candidate) => fs.existsSync(candidate));\n\n if (!found) {\n throw new UserScriptBuildError(\n UserScriptBuildErrorCode.NoEntry,\n `No script entry in [${projectDir}]: expected one of ${USER_SCRIPT_ENTRY_CANDIDATES.join(', ')}`,\n );\n }\n\n return found;\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Configuration } from '@rspack/core';
|
|
2
|
+
/**
|
|
3
|
+
* One-shot rspack build as a promise; rejects on a compiler error or on stats errors.
|
|
4
|
+
* Kept here rather than imported from @qpqjs/deploy-rspack because this package is
|
|
5
|
+
* bundled into lambdas and must not pull that package's deploy-time dependencies in.
|
|
6
|
+
*/
|
|
7
|
+
export declare const runUserScriptRspack: (config: Configuration) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { loadRspackModule } from './loadRspackModule';
|
|
2
|
+
/**
|
|
3
|
+
* One-shot rspack build as a promise; rejects on a compiler error or on stats errors.
|
|
4
|
+
* Kept here rather than imported from @qpqjs/deploy-rspack because this package is
|
|
5
|
+
* bundled into lambdas and must not pull that package's deploy-time dependencies in.
|
|
6
|
+
*/
|
|
7
|
+
export const runUserScriptRspack = async (config) => {
|
|
8
|
+
const { rspack } = await loadRspackModule();
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
rspack(config, (error, stats) => {
|
|
11
|
+
if (error)
|
|
12
|
+
return reject(error);
|
|
13
|
+
if (stats?.hasErrors())
|
|
14
|
+
return reject(new Error(stats.toString({ errors: true, colors: false })));
|
|
15
|
+
return resolve();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=runUserScriptRspack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runUserScriptRspack.js","sourceRoot":"","sources":["../../../src/build/runUserScriptRspack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,MAAqB,EAAiB,EAAE;IAChF,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;IAE5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC9B,IAAI,KAAK;gBAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;YAChC,IAAI,KAAK,EAAE,SAAS,EAAE;gBAAE,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;YAClG,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Configuration } from '@rspack/core';\n\nimport { loadRspackModule } from './loadRspackModule';\n\n/**\n * One-shot rspack build as a promise; rejects on a compiler error or on stats errors.\n * Kept here rather than imported from @qpqjs/deploy-rspack because this package is\n * bundled into lambdas and must not pull that package's deploy-time dependencies in.\n */\nexport const runUserScriptRspack = async (config: Configuration): Promise<void> => {\n const { rspack } = await loadRspackModule();\n\n return new Promise((resolve, reject) => {\n rspack(config, (error, stats) => {\n if (error) return reject(error);\n if (stats?.hasErrors()) return reject(new Error(stats.toString({ errors: true, colors: false })));\n return resolve();\n });\n });\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuleSetRule } from '@rspack/core';
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript through rspack's builtin swc loader, no type check. The same options as a
|
|
4
|
+
* service build's rule, kept here so this package does not depend on deploy-rspack.
|
|
5
|
+
*/
|
|
6
|
+
export declare const userScriptTsRule: () => RuleSetRule;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript through rspack's builtin swc loader, no type check. The same options as a
|
|
3
|
+
* service build's rule, kept here so this package does not depend on deploy-rspack.
|
|
4
|
+
*/
|
|
5
|
+
export const userScriptTsRule = () => ({
|
|
6
|
+
test: /\.ts$/,
|
|
7
|
+
exclude: /node_modules/,
|
|
8
|
+
loader: 'builtin:swc-loader',
|
|
9
|
+
options: {
|
|
10
|
+
jsc: {
|
|
11
|
+
parser: { syntax: 'typescript', tsx: false, decorators: true },
|
|
12
|
+
transform: { legacyDecorator: true, decoratorMetadata: true },
|
|
13
|
+
target: 'es2021',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=userScriptTsRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userScriptTsRule.js","sourceRoot":"","sources":["../../../src/build/userScriptTsRule.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAgB,EAAE,CAAC,CAAC;IAClD,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE,oBAAoB;IAC5B,OAAO,EAAE;QACP,GAAG,EAAE;YACH,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE;YAC9D,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE;YAC7D,MAAM,EAAE,QAAQ;SACjB;KACF;CACF,CAAC,CAAC","sourcesContent":["import type { RuleSetRule } from '@rspack/core';\n\n/**\n * TypeScript through rspack's builtin swc loader, no type check. The same options as a\n * service build's rule, kept here so this package does not depend on deploy-rspack.\n */\nexport const userScriptTsRule = (): RuleSetRule => ({\n test: /\\.ts$/,\n exclude: /node_modules/,\n loader: 'builtin:swc-loader',\n options: {\n jsc: {\n parser: { syntax: 'typescript', tsx: false, decorators: true },\n transform: { legacyDecorator: true, decoratorMetadata: true },\n target: 'es2021',\n },\n },\n});\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The packages the builder layer provides at run time. They stay external in the lambda
|
|
3
|
+
* bundle (rspack's binding is native and cannot be bundled) and resolve from the layer.
|
|
4
|
+
*/
|
|
5
|
+
export declare const USER_SCRIPT_BUILDER_LAYER_MODULES: readonly ["@rspack/core", "@rspack/binding"];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The packages the builder layer provides at run time. They stay external in the lambda
|
|
3
|
+
* bundle (rspack's binding is native and cannot be bundled) and resolve from the layer.
|
|
4
|
+
*/
|
|
5
|
+
export const USER_SCRIPT_BUILDER_LAYER_MODULES = ['@rspack/core', '@rspack/binding'];
|
|
6
|
+
//# sourceMappingURL=USER_SCRIPT_BUILDER_LAYER_MODULES.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"USER_SCRIPT_BUILDER_LAYER_MODULES.js","sourceRoot":"","sources":["../../../src/config/USER_SCRIPT_BUILDER_LAYER_MODULES.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAU,CAAC","sourcesContent":["/**\n * The packages the builder layer provides at run time. They stay external in the lambda\n * bundle (rspack's binding is native and cannot be bundled) and resolve from the layer.\n */\nexport const USER_SCRIPT_BUILDER_LAYER_MODULES = ['@rspack/core', '@rspack/binding'] as const;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"USER_SCRIPT_BUILDER_LAYER_NAME.js","sourceRoot":"","sources":["../../../src/config/USER_SCRIPT_BUILDER_LAYER_NAME.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,8BAA8B,GAAG,qBAAqB,CAAC","sourcesContent":["/** The lambda layer that carries rspack for services that build user scripts. */\nexport const USER_SCRIPT_BUILDER_LAYER_NAME = 'user-script-builder';\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ActionProcessorsQPQConfigSetting } from '@qpqjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the askUserScriptBuild processor on a service. Only services that call this
|
|
4
|
+
* can build user scripts, and only they load rspack; on lambda they also need the layer
|
|
5
|
+
* from getUserScriptBuilderApiLayer.
|
|
6
|
+
*/
|
|
7
|
+
export declare const defineUserScriptBuilder: () => ActionProcessorsQPQConfigSetting;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineActionProcessors } from '@qpqjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the askUserScriptBuild processor on a service. Only services that call this
|
|
4
|
+
* can build user scripts, and only they load rspack; on lambda they also need the layer
|
|
5
|
+
* from getUserScriptBuilderApiLayer.
|
|
6
|
+
*/
|
|
7
|
+
export const defineUserScriptBuilder = () => defineActionProcessors({
|
|
8
|
+
basePath: __dirname,
|
|
9
|
+
relativePath: '../actionProcessor/getUserScriptBuildActionProcessors',
|
|
10
|
+
functionName: 'getUserScriptBuildActionProcessors',
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=defineUserScriptBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineUserScriptBuilder.js","sourceRoot":"","sources":["../../../src/config/defineUserScriptBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAqC,EAAE,CAC5E,sBAAsB,CAAC;IACrB,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,uDAAuD;IACrE,YAAY,EAAE,oCAAoC;CACnD,CAAC,CAAC","sourcesContent":["import { ActionProcessorsQPQConfigSetting, defineActionProcessors } from '@qpqjs/core';\n\n/**\n * Registers the askUserScriptBuild processor on a service. Only services that call this\n * can build user scripts, and only they load rspack; on lambda they also need the layer\n * from getUserScriptBuilderApiLayer.\n */\nexport const defineUserScriptBuilder = (): ActionProcessorsQPQConfigSetting =>\n defineActionProcessors({\n basePath: __dirname,\n relativePath: '../actionProcessor/getUserScriptBuildActionProcessors',\n functionName: 'getUserScriptBuildActionProcessors',\n });\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApiLayer } from '@qpqjs/config-aws';
|
|
2
|
+
/**
|
|
3
|
+
* The api layer entry that gives a service's lambdas rspack, for the service that
|
|
4
|
+
* registered defineUserScriptBuilder. Points at the directory `qpq script:builder-layer`
|
|
5
|
+
* produces, so the app's predeploy hook must run that command before a deploy.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getUserScriptBuilderApiLayer: () => ApiLayer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getUserScriptBuilderLayerDir } from './getUserScriptBuilderLayerDir';
|
|
2
|
+
import { USER_SCRIPT_BUILDER_LAYER_MODULES } from './USER_SCRIPT_BUILDER_LAYER_MODULES';
|
|
3
|
+
import { USER_SCRIPT_BUILDER_LAYER_NAME } from './USER_SCRIPT_BUILDER_LAYER_NAME';
|
|
4
|
+
/**
|
|
5
|
+
* The api layer entry that gives a service's lambdas rspack, for the service that
|
|
6
|
+
* registered defineUserScriptBuilder. Points at the directory `qpq script:builder-layer`
|
|
7
|
+
* produces, so the app's predeploy hook must run that command before a deploy.
|
|
8
|
+
*/
|
|
9
|
+
export const getUserScriptBuilderApiLayer = () => ({
|
|
10
|
+
name: USER_SCRIPT_BUILDER_LAYER_NAME,
|
|
11
|
+
buildPath: getUserScriptBuilderLayerDir(),
|
|
12
|
+
modules: [...USER_SCRIPT_BUILDER_LAYER_MODULES],
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=getUserScriptBuilderApiLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuilderApiLayer.js","sourceRoot":"","sources":["../../../src/config/getUserScriptBuilderApiLayer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAa,EAAE,CAAC,CAAC;IAC3D,IAAI,EAAE,8BAA8B;IACpC,SAAS,EAAE,4BAA4B,EAAE;IACzC,OAAO,EAAE,CAAC,GAAG,iCAAiC,CAAC;CAChD,CAAC,CAAC","sourcesContent":["import { ApiLayer } from '@qpqjs/config-aws';\n\nimport { getUserScriptBuilderLayerDir } from './getUserScriptBuilderLayerDir';\nimport { USER_SCRIPT_BUILDER_LAYER_MODULES } from './USER_SCRIPT_BUILDER_LAYER_MODULES';\nimport { USER_SCRIPT_BUILDER_LAYER_NAME } from './USER_SCRIPT_BUILDER_LAYER_NAME';\n\n/**\n * The api layer entry that gives a service's lambdas rspack, for the service that\n * registered defineUserScriptBuilder. Points at the directory `qpq script:builder-layer`\n * produces, so the app's predeploy hook must run that command before a deploy.\n */\nexport const getUserScriptBuilderApiLayer = (): ApiLayer => ({\n name: USER_SCRIPT_BUILDER_LAYER_NAME,\n buildPath: getUserScriptBuilderLayerDir(),\n modules: [...USER_SCRIPT_BUILDER_LAYER_MODULES],\n});\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one directory the builder layer lives in: `<this package>/layer`. The api layer
|
|
3
|
+
* entry reads it and `qpq script:builder-layer` writes it, so neither side is told a
|
|
4
|
+
* path. Absolute, which is why the CDK resolves layer paths rather than joining them.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getUserScriptBuilderLayerDir: () => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { USER_SCRIPT_BUILDER_LAYER_NAME } from './USER_SCRIPT_BUILDER_LAYER_NAME';
|
|
4
|
+
const PACKAGE_NAME = '@qpqjs/user-script';
|
|
5
|
+
// This package's root, from src under ts-node or from lib/commonjs, by walking up to its
|
|
6
|
+
// own package.json.
|
|
7
|
+
const getOwnPackageRoot = () => {
|
|
8
|
+
let dir = __dirname;
|
|
9
|
+
while (true) {
|
|
10
|
+
const candidate = path.join(dir, 'package.json');
|
|
11
|
+
if (fs.existsSync(candidate) && JSON.parse(fs.readFileSync(candidate, 'utf8')).name === PACKAGE_NAME) {
|
|
12
|
+
return dir;
|
|
13
|
+
}
|
|
14
|
+
const parent = path.dirname(dir);
|
|
15
|
+
if (parent === dir)
|
|
16
|
+
throw new Error(`Could not locate the ${PACKAGE_NAME} package root from [${__dirname}]`);
|
|
17
|
+
dir = parent;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The one directory the builder layer lives in: `<this package>/layer`. The api layer
|
|
22
|
+
* entry reads it and `qpq script:builder-layer` writes it, so neither side is told a
|
|
23
|
+
* path. Absolute, which is why the CDK resolves layer paths rather than joining them.
|
|
24
|
+
*/
|
|
25
|
+
export const getUserScriptBuilderLayerDir = () => path.join(getOwnPackageRoot(), 'layer', USER_SCRIPT_BUILDER_LAYER_NAME);
|
|
26
|
+
//# sourceMappingURL=getUserScriptBuilderLayerDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUserScriptBuilderLayerDir.js","sourceRoot":"","sources":["../../../src/config/getUserScriptBuilderLayerDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAE1C,yFAAyF;AACzF,oBAAoB;AACpB,MAAM,iBAAiB,GAAG,GAAW,EAAE;IACrC,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACjD,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACrG,OAAO,GAAG,CAAC;QACb,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,YAAY,uBAAuB,SAAS,GAAG,CAAC,CAAC;QAC7G,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,OAAO,EAAE,8BAA8B,CAAC,CAAC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { USER_SCRIPT_BUILDER_LAYER_NAME } from './USER_SCRIPT_BUILDER_LAYER_NAME';\n\nconst PACKAGE_NAME = '@qpqjs/user-script';\n\n// This package's root, from src under ts-node or from lib/commonjs, by walking up to its\n// own package.json.\nconst getOwnPackageRoot = (): string => {\n let dir = __dirname;\n while (true) {\n const candidate = path.join(dir, 'package.json');\n if (fs.existsSync(candidate) && JSON.parse(fs.readFileSync(candidate, 'utf8')).name === PACKAGE_NAME) {\n return dir;\n }\n const parent = path.dirname(dir);\n if (parent === dir) throw new Error(`Could not locate the ${PACKAGE_NAME} package root from [${__dirname}]`);\n dir = parent;\n }\n};\n\n/**\n * The one directory the builder layer lives in: `<this package>/layer`. The api layer\n * entry reads it and `qpq script:builder-layer` writes it, so neither side is told a\n * path. Absolute, which is why the CDK resolves layer paths rather than joining them.\n */\nexport const getUserScriptBuilderLayerDir = (): string => path.join(getOwnPackageRoot(), 'layer', USER_SCRIPT_BUILDER_LAYER_NAME);\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './defineUserScriptBuilder';
|
|
2
|
+
export * from './getUserScriptBuilderApiLayer';
|
|
3
|
+
export * from './getUserScriptBuilderLayerDir';
|
|
4
|
+
export * from './USER_SCRIPT_BUILDER_LAYER_MODULES';
|
|
5
|
+
export * from './USER_SCRIPT_BUILDER_LAYER_NAME';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './defineUserScriptBuilder';\nexport * from './getUserScriptBuilderApiLayer';\nexport * from './getUserScriptBuilderLayerDir';\nexport * from './USER_SCRIPT_BUILDER_LAYER_MODULES';\nexport * from './USER_SCRIPT_BUILDER_LAYER_NAME';\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC","sourcesContent":["export * from './actionProcessor';\nexport * from './build';\nexport * from './config';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qpqjs/user-script",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Build user-written scripts into one loadable file, on a developer machine, the dev server or lambda",
|
|
5
|
+
"main": "./lib/commonjs/index.js",
|
|
6
|
+
"module": "./lib/esm/index.js",
|
|
7
|
+
"types": "./lib/commonjs/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"files": [
|
|
10
|
+
"lib/**/*"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"clean": "npx rimraf lib && npx rimraf node_modules",
|
|
18
|
+
"build": "npm run clean && npm run build:esm && npm run build:cjs",
|
|
19
|
+
"watch": "tsc -p tsconfig.commonjs.json -w",
|
|
20
|
+
"build:cjs": "tsc -p tsconfig.commonjs.json",
|
|
21
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
22
|
+
"lint": "npx eslint .",
|
|
23
|
+
"lint:fix": "npx eslint . --fix",
|
|
24
|
+
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json,css,scss,md}\""
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/qpqjs/quidproquo.git"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [],
|
|
31
|
+
"author": "",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/qpqjs/quidproquo/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/qpqjs/quidproquo#readme",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@rspack/core": "^2.1.2",
|
|
39
|
+
"@qpqjs/actionprocessor-node": "0.2.0",
|
|
40
|
+
"@qpqjs/config-aws": "0.2.0",
|
|
41
|
+
"@qpqjs/core": "0.2.0",
|
|
42
|
+
"yauzl": "^3.4.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.13.13",
|
|
46
|
+
"@types/yauzl": "^3.4.0",
|
|
47
|
+
"fflate": "^0.8.3",
|
|
48
|
+
"@qpqjs/actionprocessor-js": "0.2.0",
|
|
49
|
+
"@qpqjs/tsconfig": "0.2.0",
|
|
50
|
+
"typescript": "^5.8.2"
|
|
51
|
+
}
|
|
6
52
|
}
|