@bleedingdev/modern-js-app-tools-extensions 3.8.3-ultramodern.6 → 3.9.0-ultramodern.10
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/dist/cjs/backend-federation-build/codegen.js +256 -0
- package/dist/cjs/backend-federation-build/config.js +189 -0
- package/dist/cjs/backend-federation-build/emit.js +150 -0
- package/dist/cjs/backend-federation-build/index.js +53 -0
- package/dist/cjs/build-config/build-environment.js +268 -0
- package/dist/cjs/build-config/precompress/plugin.js +124 -0
- package/dist/cjs/build-config/precompress/types.js +18 -0
- package/dist/cjs/build-config/public.js +46 -0
- package/dist/cjs/cloudflare/constants.js +1 -1
- package/dist/cjs/cloudflare/delivery-unit.js +7 -16
- package/dist/cjs/cloudflare-output-contract.js +37 -1
- package/dist/cjs/cloudflare-output-verifier/identity.js +6 -6
- package/dist/cjs/cloudflare-output-verifier/worker-bundles.js +4 -1
- package/dist/cjs/config.js +29 -1
- package/dist/cjs/deploy-output/npmAliases.js +226 -0
- package/dist/cjs/deploy-output/plugin.js +76 -0
- package/dist/cjs/deploy-output/target.js +48 -0
- package/dist/cjs/native-type-checker.js +193 -0
- package/dist/cjs/policy-defaults.js +101 -0
- package/dist/cjs/release-envelope/framework-output.js +77 -32
- package/dist/cjs/release-envelope/plugin.js +5 -3
- package/dist/cjs/release-identity.js +3 -6
- package/dist/cjs/runtime-package-resolution.js +118 -0
- package/dist/esm/backend-federation-build/codegen.mjs +205 -0
- package/dist/esm/backend-federation-build/config.mjs +116 -0
- package/dist/esm/backend-federation-build/emit.mjs +99 -0
- package/dist/esm/backend-federation-build/index.mjs +1 -0
- package/dist/esm/build-config/build-environment.mjs +224 -0
- package/dist/esm/build-config/precompress/plugin.mjs +76 -0
- package/dist/esm/build-config/precompress/types.mjs +0 -0
- package/dist/esm/build-config/public.mjs +1 -0
- package/dist/esm/cloudflare/constants.mjs +1 -1
- package/dist/esm/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm/cloudflare-output-contract.mjs +35 -2
- package/dist/esm/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm/cloudflare-output-verifier/worker-bundles.mjs +5 -2
- package/dist/esm/config.mjs +1 -0
- package/dist/esm/deploy-output/npmAliases.mjs +174 -0
- package/dist/esm/deploy-output/plugin.mjs +28 -0
- package/dist/esm/deploy-output/target.mjs +10 -0
- package/dist/esm/native-type-checker.mjs +142 -0
- package/dist/esm/policy-defaults.mjs +45 -0
- package/dist/esm/release-envelope/framework-output.mjs +51 -6
- package/dist/esm/release-envelope/plugin.mjs +5 -3
- package/dist/esm/release-identity.mjs +3 -6
- package/dist/esm/runtime-package-resolution.mjs +60 -0
- package/dist/esm-node/backend-federation-build/codegen.mjs +206 -0
- package/dist/esm-node/backend-federation-build/config.mjs +117 -0
- package/dist/esm-node/backend-federation-build/emit.mjs +100 -0
- package/dist/esm-node/backend-federation-build/index.mjs +2 -0
- package/dist/esm-node/build-config/build-environment.mjs +225 -0
- package/dist/esm-node/build-config/precompress/plugin.mjs +77 -0
- package/dist/esm-node/build-config/precompress/types.mjs +1 -0
- package/dist/esm-node/build-config/public.mjs +2 -0
- package/dist/esm-node/cloudflare/constants.mjs +1 -1
- package/dist/esm-node/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm-node/cloudflare-output-contract.mjs +35 -2
- package/dist/esm-node/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm-node/cloudflare-output-verifier/worker-bundles.mjs +5 -2
- package/dist/esm-node/config.mjs +1 -0
- package/dist/esm-node/deploy-output/npmAliases.mjs +175 -0
- package/dist/esm-node/deploy-output/plugin.mjs +31 -0
- package/dist/esm-node/deploy-output/target.mjs +11 -0
- package/dist/esm-node/native-type-checker.mjs +143 -0
- package/dist/esm-node/policy-defaults.mjs +46 -0
- package/dist/esm-node/release-envelope/framework-output.mjs +51 -6
- package/dist/esm-node/release-envelope/plugin.mjs +5 -3
- package/dist/esm-node/release-identity.mjs +3 -6
- package/dist/esm-node/runtime-package-resolution.mjs +61 -0
- package/dist/types/backend-federation-build/codegen.d.ts +86 -0
- package/dist/types/backend-federation-build/config.d.ts +102 -0
- package/dist/types/backend-federation-build/emit.d.ts +21 -0
- package/dist/types/backend-federation-build/index.d.ts +2 -0
- package/dist/types/build-config/build-environment.d.ts +22 -0
- package/dist/types/build-config/precompress/plugin.d.ts +4 -0
- package/dist/types/build-config/precompress/types.d.ts +19 -0
- package/dist/types/build-config/public.d.ts +2 -0
- package/dist/types/cloudflare/artifacts.d.ts +1 -1
- package/dist/types/cloudflare/constants.d.ts +2 -2
- package/dist/types/cloudflare/delivery-unit.d.ts +2 -2
- package/dist/types/cloudflare/i18n-worker.d.ts +1 -1
- package/dist/types/cloudflare/index.d.ts +1 -1
- package/dist/types/cloudflare/security-policies.d.ts +1 -1
- package/dist/types/cloudflare/types.d.ts +1 -1
- package/dist/types/cloudflare/utils.d.ts +1 -1
- package/dist/types/cloudflare/worker-manifest.d.ts +4 -4
- package/dist/types/cloudflare/wrangler-config.d.ts +2 -2
- package/dist/types/cloudflare-output-contract.d.ts +2 -1
- package/dist/types/cloudflare-output-plan.d.ts +1 -1
- package/dist/types/cloudflare-output-verifier/identity.d.ts +2 -2
- package/dist/types/cloudflare-output-verifier/index.d.ts +5 -5
- package/dist/types/cloudflare-output-verifier/manifest.d.ts +1 -1
- package/dist/types/cloudflare-output-verifier/mutation-policy.d.ts +1 -1
- package/dist/types/cloudflare-output-verifier/worker-bundles.d.ts +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/deploy-output/npmAliases.d.ts +14 -0
- package/dist/types/deploy-output/plugin.d.ts +15 -0
- package/dist/types/deploy-output/target.d.ts +6 -0
- package/dist/types/index.d.ts +10 -10
- package/dist/types/native-type-checker.d.ts +15 -0
- package/dist/types/policy-defaults.d.ts +46 -0
- package/dist/types/precompress/LICENSE +20 -0
- package/dist/types/precompress/index.d.ts +76 -0
- package/dist/types/release-envelope/canonical.d.ts +1 -1
- package/dist/types/release-envelope/framework-output.d.ts +3 -2
- package/dist/types/release-envelope/index.d.ts +3 -3
- package/dist/types/runtime-package-resolution.d.ts +28 -0
- package/package.json +72 -14
- package/src/backend-federation-build/codegen.ts +245 -0
- package/src/backend-federation-build/config.ts +356 -0
- package/src/backend-federation-build/emit.ts +202 -0
- package/src/backend-federation-build/index.ts +2 -0
- package/src/build-config/build-environment.ts +404 -0
- package/src/build-config/precompress/plugin.ts +140 -0
- package/src/build-config/precompress/types.ts +26 -0
- package/src/build-config/public.ts +6 -0
- package/src/cloudflare/constants.ts +1 -1
- package/src/cloudflare/delivery-unit.ts +3 -20
- package/src/cloudflare/worker-manifest.ts +1 -0
- package/src/cloudflare-builder.ts +1 -0
- package/src/cloudflare-output-contract.ts +37 -0
- package/src/cloudflare-output-verifier/identity.ts +1 -1
- package/src/cloudflare-output-verifier/worker-bundles.ts +5 -3
- package/src/config.ts +7 -0
- package/src/deploy-output/npmAliases.ts +333 -0
- package/src/deploy-output/plugin.ts +49 -0
- package/src/deploy-output/target.ts +23 -0
- package/src/native-type-checker.ts +183 -0
- package/src/policy-defaults.ts +127 -0
- package/src/release-envelope/framework-output.ts +135 -4
- package/src/release-envelope/plugin.ts +15 -3
- package/src/release-identity.ts +3 -2
- package/src/runtime-package-resolution.ts +115 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { constants } from "node:zlib";
|
|
2
|
+
import compression_webpack_plugin from "compression-webpack-plugin";
|
|
3
|
+
const DEFAULT_PRECOMPRESS_TEST = /\.(js|mjs|cjs|css|html|svg|json|map)$/i;
|
|
4
|
+
const DEFAULT_PRECOMPRESS_THRESHOLD = 10240;
|
|
5
|
+
const DEFAULT_PRECOMPRESS_MIN_RATIO = 0.8;
|
|
6
|
+
const createDefaultGzipOptions = ()=>({
|
|
7
|
+
algorithm: 'gzip',
|
|
8
|
+
filename: '[path][base].gz',
|
|
9
|
+
test: DEFAULT_PRECOMPRESS_TEST,
|
|
10
|
+
threshold: DEFAULT_PRECOMPRESS_THRESHOLD,
|
|
11
|
+
minRatio: DEFAULT_PRECOMPRESS_MIN_RATIO,
|
|
12
|
+
compressionOptions: {
|
|
13
|
+
level: 6
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const createDefaultBrotliOptions = ()=>({
|
|
17
|
+
algorithm: 'brotliCompress',
|
|
18
|
+
filename: '[path][base].br',
|
|
19
|
+
test: DEFAULT_PRECOMPRESS_TEST,
|
|
20
|
+
threshold: DEFAULT_PRECOMPRESS_THRESHOLD,
|
|
21
|
+
minRatio: DEFAULT_PRECOMPRESS_MIN_RATIO,
|
|
22
|
+
compressionOptions: {
|
|
23
|
+
params: {
|
|
24
|
+
[constants.BROTLI_PARAM_QUALITY]: 9
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const mergeCompressionOptions = (base, next)=>{
|
|
29
|
+
const merged = {
|
|
30
|
+
...base,
|
|
31
|
+
...next
|
|
32
|
+
};
|
|
33
|
+
if (base.compressionOptions || next.compressionOptions) {
|
|
34
|
+
const baseCompressionOptions = base.compressionOptions;
|
|
35
|
+
const nextCompressionOptions = next.compressionOptions;
|
|
36
|
+
const mergedCompressionOptions = {
|
|
37
|
+
...baseCompressionOptions,
|
|
38
|
+
...nextCompressionOptions
|
|
39
|
+
};
|
|
40
|
+
if (baseCompressionOptions?.params || nextCompressionOptions?.params) mergedCompressionOptions.params = {
|
|
41
|
+
...baseCompressionOptions?.params,
|
|
42
|
+
...nextCompressionOptions?.params
|
|
43
|
+
};
|
|
44
|
+
merged.compressionOptions = mergedCompressionOptions;
|
|
45
|
+
}
|
|
46
|
+
return merged;
|
|
47
|
+
};
|
|
48
|
+
const resolveCodecOptions = (codecConfig, createDefaultOptions)=>{
|
|
49
|
+
if (false === codecConfig) return null;
|
|
50
|
+
if (void 0 === codecConfig || true === codecConfig) return createDefaultOptions();
|
|
51
|
+
return mergeCompressionOptions(createDefaultOptions(), codecConfig);
|
|
52
|
+
};
|
|
53
|
+
const resolvePrecompressConfig = (precompress)=>{
|
|
54
|
+
if (false === precompress || void 0 === precompress) return false;
|
|
55
|
+
if (true === precompress) return {};
|
|
56
|
+
return precompress;
|
|
57
|
+
};
|
|
58
|
+
const builderPluginAdapterPrecompress = (precompress)=>({
|
|
59
|
+
name: 'builder-plugin-adapter-modern-precompress',
|
|
60
|
+
setup (api) {
|
|
61
|
+
api.modifyBundlerChain((chain, { isProd, target })=>{
|
|
62
|
+
if (!isProd || 'web' !== target) return;
|
|
63
|
+
const precompressConfig = resolvePrecompressConfig(precompress);
|
|
64
|
+
if (false === precompressConfig) return;
|
|
65
|
+
const gzipOptions = resolveCodecOptions(precompressConfig.gzip, createDefaultGzipOptions);
|
|
66
|
+
if (gzipOptions) chain.plugin('modern-precompress-gzip').use(compression_webpack_plugin, [
|
|
67
|
+
gzipOptions
|
|
68
|
+
]);
|
|
69
|
+
const brotliOptions = resolveCodecOptions(precompressConfig.brotli, createDefaultBrotliOptions);
|
|
70
|
+
if (brotliOptions) chain.plugin('modern-precompress-brotli').use(compression_webpack_plugin, [
|
|
71
|
+
brotliOptions
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export { builderPluginAdapterPrecompress };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getBuildConfigEnvironment, resolveEffectTsgoCompiler, withBuildConfigEnvironment } from "./build-environment.mjs";
|
|
@@ -18,7 +18,7 @@ const DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES = [
|
|
|
18
18
|
];
|
|
19
19
|
const BFF_EFFECT_WORKER_ENTRY = `${WORKER_BUNDLE_DIRECTORY}/__modern_bff_effect.js`;
|
|
20
20
|
const BFF_EFFECT_WORKER_DISPATCHER_EXPORT = '__modern_create_effect_bff_dispatcher';
|
|
21
|
-
const EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE = 'Ensure the Effect API entry exists at api/index.ts or bff.effect.entry, and import Cloudflare edge handlers from @modern-js/
|
|
21
|
+
const EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE = 'Ensure the Effect API entry exists at api/index.ts or bff.effect.entry, and import Cloudflare edge handlers from @modern-js/bff-effect/effect-edge instead of lambda/Hono server helpers.';
|
|
22
22
|
const DEFAULT_COMPATIBILITY_DATE = '2026-06-02';
|
|
23
23
|
const COMPATIBILITY_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
|
|
24
24
|
const REQUIRED_COMPATIBILITY_FLAGS = CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
|
+
import { ULTRAMODERN_BUILD_ARTIFACT_PATH, isUltramodernBuildArtifact, nonEmptyString, toDeliveryUnitIdentity } from "@modern-js/backend-federation-contracts";
|
|
2
3
|
import { fs } from "@modern-js/utils";
|
|
3
|
-
import { ULTRAMODERN_BUILD_ARTIFACT_PATH, ULTRAMODERN_BUILD_MODULE_PATH, isUltramodernBuildArtifact, nonEmptyString, toDeliveryUnitIdentity } from "@modern-js/utils/universal";
|
|
4
4
|
import { resolveUltramodernReleaseIdentity } from "../release-identity.mjs";
|
|
5
5
|
import { isRecord } from "./utils.mjs";
|
|
6
6
|
const COMPACT_CONFIG_PATH = '.modernjs/ultramodern.json';
|
|
@@ -87,20 +87,11 @@ const resolveTopologyDeliveryUnit = async (appDirectory)=>{
|
|
|
87
87
|
};
|
|
88
88
|
const resolveWorkerDeliveryUnitStamp = async (appDirectory)=>{
|
|
89
89
|
const buildArtifactPath = node_path.join(appDirectory, ULTRAMODERN_BUILD_ARTIFACT_PATH);
|
|
90
|
-
const buildModulePath = node_path.join(appDirectory, ULTRAMODERN_BUILD_MODULE_PATH);
|
|
91
90
|
let identity;
|
|
92
91
|
if (await fs.pathExists(buildArtifactPath)) {
|
|
93
92
|
const artifact = await fs.readJSON(buildArtifactPath);
|
|
94
93
|
if (!isUltramodernBuildArtifact(artifact)) return;
|
|
95
94
|
identity = toDeliveryUnitIdentity(artifact.deliveryUnit);
|
|
96
|
-
} else if (await fs.pathExists(buildModulePath)) {
|
|
97
|
-
console.warn(`[cloudflare] ${buildArtifactPath} missing; falling back to legacy regex parsing of ${buildModulePath}. Regenerate the workspace to emit ultramodern-build.json.`);
|
|
98
|
-
const source = await fs.readFile(buildModulePath, 'utf8');
|
|
99
|
-
identity = toDeliveryUnitIdentity({
|
|
100
|
-
buildMarker: source.match(/\bbuild:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
101
|
-
unitId: source.match(/\bunitId:\s*['"]([^'"]+)['"]/u)?.[1],
|
|
102
|
-
sourceRevision: source.match(/\bsourceRevision:\s*['"]([^'"]+)['"]/u)?.[1]
|
|
103
|
-
});
|
|
104
95
|
}
|
|
105
96
|
if (!identity) return;
|
|
106
97
|
const resolved = await resolveCompactApp(appDirectory);
|
|
@@ -11,21 +11,54 @@ const CLOUDFLARE_OUTPUT_PACKAGE_TYPE = 'module';
|
|
|
11
11
|
const CLOUDFLARE_WORKER_PACKAGE_TYPE = 'commonjs';
|
|
12
12
|
const CLOUDFLARE_WORKER_BUNDLE_FORMAT = 'commonjs';
|
|
13
13
|
const CLOUDFLARE_WORKER_NODE_BUILTINS = [
|
|
14
|
+
'assert',
|
|
15
|
+
'assert/strict',
|
|
14
16
|
'async_hooks',
|
|
15
17
|
'buffer',
|
|
18
|
+
'child_process',
|
|
16
19
|
'crypto',
|
|
20
|
+
'dgram',
|
|
21
|
+
'dns',
|
|
22
|
+
'domain',
|
|
17
23
|
'events',
|
|
24
|
+
'fs',
|
|
18
25
|
'fs/promises',
|
|
26
|
+
'http',
|
|
27
|
+
'http2',
|
|
28
|
+
'inspector',
|
|
19
29
|
'module',
|
|
30
|
+
'net',
|
|
31
|
+
'os',
|
|
20
32
|
'path',
|
|
21
33
|
'process',
|
|
34
|
+
'readline',
|
|
35
|
+
'readline/promises',
|
|
36
|
+
'repl',
|
|
37
|
+
'sqlite',
|
|
22
38
|
'stream',
|
|
39
|
+
'stream/consumers',
|
|
40
|
+
'stream/promises',
|
|
41
|
+
'stream/web',
|
|
23
42
|
'string_decoder',
|
|
43
|
+
'timers',
|
|
44
|
+
'timers/promises',
|
|
45
|
+
'tls',
|
|
46
|
+
'trace_events',
|
|
47
|
+
'tty',
|
|
24
48
|
'url',
|
|
25
|
-
'util'
|
|
49
|
+
'util',
|
|
50
|
+
'util/types',
|
|
51
|
+
'v8',
|
|
52
|
+
'vm',
|
|
53
|
+
'wasi',
|
|
54
|
+
'worker_threads',
|
|
55
|
+
'zlib'
|
|
56
|
+
];
|
|
57
|
+
const CLOUDFLARE_WORKER_PLATFORM_MODULES = [
|
|
58
|
+
'cloudflare:sockets'
|
|
26
59
|
];
|
|
27
60
|
const CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS = [
|
|
28
61
|
'nodejs_compat',
|
|
29
62
|
'global_fetch_strictly_public'
|
|
30
63
|
];
|
|
31
|
-
export { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_BUNDLE_FORMAT, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WORKER_NODE_BUILTINS, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WRANGLER_CONFIG_FILE };
|
|
64
|
+
export { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_BUNDLE_FORMAT, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WORKER_NODE_BUILTINS, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WORKER_PLATFORM_MODULES, CLOUDFLARE_WRANGLER_CONFIG_FILE };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/
|
|
1
|
+
import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/backend-federation-contracts";
|
|
2
2
|
import { addIssue, assertEqual } from "./issues.mjs";
|
|
3
3
|
const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
|
|
4
4
|
const stamped = manifest?.deliveryUnit;
|
|
@@ -4,7 +4,7 @@ import { pathToFileURL } from "node:url";
|
|
|
4
4
|
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
import { parse } from "@babel/parser";
|
|
6
6
|
import traverse from "@babel/traverse";
|
|
7
|
-
import { CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_NODE_BUILTINS } from "../cloudflare-output-contract.mjs";
|
|
7
|
+
import { CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_NODE_BUILTINS, CLOUDFLARE_WORKER_PLATFORM_MODULES } from "../cloudflare-output-contract.mjs";
|
|
8
8
|
import { addIssue } from "./issues.mjs";
|
|
9
9
|
const getReferencedRouteWorkers = (manifest)=>Array.isArray(manifest?.routeSpec?.routes) ? manifest.routeSpec.routes.map((route)=>'string' == typeof route?.worker && route.worker.length > 0 ? route.worker : void 0).filter((worker)=>'string' == typeof worker) : [];
|
|
10
10
|
const getEffectBffWorker = (manifest)=>manifest?.bff?.runtimeFramework === 'effect' && 'string' == typeof manifest.bff.worker ? manifest.bff.worker : void 0;
|
|
@@ -174,7 +174,10 @@ const analyzeWorkerModule = (source)=>{
|
|
|
174
174
|
};
|
|
175
175
|
};
|
|
176
176
|
const getPackageName = (specifier)=>specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : specifier.split('/')[0];
|
|
177
|
-
const CLOUDFLARE_WORKER_NODE_BUILTIN_SPECIFIERS = new Set(
|
|
177
|
+
const CLOUDFLARE_WORKER_NODE_BUILTIN_SPECIFIERS = new Set([
|
|
178
|
+
...CLOUDFLARE_WORKER_NODE_BUILTINS.map((builtin)=>`node:${builtin}`),
|
|
179
|
+
...CLOUDFLARE_WORKER_PLATFORM_MODULES
|
|
180
|
+
]);
|
|
178
181
|
const isInsideDirectory = (directory, filePath)=>{
|
|
179
182
|
const relative = node_path.relative(directory, filePath);
|
|
180
183
|
return 0 === relative.length || !relative.startsWith('..') && !node_path.isAbsolute(relative);
|
package/dist/esm/config.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getBuildConfigEnvironment, resolveEffectTsgoCompiler, withBuildConfigEnvironment } from "./build-config/public.mjs";
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import promises from "node:fs/promises";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
const dependencyKeys = [
|
|
4
|
+
'dependencies',
|
|
5
|
+
'optionalDependencies'
|
|
6
|
+
];
|
|
7
|
+
const exactVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
8
|
+
async function readPackageJson(filePath) {
|
|
9
|
+
return JSON.parse(await promises.readFile(filePath, 'utf8'));
|
|
10
|
+
}
|
|
11
|
+
function parseNpmAlias(aliasName, specifier) {
|
|
12
|
+
if (!specifier.startsWith('npm:')) return;
|
|
13
|
+
const target = specifier.slice(4);
|
|
14
|
+
const versionSeparator = target.lastIndexOf('@');
|
|
15
|
+
if (versionSeparator <= 0 || versionSeparator === target.length - 1) throw new Error(`Invalid npm alias specifier for ${aliasName}: ${specifier}`);
|
|
16
|
+
return {
|
|
17
|
+
aliasName,
|
|
18
|
+
targetName: target.slice(0, versionSeparator),
|
|
19
|
+
targetVersion: target.slice(versionSeparator + 1)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function aliasesFromPackageJson(packageJson) {
|
|
23
|
+
const aliases = [];
|
|
24
|
+
for (const dependencyKey of dependencyKeys)for (const [aliasName, specifier] of Object.entries(packageJson[dependencyKey] ?? {})){
|
|
25
|
+
const alias = parseNpmAlias(aliasName, specifier);
|
|
26
|
+
if (alias) aliases.push(alias);
|
|
27
|
+
}
|
|
28
|
+
return aliases;
|
|
29
|
+
}
|
|
30
|
+
async function collectPackageRecords(nodeModulesDirectory) {
|
|
31
|
+
const records = [];
|
|
32
|
+
const visitedNodeModules = new Set();
|
|
33
|
+
const visitPackage = async (directory)=>{
|
|
34
|
+
const packageJsonPath = node_path.join(directory, 'package.json');
|
|
35
|
+
try {
|
|
36
|
+
const packageJson = await readPackageJson(packageJsonPath);
|
|
37
|
+
if (packageJson.name && packageJson.version) records.push({
|
|
38
|
+
directory,
|
|
39
|
+
packageJson
|
|
40
|
+
});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if ('ENOENT' !== error.code) throw error;
|
|
43
|
+
}
|
|
44
|
+
await visitNodeModules(node_path.join(directory, 'node_modules'));
|
|
45
|
+
};
|
|
46
|
+
const visitScope = async (scopeDirectory)=>{
|
|
47
|
+
const entries = await promises.readdir(scopeDirectory, {
|
|
48
|
+
withFileTypes: true
|
|
49
|
+
});
|
|
50
|
+
for (const entry of entries)if (entry.isDirectory()) await visitPackage(node_path.join(scopeDirectory, entry.name));
|
|
51
|
+
};
|
|
52
|
+
const visitNdepeStore = async (storeDirectory)=>{
|
|
53
|
+
const entries = await promises.readdir(storeDirectory, {
|
|
54
|
+
withFileTypes: true
|
|
55
|
+
});
|
|
56
|
+
for (const entry of entries)if (entry.isDirectory()) {
|
|
57
|
+
const entryPath = node_path.join(storeDirectory, entry.name);
|
|
58
|
+
if (entry.name.startsWith('@')) await visitScope(entryPath);
|
|
59
|
+
else await visitNodeModules(node_path.join(entryPath, 'node_modules'));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const visitNodeModules = async (directory)=>{
|
|
63
|
+
const resolvedDirectory = node_path.resolve(directory);
|
|
64
|
+
if (visitedNodeModules.has(resolvedDirectory)) return;
|
|
65
|
+
visitedNodeModules.add(resolvedDirectory);
|
|
66
|
+
let entries;
|
|
67
|
+
try {
|
|
68
|
+
entries = await promises.readdir(directory, {
|
|
69
|
+
withFileTypes: true
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if ('ENOENT' === error.code) return;
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
for (const entry of entries){
|
|
76
|
+
if (!entry.isDirectory()) continue;
|
|
77
|
+
const entryPath = node_path.join(directory, entry.name);
|
|
78
|
+
if ('.ndepe' === entry.name) await visitNdepeStore(entryPath);
|
|
79
|
+
else if (entry.name.startsWith('@')) await visitScope(entryPath);
|
|
80
|
+
else await visitPackage(entryPath);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
await visitNodeModules(nodeModulesDirectory);
|
|
84
|
+
return records;
|
|
85
|
+
}
|
|
86
|
+
async function resolveAliasTarget(ownerDirectory, alias, outputDirectory) {
|
|
87
|
+
let directory = ownerDirectory;
|
|
88
|
+
const outputRoot = node_path.resolve(outputDirectory);
|
|
89
|
+
const resolvedOutputRoot = await promises.realpath(outputRoot);
|
|
90
|
+
while(directory === outputRoot || directory.startsWith(`${outputRoot}${node_path.sep}`)){
|
|
91
|
+
const candidate = node_path.join(directory, 'node_modules', alias.targetName);
|
|
92
|
+
try {
|
|
93
|
+
const resolvedCandidate = await promises.realpath(candidate);
|
|
94
|
+
if (resolvedCandidate !== resolvedOutputRoot && !resolvedCandidate.startsWith(`${resolvedOutputRoot}${node_path.sep}`)) throw new Error(`Cannot preserve npm alias ${alias.aliasName}: emitted target ${candidate} resolves outside deployment output to ${resolvedCandidate}`);
|
|
95
|
+
const packageJson = await readPackageJson(node_path.join(candidate, 'package.json'));
|
|
96
|
+
if (packageJson.name !== alias.targetName || !packageJson.version) throw new Error(`npm alias ${alias.aliasName} resolved ${candidate} to unexpected package ${String(packageJson.name)}`);
|
|
97
|
+
if (exactVersionPattern.test(alias.targetVersion) && packageJson.version !== alias.targetVersion) return;
|
|
98
|
+
return {
|
|
99
|
+
directory: candidate,
|
|
100
|
+
packageJson
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if ('ENOENT' !== error.code) throw error;
|
|
104
|
+
}
|
|
105
|
+
if (directory === outputRoot) break;
|
|
106
|
+
directory = node_path.dirname(directory);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function ensureAliasLink(ownerDirectory, alias, target) {
|
|
110
|
+
const aliasPath = node_path.join(ownerDirectory, 'node_modules', alias.aliasName);
|
|
111
|
+
await promises.mkdir(node_path.dirname(aliasPath), {
|
|
112
|
+
recursive: true
|
|
113
|
+
});
|
|
114
|
+
try {
|
|
115
|
+
const [existing, expected] = await Promise.all([
|
|
116
|
+
promises.realpath(aliasPath),
|
|
117
|
+
promises.realpath(target.directory)
|
|
118
|
+
]);
|
|
119
|
+
if (existing === expected) return;
|
|
120
|
+
throw new Error(`Cannot preserve npm alias ${alias.aliasName}: ${aliasPath} already resolves to ${existing}, expected ${expected}`);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if ('ENOENT' !== error.code) throw error;
|
|
123
|
+
}
|
|
124
|
+
const linkTarget = node_path.relative(node_path.dirname(aliasPath), target.directory);
|
|
125
|
+
await promises.symlink(linkTarget, aliasPath, 'dir');
|
|
126
|
+
}
|
|
127
|
+
function aliasSpecifier(alias) {
|
|
128
|
+
return `npm:${alias.targetName}@${alias.targetVersion}`;
|
|
129
|
+
}
|
|
130
|
+
async function readPackageIdentity(entryPath) {
|
|
131
|
+
let directory = node_path.dirname(entryPath);
|
|
132
|
+
const root = node_path.parse(directory).root;
|
|
133
|
+
while(directory !== root){
|
|
134
|
+
try {
|
|
135
|
+
const packageJson = await readPackageJson(node_path.join(directory, 'package.json'));
|
|
136
|
+
if (packageJson.name && packageJson.version) return {
|
|
137
|
+
name: packageJson.name,
|
|
138
|
+
version: packageJson.version
|
|
139
|
+
};
|
|
140
|
+
} catch (error) {
|
|
141
|
+
if ('ENOENT' !== error.code) throw error;
|
|
142
|
+
}
|
|
143
|
+
directory = node_path.dirname(directory);
|
|
144
|
+
}
|
|
145
|
+
throw new Error(`Cannot find owning package for deployment entry ${entryPath}`);
|
|
146
|
+
}
|
|
147
|
+
async function preserveNpmAliases({ appDirectory, outputDirectory, implicitAliases = [] }) {
|
|
148
|
+
const records = await collectPackageRecords(node_path.join(outputDirectory, 'node_modules'));
|
|
149
|
+
const appPackageJson = await readPackageJson(node_path.join(appDirectory, 'package.json'));
|
|
150
|
+
const rootAliases = [
|
|
151
|
+
...aliasesFromPackageJson(appPackageJson),
|
|
152
|
+
...implicitAliases
|
|
153
|
+
].filter((alias)=>alias.aliasName !== alias.targetName);
|
|
154
|
+
const emittedRootAliases = [];
|
|
155
|
+
for (const alias of rootAliases){
|
|
156
|
+
const target = await resolveAliasTarget(outputDirectory, alias, outputDirectory);
|
|
157
|
+
if (!target) {
|
|
158
|
+
if (implicitAliases.includes(alias)) throw new Error(`Cannot preserve implicit npm alias ${alias.aliasName}: emitted target ${alias.targetName}@${alias.targetVersion} is missing`);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
await ensureAliasLink(outputDirectory, alias, target);
|
|
162
|
+
emittedRootAliases.push(alias);
|
|
163
|
+
}
|
|
164
|
+
for (const record of records)for (const alias of aliasesFromPackageJson(record.packageJson).filter((candidate)=>candidate.aliasName !== candidate.targetName)){
|
|
165
|
+
const target = await resolveAliasTarget(record.directory, alias, outputDirectory);
|
|
166
|
+
if (target) await ensureAliasLink(record.directory, alias, target);
|
|
167
|
+
}
|
|
168
|
+
const outputPackageJsonPath = node_path.join(outputDirectory, 'package.json');
|
|
169
|
+
const outputPackageJson = await readPackageJson(outputPackageJsonPath);
|
|
170
|
+
outputPackageJson.dependencies ??= {};
|
|
171
|
+
for (const alias of emittedRootAliases)outputPackageJson.dependencies[alias.aliasName] = aliasSpecifier(alias);
|
|
172
|
+
await promises.writeFile(outputPackageJsonPath, `${JSON.stringify(outputPackageJson, null, 2)}\n`);
|
|
173
|
+
}
|
|
174
|
+
export { preserveNpmAliases, readPackageIdentity };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { preserveNpmAliases, readPackageIdentity } from "./npmAliases.mjs";
|
|
4
|
+
import { resolveDeployTarget as external_target_mjs_resolveDeployTarget } from "./target.mjs";
|
|
5
|
+
const createDeployOutputAliasesPlugin = ({ resolveDeployTarget = external_target_mjs_resolveDeployTarget } = {})=>({
|
|
6
|
+
name: '@modern-js/deploy-output-aliases',
|
|
7
|
+
setup (api) {
|
|
8
|
+
api.onAfterDeploy(async ()=>{
|
|
9
|
+
const { appDirectory, metaName } = api.getAppContext();
|
|
10
|
+
const config = api.getNormalizedConfig();
|
|
11
|
+
if ('modern-js' !== metaName && !config.deploy?.target && !process.env.MODERNJS_DEPLOY || 'node' !== resolveDeployTarget(config)) return;
|
|
12
|
+
const entry = createRequire(__filename).resolve('@modern-js/prod-server');
|
|
13
|
+
const identity = await readPackageIdentity(entry);
|
|
14
|
+
await preserveNpmAliases({
|
|
15
|
+
appDirectory,
|
|
16
|
+
outputDirectory: node_path.join(appDirectory, '.output'),
|
|
17
|
+
implicitAliases: [
|
|
18
|
+
{
|
|
19
|
+
aliasName: '@modern-js/prod-server',
|
|
20
|
+
targetName: identity.name,
|
|
21
|
+
targetVersion: identity.version
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
export { createDeployOutputAliasesPlugin };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { provider } from "std-env";
|
|
2
|
+
const providerDeployTargets = {
|
|
3
|
+
vercel: 'vercel',
|
|
4
|
+
netlify: 'netlify',
|
|
5
|
+
cloudflare: 'cloudflare',
|
|
6
|
+
cloudflare_pages: 'cloudflare',
|
|
7
|
+
cloudflare_workers: 'cloudflare'
|
|
8
|
+
};
|
|
9
|
+
const resolveDeployTarget = (config, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = provider)=>config.deploy?.target || envDeployTarget || (detectedProvider ? providerDeployTargets[detectedProvider] : void 0) || 'node';
|
|
10
|
+
export { resolveDeployTarget };
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { refreshTsgoCheckerConfig } from "@modern-js/builder";
|
|
6
|
+
const execute = promisify(execFile);
|
|
7
|
+
const native_type_checker_name = 'UltramodernNativeTypeChecker';
|
|
8
|
+
const watchDependencyPath = (file)=>{
|
|
9
|
+
if ('win32' !== process.platform) return file;
|
|
10
|
+
try {
|
|
11
|
+
return realpathSync.native(file);
|
|
12
|
+
} catch {
|
|
13
|
+
return file;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
class UltramodernNativeTypeChecker {
|
|
17
|
+
async check() {
|
|
18
|
+
const { configFile, build } = this.options;
|
|
19
|
+
if (!build) {
|
|
20
|
+
const config = JSON.parse(await this.run([
|
|
21
|
+
'--showConfig',
|
|
22
|
+
'--project',
|
|
23
|
+
configFile
|
|
24
|
+
]));
|
|
25
|
+
if (config.references?.length) await this.run([
|
|
26
|
+
'--build',
|
|
27
|
+
...config.references.map((reference)=>node_path.resolve(node_path.dirname(configFile), reference.path)),
|
|
28
|
+
'--stopBuildOnErrors',
|
|
29
|
+
'--pretty',
|
|
30
|
+
'false'
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
const args = build ? [
|
|
34
|
+
'--build',
|
|
35
|
+
configFile,
|
|
36
|
+
'--stopBuildOnErrors'
|
|
37
|
+
] : [
|
|
38
|
+
'--project',
|
|
39
|
+
configFile,
|
|
40
|
+
'--noEmit'
|
|
41
|
+
];
|
|
42
|
+
await this.run([
|
|
43
|
+
...args,
|
|
44
|
+
'--pretty',
|
|
45
|
+
'false'
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
async run(args) {
|
|
49
|
+
try {
|
|
50
|
+
const result = await execute(this.options.compiler(), args, {
|
|
51
|
+
cwd: node_path.dirname(this.options.configFile),
|
|
52
|
+
maxBuffer: 16777216
|
|
53
|
+
});
|
|
54
|
+
return result.stdout;
|
|
55
|
+
} catch (cause) {
|
|
56
|
+
const output = cause;
|
|
57
|
+
const diagnostics = `${output.stdout ?? ''}${output.stderr ?? ''}`;
|
|
58
|
+
throw new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}`, {
|
|
59
|
+
cause
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async watchInputs() {
|
|
64
|
+
const inputs = new Set();
|
|
65
|
+
const missing = new Set();
|
|
66
|
+
const projects = [
|
|
67
|
+
this.options.configFile
|
|
68
|
+
];
|
|
69
|
+
const visited = new Set();
|
|
70
|
+
for (const configFile of projects){
|
|
71
|
+
if (visited.has(configFile)) continue;
|
|
72
|
+
visited.add(configFile);
|
|
73
|
+
inputs.add(configFile);
|
|
74
|
+
if (!existsSync(configFile)) {
|
|
75
|
+
missing.add(configFile);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
let config;
|
|
79
|
+
try {
|
|
80
|
+
config = JSON.parse(await this.run([
|
|
81
|
+
'--showConfig',
|
|
82
|
+
'--project',
|
|
83
|
+
configFile
|
|
84
|
+
]));
|
|
85
|
+
} catch {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const directory = node_path.dirname(configFile);
|
|
89
|
+
for (const file of config.files ?? [])inputs.add(node_path.resolve(directory, file));
|
|
90
|
+
for (const reference of config.references ?? []){
|
|
91
|
+
const target = node_path.resolve(directory, reference.path);
|
|
92
|
+
projects.push('.json' === node_path.extname(target) ? target : node_path.join(target, 'tsconfig.json'));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
inputs,
|
|
97
|
+
missing
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
apply(compiler) {
|
|
101
|
+
compiler.hooks.thisCompilation.tap(native_type_checker_name, (compilation)=>{
|
|
102
|
+
compilation.hooks.processAssets.tapPromise(native_type_checker_name, async ()=>{
|
|
103
|
+
try {
|
|
104
|
+
compilation.fileDependencies.add(watchDependencyPath(this.options.configFile));
|
|
105
|
+
const projectConfigFile = refreshTsgoCheckerConfig(this.options.configFile);
|
|
106
|
+
if (projectConfigFile) {
|
|
107
|
+
const watched = watchDependencyPath(projectConfigFile);
|
|
108
|
+
compilation.fileDependencies.add(watched);
|
|
109
|
+
if (!existsSync(projectConfigFile)) compilation.missingDependencies.add(watched);
|
|
110
|
+
}
|
|
111
|
+
const { inputs, missing } = await this.watchInputs();
|
|
112
|
+
for (const file of inputs)compilation.fileDependencies.add(watchDependencyPath(file));
|
|
113
|
+
for (const file of missing)compilation.missingDependencies.add(watchDependencyPath(file));
|
|
114
|
+
await this.check();
|
|
115
|
+
} catch (cause) {
|
|
116
|
+
compilation.errors.push(new Error(cause instanceof Error ? cause.message : String(cause), {
|
|
117
|
+
cause
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
constructor(options){
|
|
124
|
+
this.options = options;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function configureUltramodernTypeChecker(chain, pluginId, resolveCompiler) {
|
|
128
|
+
if (!chain.plugins.has(pluginId)) return;
|
|
129
|
+
const options = chain.plugin(pluginId).get('args')?.[0];
|
|
130
|
+
const typescript = options?.typescript;
|
|
131
|
+
if (typescript?.tsgo === false) return;
|
|
132
|
+
if (!typescript?.configFile) throw new Error(`${native_type_checker_name} requires the configured TypeScript project.`);
|
|
133
|
+
const configFile = node_path.resolve(typescript.configFile);
|
|
134
|
+
chain.plugin(pluginId).use(UltramodernNativeTypeChecker, [
|
|
135
|
+
{
|
|
136
|
+
build: true === typescript.build,
|
|
137
|
+
compiler: ()=>resolveCompiler(configFile),
|
|
138
|
+
configFile
|
|
139
|
+
}
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
export { UltramodernNativeTypeChecker, configureUltramodernTypeChecker };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { collectRuntimePackageModuleDirectories, createRuntimePackageResolutionPlugin } from "./runtime-package-resolution.mjs";
|
|
2
|
+
const RENDERER_EXTENSIONS_PACKAGE = '@modern-js/runtime-renderer-extensions';
|
|
3
|
+
const RENDERER_EXTENSIONS_PLUGIN_NAME = 'rendererHead';
|
|
4
|
+
const SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/app-tools/server-plugin';
|
|
5
|
+
const POLICY_DEFAULTS_PLUGIN_NAME = '@modern-js/ultramodern-policy-defaults';
|
|
6
|
+
const applyPolicyDefaults = (api, options = {})=>{
|
|
7
|
+
if (false !== options.rendererExtensions) {
|
|
8
|
+
api._internalRuntimePlugins(({ entrypoint, plugins })=>{
|
|
9
|
+
if (!plugins.some((plugin)=>plugin.path === RENDERER_EXTENSIONS_PACKAGE)) plugins.push({
|
|
10
|
+
name: RENDERER_EXTENSIONS_PLUGIN_NAME,
|
|
11
|
+
path: RENDERER_EXTENSIONS_PACKAGE,
|
|
12
|
+
config: {}
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
entrypoint,
|
|
16
|
+
plugins
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const moduleDirectories = collectRuntimePackageModuleDirectories([
|
|
20
|
+
RENDERER_EXTENSIONS_PACKAGE
|
|
21
|
+
], import.meta.url);
|
|
22
|
+
if (moduleDirectories.length > 0) api.modifyResolvedConfig((config)=>({
|
|
23
|
+
...config,
|
|
24
|
+
builderPlugins: [
|
|
25
|
+
...config.builderPlugins ?? [],
|
|
26
|
+
createRuntimePackageResolutionPlugin(moduleDirectories)
|
|
27
|
+
]
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
if (false !== options.serverExtensions) api._internalServerPlugins(({ plugins })=>{
|
|
31
|
+
if (!plugins.some((plugin)=>plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME)) plugins.push({
|
|
32
|
+
name: SERVER_EXTENSIONS_PLUGIN_NAME
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
plugins
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const createPolicyDefaultsPlugin = (options = {})=>({
|
|
40
|
+
name: POLICY_DEFAULTS_PLUGIN_NAME,
|
|
41
|
+
setup (api) {
|
|
42
|
+
applyPolicyDefaults(api, options);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export { POLICY_DEFAULTS_PLUGIN_NAME, RENDERER_EXTENSIONS_PACKAGE, RENDERER_EXTENSIONS_PLUGIN_NAME, SERVER_EXTENSIONS_PLUGIN_NAME, applyPolicyDefaults, createPolicyDefaultsPlugin };
|