@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.9 → 3.9.3-ultramodern.2
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 +23 -0
- package/dist/cjs/backend-federation-build/codegen.js +29 -18
- package/dist/cjs/backend-federation-build/config.js +84 -45
- package/dist/cjs/backend-federation-build/emit.js +63 -22
- package/dist/cjs/build-config/build-environment.js +25 -162
- package/dist/cjs/build-config/internal-effect-discovery.js +143 -0
- package/dist/cjs/build-config/public.js +2 -5
- package/dist/cjs/build-config/remote-address.js +58 -0
- package/dist/cjs/cloudflare/artifacts.js +8 -19
- package/dist/cjs/cloudflare/delivery-unit.js +125 -43
- package/dist/cjs/cloudflare/index.js +14 -4
- package/dist/cjs/cloudflare/native-renderer.js +100 -0
- package/dist/cjs/cloudflare/renderer-identity.js +106 -0
- package/dist/cjs/cloudflare/worker-manifest.js +54 -13
- package/dist/cjs/cloudflare/worker-options.js +48 -0
- package/dist/cjs/cloudflare/wrangler-config.js +210 -13
- package/dist/cjs/cloudflare-builder.js +307 -89
- package/dist/cjs/cloudflare-output-contract.js +36 -4
- package/dist/cjs/cloudflare-output-verifier/identity.js +112 -23
- package/dist/cjs/cloudflare-output-verifier/index.js +10 -0
- package/dist/cjs/cloudflare-output-verifier/manifest.js +46 -0
- package/dist/cjs/cloudflare-output-verifier/mutation-policy.js +7 -1
- package/dist/cjs/cloudflare-output-verifier/worker-bundles.js +10 -5
- package/dist/cjs/config.js +10 -5
- package/dist/cjs/deploy-output/npmAliases.js +92 -6
- package/dist/cjs/deploy-output/plugin.js +27 -6
- package/dist/cjs/deploy-output/public-assets.js +146 -0
- package/dist/cjs/deploy-output/target.js +57 -1
- package/dist/cjs/deploy-output/trace-files.js +99 -0
- package/dist/cjs/module-federation-config/exposes.js +70 -0
- package/dist/cjs/module-federation-config/index.js +73 -0
- package/dist/cjs/module-federation-config/inspect.js +103 -0
- package/dist/cjs/module-federation-config/object-literal.js +87 -0
- package/dist/cjs/module-federation-config/syntax.js +151 -0
- package/dist/cjs/module-federation-config/types.js +18 -0
- package/dist/cjs/native-type-checker.js +130 -13
- package/dist/cjs/policy-defaults.js +38 -29
- package/dist/cjs/release-envelope/canonical.js +2 -9
- package/dist/cjs/release-envelope/contract.js +68 -0
- package/dist/cjs/release-envelope/framework-output.js +296 -105
- package/dist/cjs/release-envelope/index.js +150 -36
- package/dist/cjs/release-envelope/plugin.js +24 -15
- package/dist/cjs/release-envelope/renderer-output-stamp.js +170 -0
- package/dist/cjs/release-envelope/types.js +10 -8
- package/dist/cjs/release-identity.js +8 -5
- package/dist/cjs/renderer-build-identity.js +134 -0
- package/dist/cjs/templates/cloudflare-entry.001-bootstrap-security.mjs +14 -6
- package/dist/cjs/templates/cloudflare-entry.002-assets-routes.mjs +10 -2
- package/dist/cjs/templates/cloudflare-entry.004-rendering-css.mjs +403 -96
- package/dist/cjs/templates/cloudflare-entry.005-worker-dispatch.mjs +530 -103
- package/dist/cjs/templates/cloudflare-entry.006-fetch-handler.mjs +26 -7
- package/dist/cjs/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/cjs/workspace-topology.js +84 -0
- package/dist/esm/backend-federation-build/codegen.mjs +29 -18
- package/dist/esm/backend-federation-build/config.mjs +74 -38
- package/dist/esm/backend-federation-build/emit.mjs +64 -23
- package/dist/esm/build-config/build-environment.mjs +26 -160
- package/dist/esm/build-config/internal-effect-discovery.mjs +102 -0
- package/dist/esm/build-config/public.mjs +1 -1
- package/dist/esm/build-config/remote-address.mjs +20 -0
- package/dist/esm/cloudflare/artifacts.mjs +8 -19
- package/dist/esm/cloudflare/delivery-unit.mjs +124 -45
- package/dist/esm/cloudflare/index.mjs +15 -5
- package/dist/esm/cloudflare/native-renderer.mjs +48 -0
- package/dist/esm/cloudflare/renderer-identity.mjs +57 -0
- package/dist/esm/cloudflare/worker-manifest.mjs +55 -14
- package/dist/esm/cloudflare/worker-options.mjs +10 -0
- package/dist/esm/cloudflare/wrangler-config.mjs +203 -12
- package/dist/esm/cloudflare-builder.mjs +301 -89
- package/dist/esm/cloudflare-output-contract.mjs +29 -3
- package/dist/esm/cloudflare-output-verifier/identity.mjs +113 -24
- package/dist/esm/cloudflare-output-verifier/index.mjs +10 -0
- package/dist/esm/cloudflare-output-verifier/manifest.mjs +46 -0
- package/dist/esm/cloudflare-output-verifier/mutation-policy.mjs +7 -1
- package/dist/esm/cloudflare-output-verifier/worker-bundles.mjs +11 -6
- package/dist/esm/config.mjs +3 -1
- package/dist/esm/deploy-output/npmAliases.mjs +92 -6
- package/dist/esm/deploy-output/plugin.mjs +24 -6
- package/dist/esm/deploy-output/public-assets.mjs +82 -0
- package/dist/esm/deploy-output/target.mjs +50 -3
- package/dist/esm/deploy-output/trace-files.mjs +47 -0
- package/dist/esm/module-federation-config/exposes.mjs +18 -0
- package/dist/esm/module-federation-config/index.mjs +4 -0
- package/dist/esm/module-federation-config/inspect.mjs +65 -0
- package/dist/esm/module-federation-config/object-literal.mjs +43 -0
- package/dist/esm/module-federation-config/syntax.mjs +101 -0
- package/dist/esm/module-federation-config/types.mjs +0 -0
- package/dist/esm/native-type-checker.mjs +124 -13
- package/dist/esm/policy-defaults.mjs +36 -30
- package/dist/esm/release-envelope/canonical.mjs +2 -9
- package/dist/esm/release-envelope/contract.mjs +21 -0
- package/dist/esm/release-envelope/framework-output.mjs +297 -106
- package/dist/esm/release-envelope/index.mjs +149 -38
- package/dist/esm/release-envelope/plugin.mjs +24 -15
- package/dist/esm/release-envelope/renderer-output-stamp.mjs +112 -0
- package/dist/esm/release-envelope/types.mjs +2 -3
- package/dist/esm/release-identity.mjs +8 -5
- package/dist/esm/renderer-build-identity.mjs +82 -0
- package/dist/esm/templates/cloudflare-entry.001-bootstrap-security.mjs +14 -6
- package/dist/esm/templates/cloudflare-entry.002-assets-routes.mjs +10 -2
- package/dist/esm/templates/cloudflare-entry.004-rendering-css.mjs +403 -96
- package/dist/esm/templates/cloudflare-entry.005-worker-dispatch.mjs +530 -103
- package/dist/esm/templates/cloudflare-entry.006-fetch-handler.mjs +26 -7
- package/dist/esm/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/esm/workspace-topology.mjs +21 -0
- package/dist/esm-node/backend-federation-build/codegen.mjs +29 -18
- package/dist/esm-node/backend-federation-build/config.mjs +74 -38
- package/dist/esm-node/backend-federation-build/emit.mjs +64 -23
- package/dist/esm-node/build-config/build-environment.mjs +26 -160
- package/dist/esm-node/build-config/internal-effect-discovery.mjs +103 -0
- package/dist/esm-node/build-config/public.mjs +1 -1
- package/dist/esm-node/build-config/remote-address.mjs +21 -0
- package/dist/esm-node/cloudflare/artifacts.mjs +8 -19
- package/dist/esm-node/cloudflare/delivery-unit.mjs +124 -45
- package/dist/esm-node/cloudflare/index.mjs +15 -5
- package/dist/esm-node/cloudflare/native-renderer.mjs +49 -0
- package/dist/esm-node/cloudflare/renderer-identity.mjs +58 -0
- package/dist/esm-node/cloudflare/worker-manifest.mjs +55 -14
- package/dist/esm-node/cloudflare/worker-options.mjs +11 -0
- package/dist/esm-node/cloudflare/wrangler-config.mjs +203 -12
- package/dist/esm-node/cloudflare-builder.mjs +301 -89
- package/dist/esm-node/cloudflare-output-contract.mjs +29 -3
- package/dist/esm-node/cloudflare-output-verifier/identity.mjs +113 -24
- package/dist/esm-node/cloudflare-output-verifier/index.mjs +10 -0
- package/dist/esm-node/cloudflare-output-verifier/manifest.mjs +46 -0
- package/dist/esm-node/cloudflare-output-verifier/mutation-policy.mjs +7 -1
- package/dist/esm-node/cloudflare-output-verifier/worker-bundles.mjs +11 -6
- package/dist/esm-node/config.mjs +3 -1
- package/dist/esm-node/deploy-output/npmAliases.mjs +92 -6
- package/dist/esm-node/deploy-output/plugin.mjs +24 -6
- package/dist/esm-node/deploy-output/public-assets.mjs +83 -0
- package/dist/esm-node/deploy-output/target.mjs +50 -3
- package/dist/esm-node/deploy-output/trace-files.mjs +48 -0
- package/dist/esm-node/module-federation-config/exposes.mjs +19 -0
- package/dist/esm-node/module-federation-config/index.mjs +5 -0
- package/dist/esm-node/module-federation-config/inspect.mjs +66 -0
- package/dist/esm-node/module-federation-config/object-literal.mjs +44 -0
- package/dist/esm-node/module-federation-config/syntax.mjs +102 -0
- package/dist/esm-node/module-federation-config/types.mjs +1 -0
- package/dist/esm-node/native-type-checker.mjs +124 -13
- package/dist/esm-node/policy-defaults.mjs +36 -30
- package/dist/esm-node/release-envelope/canonical.mjs +2 -9
- package/dist/esm-node/release-envelope/contract.mjs +22 -0
- package/dist/esm-node/release-envelope/framework-output.mjs +297 -106
- package/dist/esm-node/release-envelope/index.mjs +149 -38
- package/dist/esm-node/release-envelope/plugin.mjs +24 -15
- package/dist/esm-node/release-envelope/renderer-output-stamp.mjs +113 -0
- package/dist/esm-node/release-envelope/types.mjs +2 -3
- package/dist/esm-node/release-identity.mjs +8 -5
- package/dist/esm-node/renderer-build-identity.mjs +83 -0
- package/dist/esm-node/templates/cloudflare-entry.001-bootstrap-security.mjs +14 -6
- package/dist/esm-node/templates/cloudflare-entry.002-assets-routes.mjs +10 -2
- package/dist/esm-node/templates/cloudflare-entry.004-rendering-css.mjs +403 -96
- package/dist/esm-node/templates/cloudflare-entry.005-worker-dispatch.mjs +530 -103
- package/dist/esm-node/templates/cloudflare-entry.006-fetch-handler.mjs +26 -7
- package/dist/esm-node/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/dist/esm-node/workspace-topology.mjs +22 -0
- package/dist/types/backend-federation-build/codegen.d.ts +30 -0
- package/dist/types/backend-federation-build/config.d.ts +10 -57
- package/dist/types/backend-federation-build/emit.d.ts +12 -2
- package/dist/types/backend-federation-build/index.d.ts +1 -1
- package/dist/types/build-config/build-environment.d.ts +1 -9
- package/dist/types/build-config/internal-effect-discovery.d.ts +4 -0
- package/dist/types/build-config/public.d.ts +1 -1
- package/dist/types/build-config/remote-address.d.ts +3 -0
- package/dist/types/cloudflare/artifacts.d.ts +7 -6
- package/dist/types/cloudflare/constants.d.ts +1 -1
- package/dist/types/cloudflare/delivery-unit.d.ts +38 -7
- package/dist/types/cloudflare/native-renderer.d.ts +30 -0
- package/dist/types/cloudflare/renderer-identity.d.ts +25 -0
- package/dist/types/cloudflare/worker-manifest.d.ts +17 -2
- package/dist/types/cloudflare/worker-options.d.ts +20 -0
- package/dist/types/cloudflare/wrangler-config.d.ts +55 -2
- package/dist/types/cloudflare-builder.d.ts +51 -8
- package/dist/types/cloudflare-output-contract.d.ts +5 -3
- package/dist/types/cloudflare-output-verifier/identity.d.ts +7 -3
- package/dist/types/cloudflare-output-verifier/worker-bundles.d.ts +2 -2
- package/dist/types/config.d.ts +98 -13
- package/dist/types/deploy-output/plugin.d.ts +29 -9
- package/dist/types/deploy-output/public-assets.d.ts +51 -0
- package/dist/types/deploy-output/target.d.ts +28 -5
- package/dist/types/deploy-output/trace-files.d.ts +17 -0
- package/dist/types/module-federation-config/exposes.d.ts +11 -0
- package/dist/types/module-federation-config/index.d.ts +5 -0
- package/dist/types/module-federation-config/inspect.d.ts +2 -0
- package/dist/types/module-federation-config/object-literal.d.ts +4 -0
- package/dist/types/module-federation-config/syntax.d.ts +7 -0
- package/dist/types/module-federation-config/types.d.ts +20 -0
- package/dist/types/native-type-checker.d.ts +26 -3
- package/dist/types/policy-defaults.d.ts +12 -2
- package/dist/types/release-envelope/canonical.d.ts +5 -5
- package/dist/types/release-envelope/contract.d.mts +8 -0
- package/dist/types/release-envelope/framework-output.d.ts +23 -13
- package/dist/types/release-envelope/index.d.ts +17 -5
- package/dist/types/release-envelope/plugin.d.ts +10 -6
- package/dist/types/release-envelope/renderer-output-stamp.d.ts +34 -0
- package/dist/types/release-envelope/types.d.ts +42 -4
- package/dist/types/release-identity.d.ts +3 -2
- package/dist/types/renderer-build-identity.d.ts +30 -0
- package/dist/types/templates/cloudflare-worker-route-data.d.mts +14 -0
- package/dist/types/workspace-topology.d.ts +91 -0
- package/package.json +87 -27
- package/src/backend-federation-build/codegen.ts +28 -19
- package/src/backend-federation-build/config.ts +189 -123
- package/src/backend-federation-build/emit.ts +119 -38
- package/src/backend-federation-build/index.ts +4 -1
- package/src/build-config/build-environment.ts +59 -285
- package/src/build-config/internal-effect-discovery.ts +239 -0
- package/src/build-config/public.ts +0 -1
- package/src/build-config/remote-address.ts +33 -0
- package/src/cloudflare/artifacts.ts +22 -43
- package/src/cloudflare/delivery-unit.ts +283 -60
- package/src/cloudflare/index.ts +35 -19
- package/src/cloudflare/native-renderer.ts +117 -0
- package/src/cloudflare/renderer-identity.ts +171 -0
- package/src/cloudflare/worker-manifest.ts +108 -10
- package/src/cloudflare/worker-options.ts +60 -0
- package/src/cloudflare/wrangler-config.ts +390 -14
- package/src/cloudflare-builder.ts +543 -170
- package/src/cloudflare-output-contract.ts +45 -2
- package/src/cloudflare-output-verifier/identity.ts +138 -7
- package/src/cloudflare-output-verifier/index.ts +20 -0
- package/src/cloudflare-output-verifier/manifest.ts +77 -0
- package/src/cloudflare-output-verifier/mutation-policy.ts +11 -1
- package/src/cloudflare-output-verifier/worker-bundles.ts +27 -11
- package/src/config.ts +101 -19
- package/src/deploy-output/npmAliases.ts +141 -4
- package/src/deploy-output/plugin.ts +55 -18
- package/src/deploy-output/public-assets.ts +224 -0
- package/src/deploy-output/target.ts +97 -14
- package/src/deploy-output/trace-files.ts +80 -0
- package/src/module-federation-config/exposes.ts +46 -0
- package/src/module-federation-config/index.ts +22 -0
- package/src/module-federation-config/inspect.ts +157 -0
- package/src/module-federation-config/object-literal.ts +76 -0
- package/src/module-federation-config/syntax.ts +212 -0
- package/src/module-federation-config/types.ts +22 -0
- package/src/native-type-checker.ts +233 -20
- package/src/policy-defaults.ts +47 -17
- package/src/release-envelope/canonical.ts +6 -18
- package/src/release-envelope/contract.mjs +28 -0
- package/src/release-envelope/framework-output.ts +681 -156
- package/src/release-envelope/index.ts +315 -60
- package/src/release-envelope/plugin.ts +54 -38
- package/src/release-envelope/renderer-output-stamp.ts +210 -0
- package/src/release-envelope/types.ts +75 -6
- package/src/release-identity.ts +19 -2
- package/src/renderer-build-identity.ts +168 -0
- package/src/templates/cloudflare-entry.001-bootstrap-security.mjs +14 -6
- package/src/templates/cloudflare-entry.002-assets-routes.mjs +10 -2
- package/src/templates/cloudflare-entry.004-rendering-css.mjs +403 -96
- package/src/templates/cloudflare-entry.005-worker-dispatch.mjs +530 -103
- package/src/templates/cloudflare-entry.006-fetch-handler.mjs +26 -7
- package/src/templates/cloudflare-worker-route-data.mjs +1069 -0
- package/src/workspace-topology.ts +125 -0
- package/dist/cjs/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/cjs/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/cjs/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/cjs/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/esm/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/esm-node/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/dist/esm-node/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/dist/esm-node/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/dist/esm-node/templates/cloudflare-worker-path.mjs +0 -98
- package/dist/types/templates/cloudflare-worker-fs-promises.d.mts +0 -5
- package/dist/types/templates/cloudflare-worker-loadable-server.d.mts +0 -48
- package/dist/types/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +0 -13
- package/dist/types/templates/cloudflare-worker-path.d.mts +0 -21
- package/src/templates/cloudflare-worker-fs-promises.mjs +0 -11
- package/src/templates/cloudflare-worker-loadable-server.mjs +0 -281
- package/src/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +0 -14
- package/src/templates/cloudflare-worker-path.mjs +0 -98
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import node_os from "node:os";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
const SYSTEM_ROOTS = 'win32' === process.platform ? [] : [
|
|
4
|
+
'/dev',
|
|
5
|
+
'/etc',
|
|
6
|
+
'/proc',
|
|
7
|
+
'/run',
|
|
8
|
+
'/sys',
|
|
9
|
+
'/var/run'
|
|
10
|
+
];
|
|
11
|
+
const GLOB_SEGMENT = /[*?[{]/;
|
|
12
|
+
const isInside = (parent, child)=>child === parent || child.startsWith(`${parent}${node_path.sep}`);
|
|
13
|
+
const globRoot = (absolutePattern)=>{
|
|
14
|
+
const { root } = node_path.parse(absolutePattern);
|
|
15
|
+
const segments = absolutePattern.slice(root.length).split(node_path.sep);
|
|
16
|
+
const index = segments.findIndex((segment)=>GLOB_SEGMENT.test(segment));
|
|
17
|
+
return -1 === index ? void 0 : node_path.join(root, ...segments.slice(0, index));
|
|
18
|
+
};
|
|
19
|
+
const createBuildHostIgnore = (base)=>{
|
|
20
|
+
const wholeDirectories = new Set([
|
|
21
|
+
node_path.parse(node_path.resolve(base)).root,
|
|
22
|
+
node_path.resolve(node_os.homedir()),
|
|
23
|
+
node_path.resolve(node_os.tmpdir())
|
|
24
|
+
]);
|
|
25
|
+
return (relativePath)=>{
|
|
26
|
+
const absolutePath = node_path.resolve(base, relativePath);
|
|
27
|
+
if (SYSTEM_ROOTS.some((root)=>isInside(root, absolutePath))) return true;
|
|
28
|
+
const root = globRoot(absolutePath);
|
|
29
|
+
return void 0 !== root && wholeDirectories.has(root);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const traceDeployFiles = ({ entryFiles, sourceDir, base = '/' })=>{
|
|
33
|
+
const resolvedBase = node_path.resolve(base);
|
|
34
|
+
const ignore = createBuildHostIgnore(resolvedBase);
|
|
35
|
+
try {
|
|
36
|
+
const options = {
|
|
37
|
+
base: resolvedBase,
|
|
38
|
+
processCwd: node_path.resolve(sourceDir || resolvedBase),
|
|
39
|
+
ignore
|
|
40
|
+
};
|
|
41
|
+
const entries = entryFiles.map((file)=>node_path.resolve(file));
|
|
42
|
+
return import("@vercel/nft").then(({ nodeFileTrace })=>nodeFileTrace(entries, options));
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return Promise.reject(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export { createBuildHostIgnore, traceDeployFiles };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import node_path from "node:path";
|
|
3
|
+
import { inspectModuleFederationConfigSource } from "./inspect.mjs";
|
|
4
|
+
const moduleFederationConfigFile = 'module-federation.config.ts';
|
|
5
|
+
function readModuleFederationConfigInspection(workspaceRoot, appDirectory) {
|
|
6
|
+
const configPath = node_path.join(workspaceRoot, appDirectory, moduleFederationConfigFile);
|
|
7
|
+
if (!node_fs.existsSync(configPath)) return;
|
|
8
|
+
try {
|
|
9
|
+
const source = node_fs.readFileSync(configPath, 'utf-8');
|
|
10
|
+
return inspectModuleFederationConfigSource(source, appDirectory, node_path.join(appDirectory, moduleFederationConfigFile));
|
|
11
|
+
} catch {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function readModuleFederationExposePaths(workspaceRoot, appDirectory) {
|
|
16
|
+
return readModuleFederationConfigInspection(workspaceRoot, appDirectory)?.exposePaths;
|
|
17
|
+
}
|
|
18
|
+
export { readModuleFederationConfigInspection, readModuleFederationExposePaths };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { readModuleFederationConfigInspection, readModuleFederationExposePaths } from "./exposes.mjs";
|
|
2
|
+
export { inspectModuleFederationConfigSource } from "./inspect.mjs";
|
|
3
|
+
export { parseArrayLiteral, parseLiteralString, parseObjectLiteral } from "./object-literal.mjs";
|
|
4
|
+
export { findCreateModuleFederationConfigObject, findExportDefaultObject, locateCreateModuleFederationConfigObject, parseConfigModule, parseStaticExpression } from "./syntax.mjs";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { parseArrayLiteral, parseLiteralString, parseObjectLiteral } from "./object-literal.mjs";
|
|
2
|
+
import { findCreateModuleFederationConfigObject, findExportDefaultObject, parseConfigModule } from "./syntax.mjs";
|
|
3
|
+
function extractExposes(configPath, value) {
|
|
4
|
+
if (void 0 === value) return {
|
|
5
|
+
exposePaths: {},
|
|
6
|
+
exposes: []
|
|
7
|
+
};
|
|
8
|
+
const object = parseObjectLiteral(value);
|
|
9
|
+
if (object) {
|
|
10
|
+
if (object.hasSpread) throw new Error(`Cannot statically extract Module Federation exposes from ${configPath}; use a literal exposes object without spreads.`);
|
|
11
|
+
const exposePaths = {};
|
|
12
|
+
for (const [expose, source] of object.properties){
|
|
13
|
+
const exposePath = parseLiteralString(source);
|
|
14
|
+
if (void 0 !== exposePath) exposePaths[expose] = exposePath;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
exposePaths,
|
|
18
|
+
exposes: Array.from(object.properties.keys()).sort()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const array = parseArrayLiteral(value);
|
|
22
|
+
if (array) return {
|
|
23
|
+
exposePaths: {},
|
|
24
|
+
exposes: array.sort()
|
|
25
|
+
};
|
|
26
|
+
throw new Error(`Cannot statically extract Module Federation exposes from ${configPath}; use a literal exposes object or string array.`);
|
|
27
|
+
}
|
|
28
|
+
function extractDtsSettings(configPath, value, exposes) {
|
|
29
|
+
if ('false' === value) {
|
|
30
|
+
if (exposes.length > 0) throw new Error(`Module Federation DTS cannot be disabled for exposed app ${configPath}.`);
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
if (void 0 === value) return {};
|
|
34
|
+
const dts = parseObjectLiteral(value);
|
|
35
|
+
if (!dts || dts.hasSpread) throw new Error(`Cannot statically extract Module Federation DTS settings from ${configPath}; use a literal dts object.`);
|
|
36
|
+
const generateTypes = parseObjectLiteral(dts.properties.get('generateTypes'));
|
|
37
|
+
if (generateTypes?.hasSpread) throw new Error(`Cannot statically extract Module Federation generateTypes settings from ${configPath}; use a literal generateTypes object.`);
|
|
38
|
+
const compilerInstanceSource = generateTypes?.properties.get('compilerInstance');
|
|
39
|
+
return {
|
|
40
|
+
compilerInstance: parseLiteralString(compilerInstanceSource) ?? ('tsgoCompilerInstance' === compilerInstanceSource ? 'effect-tsgo' : void 0),
|
|
41
|
+
tsConfigPath: parseLiteralString(dts.properties.get('tsConfigPath'))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function hasHostOnlyNoExposesDeclaration(source) {
|
|
45
|
+
return (parseConfigModule(source).comments ?? []).some((comment)=>/@?ultramodern-mf\s*:?\s*(?:host-only|no-exposes)\b/iu.test(comment.value));
|
|
46
|
+
}
|
|
47
|
+
function inspectModuleFederationConfigSource(source, appDir, configPath) {
|
|
48
|
+
const configObject = findCreateModuleFederationConfigObject(source) ?? findExportDefaultObject(source);
|
|
49
|
+
if (!configObject) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; export or pass a literal config object.`);
|
|
50
|
+
const properties = parseObjectLiteral(configObject);
|
|
51
|
+
if (!properties) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; expected a literal config object.`);
|
|
52
|
+
if (properties.hasSpread) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; top-level config spreads are not supported.`);
|
|
53
|
+
const { exposePaths, exposes } = extractExposes(configPath, properties.properties.get('exposes'));
|
|
54
|
+
const hostOnlyNoExposes = hasHostOnlyNoExposesDeclaration(source);
|
|
55
|
+
if (hostOnlyNoExposes && exposes.length > 0) throw new Error(`Module Federation host-only/no-exposes declaration conflicts with actual exposes in ${configPath}.`);
|
|
56
|
+
return {
|
|
57
|
+
appDir,
|
|
58
|
+
configPath,
|
|
59
|
+
dts: extractDtsSettings(configPath, properties.properties.get('dts'), exposes),
|
|
60
|
+
exposePaths,
|
|
61
|
+
exposes,
|
|
62
|
+
hostOnlyNoExposes
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export { inspectModuleFederationConfigSource };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { parseStaticExpression } from "./syntax.mjs";
|
|
2
|
+
function parseLiteralString(source) {
|
|
3
|
+
const node = parseStaticExpression(source);
|
|
4
|
+
if (node?.type === 'StringLiteral') return node.value;
|
|
5
|
+
if (node?.type === 'TemplateLiteral' && 0 === node.expressions.length) return node.quasis[0]?.value.cooked ?? void 0;
|
|
6
|
+
}
|
|
7
|
+
function parseObjectLiteral(source) {
|
|
8
|
+
const node = parseStaticExpression(source);
|
|
9
|
+
if (void 0 === source || node?.type !== 'ObjectExpression') return;
|
|
10
|
+
const properties = new Map();
|
|
11
|
+
let hasSpread = false;
|
|
12
|
+
for (const property of node.properties){
|
|
13
|
+
if ('ObjectProperty' !== property.type || property.computed || property.shorthand) {
|
|
14
|
+
hasSpread = true;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const key = 'Identifier' === property.key.type ? property.key.name : 'StringLiteral' === property.key.type ? property.key.value : void 0;
|
|
18
|
+
const value = parseStaticExpression(source.slice(property.value.start ?? 0, property.value.end ?? 0));
|
|
19
|
+
if (void 0 === key || properties.has(key) || !value || null == value.start || null == value.end) {
|
|
20
|
+
hasSpread = true;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const rawValue = source.slice(property.value.start ?? 0, property.value.end ?? 0);
|
|
24
|
+
properties.set(key, rawValue.slice(value.start, value.end));
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
hasSpread,
|
|
28
|
+
properties
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function parseArrayLiteral(source) {
|
|
32
|
+
const node = parseStaticExpression(source);
|
|
33
|
+
if (void 0 === source || node?.type !== 'ArrayExpression') return;
|
|
34
|
+
const values = [];
|
|
35
|
+
for (const element of node.elements){
|
|
36
|
+
if (!element || 'SpreadElement' === element.type) return;
|
|
37
|
+
const value = parseLiteralString(source.slice(element.start ?? 0, element.end ?? 0));
|
|
38
|
+
if (void 0 === value) return;
|
|
39
|
+
values.push(value);
|
|
40
|
+
}
|
|
41
|
+
return values;
|
|
42
|
+
}
|
|
43
|
+
export { parseArrayLiteral, parseLiteralString, parseObjectLiteral };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { parse, parseExpression } from "@babel/parser";
|
|
2
|
+
function unwrapExpression(node) {
|
|
3
|
+
while('TSAsExpression' === node.type || 'TSSatisfiesExpression' === node.type || 'TSNonNullExpression' === node.type || 'TSTypeAssertion' === node.type || 'ParenthesizedExpression' === node.type)node = node.expression;
|
|
4
|
+
return node;
|
|
5
|
+
}
|
|
6
|
+
function parseStaticExpression(source) {
|
|
7
|
+
if (void 0 === source) return;
|
|
8
|
+
try {
|
|
9
|
+
return unwrapExpression(parseExpression(source, {
|
|
10
|
+
plugins: [
|
|
11
|
+
"typescript"
|
|
12
|
+
]
|
|
13
|
+
}));
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function parseConfigModule(source) {
|
|
19
|
+
return parse(source, {
|
|
20
|
+
sourceType: 'module',
|
|
21
|
+
plugins: [
|
|
22
|
+
"typescript"
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function locateExportedConfig(source, factory) {
|
|
27
|
+
const module = parseConfigModule(source);
|
|
28
|
+
const constants = new Map();
|
|
29
|
+
const bindingStarts = new Map();
|
|
30
|
+
const resolvedBindings = new Set();
|
|
31
|
+
const allowedReferences = new Set();
|
|
32
|
+
const factories = new Set();
|
|
33
|
+
const namespaces = new Set();
|
|
34
|
+
const defaults = [];
|
|
35
|
+
for (const statement of module.program.body){
|
|
36
|
+
if ('ImportDeclaration' === statement.type && 'type' !== statement.importKind && '@module-federation/modern-js-v3' === statement.source.value) {
|
|
37
|
+
for (const specifier of statement.specifiers)if ('ImportNamespaceSpecifier' === specifier.type) namespaces.add(specifier.local.name);
|
|
38
|
+
else if ('ImportSpecifier' === specifier.type && 'type' !== specifier.importKind && ('Identifier' === specifier.imported.type ? specifier.imported.name : specifier.imported.value) === 'createModuleFederationConfig') factories.add(specifier.local.name);
|
|
39
|
+
}
|
|
40
|
+
const declaration = 'ExportNamedDeclaration' === statement.type ? statement.declaration : statement;
|
|
41
|
+
if (declaration?.type === 'VariableDeclaration' && 'const' === declaration.kind) {
|
|
42
|
+
for (const binding of declaration.declarations)if ('Identifier' === binding.id.type && binding.init) {
|
|
43
|
+
constants.set(binding.id.name, binding.init);
|
|
44
|
+
bindingStarts.set(binding.id.name, binding.id.start);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if ('ExportDefaultDeclaration' === statement.type) defaults.push(statement.declaration);
|
|
48
|
+
else if ('ExportNamedDeclaration' === statement.type && !statement.source && 'type' !== statement.exportKind) {
|
|
49
|
+
for (const specifier of statement.specifiers)if ('ExportSpecifier' === specifier.type && 'type' !== specifier.exportKind && ('Identifier' === specifier.exported.type ? specifier.exported.name : specifier.exported.value) === 'default') defaults.push(specifier.local);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const resolve = (node, seen = new Set())=>{
|
|
53
|
+
if (!node) return;
|
|
54
|
+
if ('Identifier' === node.type) {
|
|
55
|
+
if (seen.has(node.name)) return;
|
|
56
|
+
seen.add(node.name);
|
|
57
|
+
resolvedBindings.add(node.name);
|
|
58
|
+
if (null != node.start) allowedReferences.add(node.start);
|
|
59
|
+
const bindingStart = bindingStarts.get(node.name);
|
|
60
|
+
if (null != bindingStart) allowedReferences.add(bindingStart);
|
|
61
|
+
return resolve(constants.get(node.name), seen);
|
|
62
|
+
}
|
|
63
|
+
if ('TSAsExpression' === node.type || 'TSSatisfiesExpression' === node.type || 'TSNonNullExpression' === node.type || 'TSTypeAssertion' === node.type || 'ParenthesizedExpression' === node.type) return resolve(node.expression, seen);
|
|
64
|
+
return node;
|
|
65
|
+
};
|
|
66
|
+
if (1 !== defaults.length) return;
|
|
67
|
+
let node = resolve(defaults[0]);
|
|
68
|
+
if (factory) {
|
|
69
|
+
if (node?.type !== 'CallExpression' || 1 !== node.arguments.length) return;
|
|
70
|
+
const callee = node.callee;
|
|
71
|
+
const supported = 'Identifier' === callee.type && factories.has(callee.name) || 'MemberExpression' === callee.type && !callee.computed && 'Identifier' === callee.object.type && namespaces.has(callee.object.name) && 'Identifier' === callee.property.type && 'createModuleFederationConfig' === callee.property.name;
|
|
72
|
+
if (!supported) return;
|
|
73
|
+
const argument = node.arguments[0];
|
|
74
|
+
if (!argument || 'SpreadElement' === argument.type || 'ArgumentPlaceholder' === argument.type) return;
|
|
75
|
+
node = resolve(argument);
|
|
76
|
+
}
|
|
77
|
+
if (node?.type !== 'ObjectExpression' || null == node.start || null == node.end) return;
|
|
78
|
+
const hasOtherReference = (value)=>{
|
|
79
|
+
if (!value || 'object' != typeof value) return false;
|
|
80
|
+
if (Array.isArray(value)) return value.some(hasOtherReference);
|
|
81
|
+
const entry = value;
|
|
82
|
+
if ('Identifier' === entry.type && 'string' == typeof entry.name && resolvedBindings.has(entry.name) && ('number' != typeof entry.start || !allowedReferences.has(entry.start))) return true;
|
|
83
|
+
return Object.entries(entry).some(([key, child])=>'loc' !== key && 'comments' !== key && 'leadingComments' !== key && 'trailingComments' !== key && hasOtherReference(child));
|
|
84
|
+
};
|
|
85
|
+
if (hasOtherReference(module.program)) return;
|
|
86
|
+
return {
|
|
87
|
+
start: node.start,
|
|
88
|
+
end: node.end,
|
|
89
|
+
source: source.slice(node.start, node.end)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function locateCreateModuleFederationConfigObject(source) {
|
|
93
|
+
return locateExportedConfig(source, true);
|
|
94
|
+
}
|
|
95
|
+
function findCreateModuleFederationConfigObject(source) {
|
|
96
|
+
return locateCreateModuleFederationConfigObject(source)?.source;
|
|
97
|
+
}
|
|
98
|
+
function findExportDefaultObject(source) {
|
|
99
|
+
return locateExportedConfig(source, false)?.source;
|
|
100
|
+
}
|
|
101
|
+
export { findCreateModuleFederationConfigObject, findExportDefaultObject, locateCreateModuleFederationConfigObject, parseConfigModule, parseStaticExpression };
|
|
File without changes
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { existsSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
4
|
import node_path from "node:path";
|
|
4
5
|
import { promisify } from "node:util";
|
|
5
6
|
import { refreshTsgoCheckerConfig } from "@modern-js/builder";
|
|
7
|
+
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
6
8
|
const execute = promisify(execFile);
|
|
7
9
|
const native_type_checker_name = 'UltramodernNativeTypeChecker';
|
|
10
|
+
function resolveNativeTypeCheckerCommand(packageJsonPath) {
|
|
11
|
+
const manifestFile = realpathSync(packageJsonPath);
|
|
12
|
+
const directory = node_path.dirname(manifestFile);
|
|
13
|
+
const manifest = JSON.parse(readFileSync(manifestFile, 'utf8'));
|
|
14
|
+
if ("typescript" !== manifest.name || '7.0.2' !== manifest.version) throw new Error(`${native_type_checker_name} requires typescript@7.0.2; found ${String(manifest.name)}@${String(manifest.version)} at ${manifestFile}.`);
|
|
15
|
+
const bin = manifest.bin?.tsc;
|
|
16
|
+
if ('string' != typeof bin || !bin || node_path.isAbsolute(bin)) throw new Error(`${native_type_checker_name} requires the selected package's public tsc bin.`);
|
|
17
|
+
const launcher = realpathSync(node_path.resolve(directory, bin));
|
|
18
|
+
const relative = node_path.relative(directory, launcher);
|
|
19
|
+
if (!relative || node_path.isAbsolute(relative) || '..' === relative || relative.startsWith(`..${node_path.sep}`) || !statSync(launcher).isFile()) throw new Error(`${native_type_checker_name} public tsc bin must belong to its selected package.`);
|
|
20
|
+
return {
|
|
21
|
+
executable: process.execPath,
|
|
22
|
+
args: [
|
|
23
|
+
launcher
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
8
27
|
const watchDependencyPath = (file)=>{
|
|
9
28
|
if ('win32' !== process.platform) return file;
|
|
10
29
|
try {
|
|
@@ -13,9 +32,87 @@ const watchDependencyPath = (file)=>{
|
|
|
13
32
|
return file;
|
|
14
33
|
}
|
|
15
34
|
};
|
|
35
|
+
function missingJsxRuntimeHint(diagnostics) {
|
|
36
|
+
const source = /error TS2875: This JSX tag requires the module path '(.+?)\/jsx-(?:dev-)?runtime'/u.exec(diagnostics)?.[1];
|
|
37
|
+
if (!source) return '';
|
|
38
|
+
return `\nHint: JSX compiles against jsxImportSource '${source}', the selected renderer's runtime, but '${source}/jsx-runtime' cannot be resolved from this app. If you changed \`renderer\` in modern.config, install that renderer's packages and port components authored for the previous renderer, or switch \`renderer\` back.\n`;
|
|
39
|
+
}
|
|
16
40
|
class UltramodernNativeTypeChecker {
|
|
17
41
|
async check() {
|
|
18
|
-
const
|
|
42
|
+
const configFile = await this.projectConfigFile();
|
|
43
|
+
try {
|
|
44
|
+
await this.checkProject(configFile);
|
|
45
|
+
} finally{
|
|
46
|
+
this.removeProjection(configFile);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async projectConfigFile() {
|
|
50
|
+
const { configFile, configOverwrite } = this.options;
|
|
51
|
+
if (!configOverwrite) return configFile;
|
|
52
|
+
const errors = [];
|
|
53
|
+
const source = readFileSync(configFile, 'utf8');
|
|
54
|
+
const project = parse(0xfeff === source.charCodeAt(0) ? source.slice(1) : source, errors, {
|
|
55
|
+
allowTrailingComma: true
|
|
56
|
+
});
|
|
57
|
+
if (errors.length) throw new Error(`${native_type_checker_name} requires valid JSONC in ${configFile}: ${errors.map((error)=>`${printParseErrorCode(error.error)} at ${error.offset}`).join(', ')}`);
|
|
58
|
+
if (!project || 'object' != typeof project || Array.isArray(project)) throw new Error(`${native_type_checker_name} requires a JSONC object in ${configFile}.`);
|
|
59
|
+
const projectedConfig = {
|
|
60
|
+
...project,
|
|
61
|
+
...configOverwrite,
|
|
62
|
+
compilerOptions: {
|
|
63
|
+
...project.compilerOptions,
|
|
64
|
+
...configOverwrite.compilerOptions
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const projected = node_path.join(node_path.dirname(configFile), `.ultramodern-native-checker.${randomUUID()}.json`);
|
|
68
|
+
writeFileSync(projected, `${JSON.stringify(projectedConfig, null, 2)}\n`, {
|
|
69
|
+
flag: 'wx'
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const resolved = JSON.parse(await this.run([
|
|
73
|
+
'--showConfig',
|
|
74
|
+
'--project',
|
|
75
|
+
projected
|
|
76
|
+
]));
|
|
77
|
+
const options = resolved.compilerOptions ?? {};
|
|
78
|
+
if ((this.options.build || true === options.incremental || true === options.composite) && !options.tsBuildInfoFile) {
|
|
79
|
+
const original = configFile.slice(0, configFile.length - node_path.extname(configFile).length);
|
|
80
|
+
let buildInfo = original;
|
|
81
|
+
if ('string' == typeof options.outDir) {
|
|
82
|
+
const outDir = node_path.resolve(node_path.dirname(configFile), options.outDir);
|
|
83
|
+
buildInfo = 'string' == typeof options.rootDir ? node_path.resolve(outDir, node_path.relative(node_path.resolve(node_path.dirname(configFile), options.rootDir), original)) : node_path.join(outDir, node_path.basename(original));
|
|
84
|
+
}
|
|
85
|
+
projectedConfig.compilerOptions = {
|
|
86
|
+
...projectedConfig.compilerOptions,
|
|
87
|
+
tsBuildInfoFile: `${buildInfo}.tsbuildinfo`
|
|
88
|
+
};
|
|
89
|
+
writeFileSync(projected, `${JSON.stringify(projectedConfig, null, 2)}\n`);
|
|
90
|
+
}
|
|
91
|
+
return projected;
|
|
92
|
+
} catch (error) {
|
|
93
|
+
unlinkSync(projected);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
removeProjection(configFile) {
|
|
98
|
+
if (configFile !== this.options.configFile) unlinkSync(configFile);
|
|
99
|
+
}
|
|
100
|
+
async checkProject(configFile) {
|
|
101
|
+
const { build } = this.options;
|
|
102
|
+
if (!build) {
|
|
103
|
+
const config = JSON.parse(await this.run([
|
|
104
|
+
'--showConfig',
|
|
105
|
+
'--project',
|
|
106
|
+
configFile
|
|
107
|
+
]));
|
|
108
|
+
if (config.references?.length) await this.run([
|
|
109
|
+
'--build',
|
|
110
|
+
...config.references.map((reference)=>node_path.resolve(node_path.dirname(configFile), reference.path)),
|
|
111
|
+
'--stopBuildOnErrors',
|
|
112
|
+
'--pretty',
|
|
113
|
+
'false'
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
19
116
|
const args = build ? [
|
|
20
117
|
'--build',
|
|
21
118
|
configFile,
|
|
@@ -33,7 +130,15 @@ class UltramodernNativeTypeChecker {
|
|
|
33
130
|
}
|
|
34
131
|
async run(args) {
|
|
35
132
|
try {
|
|
36
|
-
const
|
|
133
|
+
const selected = this.options.compiler();
|
|
134
|
+
const command = 'string' == typeof selected ? {
|
|
135
|
+
executable: selected,
|
|
136
|
+
args: []
|
|
137
|
+
} : selected;
|
|
138
|
+
const result = await execute(command.executable, [
|
|
139
|
+
...command.args,
|
|
140
|
+
...args
|
|
141
|
+
], {
|
|
37
142
|
cwd: node_path.dirname(this.options.configFile),
|
|
38
143
|
maxBuffer: 16777216
|
|
39
144
|
});
|
|
@@ -41,22 +146,22 @@ class UltramodernNativeTypeChecker {
|
|
|
41
146
|
} catch (cause) {
|
|
42
147
|
const output = cause;
|
|
43
148
|
const diagnostics = `${output.stdout ?? ''}${output.stderr ?? ''}`;
|
|
44
|
-
throw new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}`, {
|
|
149
|
+
throw new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}${missingJsxRuntimeHint(diagnostics)}`, {
|
|
45
150
|
cause
|
|
46
151
|
});
|
|
47
152
|
}
|
|
48
153
|
}
|
|
49
|
-
async watchInputs() {
|
|
154
|
+
async watchInputs(configFile) {
|
|
50
155
|
const inputs = new Set();
|
|
51
156
|
const missing = new Set();
|
|
52
157
|
const projects = [
|
|
53
|
-
|
|
158
|
+
configFile
|
|
54
159
|
];
|
|
55
160
|
const visited = new Set();
|
|
56
161
|
for (const configFile of projects){
|
|
57
162
|
if (visited.has(configFile)) continue;
|
|
58
163
|
visited.add(configFile);
|
|
59
|
-
inputs.add(configFile);
|
|
164
|
+
if (configFile === this.options.configFile || configFile !== projects[0]) inputs.add(configFile);
|
|
60
165
|
if (!existsSync(configFile)) {
|
|
61
166
|
missing.add(configFile);
|
|
62
167
|
continue;
|
|
@@ -94,10 +199,15 @@ class UltramodernNativeTypeChecker {
|
|
|
94
199
|
compilation.fileDependencies.add(watched);
|
|
95
200
|
if (!existsSync(projectConfigFile)) compilation.missingDependencies.add(watched);
|
|
96
201
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
202
|
+
const configFile = await this.projectConfigFile();
|
|
203
|
+
try {
|
|
204
|
+
const { inputs, missing } = await this.watchInputs(configFile);
|
|
205
|
+
for (const file of inputs)compilation.fileDependencies.add(watchDependencyPath(file));
|
|
206
|
+
for (const file of missing)compilation.missingDependencies.add(watchDependencyPath(file));
|
|
207
|
+
await this.checkProject(configFile);
|
|
208
|
+
} finally{
|
|
209
|
+
this.removeProjection(configFile);
|
|
210
|
+
}
|
|
101
211
|
} catch (cause) {
|
|
102
212
|
compilation.errors.push(new Error(cause instanceof Error ? cause.message : String(cause), {
|
|
103
213
|
cause
|
|
@@ -121,8 +231,9 @@ function configureUltramodernTypeChecker(chain, pluginId, resolveCompiler) {
|
|
|
121
231
|
{
|
|
122
232
|
build: true === typescript.build,
|
|
123
233
|
compiler: ()=>resolveCompiler(configFile),
|
|
124
|
-
configFile
|
|
234
|
+
configFile,
|
|
235
|
+
configOverwrite: typescript.configOverwrite
|
|
125
236
|
}
|
|
126
237
|
]);
|
|
127
238
|
}
|
|
128
|
-
export { UltramodernNativeTypeChecker, configureUltramodernTypeChecker };
|
|
239
|
+
export { UltramodernNativeTypeChecker, configureUltramodernTypeChecker, missingJsxRuntimeHint, resolveNativeTypeCheckerCommand };
|
|
@@ -2,44 +2,50 @@ import { collectRuntimePackageModuleDirectories, createRuntimePackageResolutionP
|
|
|
2
2
|
const RENDERER_EXTENSIONS_PACKAGE = '@modern-js/runtime-renderer-extensions';
|
|
3
3
|
const RENDERER_EXTENSIONS_PLUGIN_NAME = 'rendererHead';
|
|
4
4
|
const SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/app-tools/server-plugin';
|
|
5
|
+
const ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/ultramodern-app-tools/server-plugin';
|
|
5
6
|
const POLICY_DEFAULTS_PLUGIN_NAME = '@modern-js/ultramodern-policy-defaults';
|
|
6
|
-
const applyPolicyDefaults = (api, options = {})=>{
|
|
7
|
-
if (false !== options.rendererExtensions) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const applyPolicyDefaults = (api, options = {}, composition = {})=>{
|
|
8
|
+
if (false !== options.rendererExtensions) 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 runtimePackages = [
|
|
20
|
+
...false !== options.rendererExtensions ? [
|
|
21
|
+
RENDERER_EXTENSIONS_PACKAGE
|
|
22
|
+
] : [],
|
|
23
|
+
...(composition.runtimePackages ?? []).filter((packageName)=>packageName !== RENDERER_EXTENSIONS_PACKAGE)
|
|
24
|
+
];
|
|
25
|
+
const moduleDirectories = collectRuntimePackageModuleDirectories(runtimePackages, composition.registrarUrl ?? import.meta.url);
|
|
26
|
+
if (moduleDirectories.length > 0) api.modifyResolvedConfig((config)=>({
|
|
27
|
+
...config,
|
|
28
|
+
builderPlugins: [
|
|
29
|
+
...config.builderPlugins ?? [],
|
|
30
|
+
createRuntimePackageResolutionPlugin(moduleDirectories)
|
|
31
|
+
]
|
|
32
|
+
}));
|
|
33
|
+
if (false !== options.serverExtensions) {
|
|
34
|
+
const serverPluginName = composition.serverPluginName ?? SERVER_EXTENSIONS_PLUGIN_NAME;
|
|
35
|
+
api._internalServerPlugins(({ plugins })=>{
|
|
36
|
+
if (!plugins.some((plugin)=>plugin.name === serverPluginName || plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME || plugin.name === ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME)) plugins.push({
|
|
37
|
+
name: serverPluginName
|
|
13
38
|
});
|
|
14
39
|
return {
|
|
15
|
-
entrypoint,
|
|
16
40
|
plugins
|
|
17
41
|
};
|
|
18
42
|
});
|
|
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
43
|
}
|
|
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
44
|
};
|
|
39
|
-
const createPolicyDefaultsPlugin = (options = {})=>({
|
|
40
|
-
name: POLICY_DEFAULTS_PLUGIN_NAME,
|
|
45
|
+
const createPolicyDefaultsPlugin = (options = {}, composition = {})=>({
|
|
46
|
+
name: composition.pluginName ?? POLICY_DEFAULTS_PLUGIN_NAME,
|
|
41
47
|
setup (api) {
|
|
42
|
-
applyPolicyDefaults(api, options);
|
|
48
|
+
applyPolicyDefaults(api, options, composition);
|
|
43
49
|
}
|
|
44
50
|
});
|
|
45
|
-
export { POLICY_DEFAULTS_PLUGIN_NAME, RENDERER_EXTENSIONS_PACKAGE, RENDERER_EXTENSIONS_PLUGIN_NAME, SERVER_EXTENSIONS_PLUGIN_NAME, applyPolicyDefaults, createPolicyDefaultsPlugin };
|
|
51
|
+
export { POLICY_DEFAULTS_PLUGIN_NAME, RENDERER_EXTENSIONS_PACKAGE, RENDERER_EXTENSIONS_PLUGIN_NAME, SERVER_EXTENSIONS_PLUGIN_NAME, ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME, applyPolicyDefaults, createPolicyDefaultsPlugin };
|
|
@@ -7,15 +7,8 @@ const serializeCanonicalValue = (value)=>{
|
|
|
7
7
|
if (Array.isArray(value)) return `[${value.map(serializeCanonicalValue).join(',')}]`;
|
|
8
8
|
return `{${Object.keys(value).sort().map((key)=>`${JSON.stringify(key)}:${serializeCanonicalValue(value[key])}`).join(',')}}`;
|
|
9
9
|
};
|
|
10
|
-
const releaseEnvelopePayload = (envelope)=>({
|
|
11
|
-
schemaVersion: envelope.schemaVersion,
|
|
12
|
-
kind: envelope.kind,
|
|
13
|
-
target: envelope.target,
|
|
14
|
-
identity: envelope.identity,
|
|
15
|
-
artifacts: envelope.artifacts,
|
|
16
|
-
surfaces: envelope.surfaces
|
|
17
|
-
});
|
|
18
10
|
const canonicalSerializeMicroVerticalReleaseEnvelopePayload = (payload)=>serializeCanonicalValue(payload);
|
|
19
11
|
const canonicalSerializeMicroVerticalReleaseEnvelope = (envelope)=>serializeCanonicalValue(envelope);
|
|
20
12
|
const digestMicroVerticalReleaseEnvelopePayload = (payload)=>createHash('sha256').update(canonicalSerializeMicroVerticalReleaseEnvelopePayload(payload)).digest('hex');
|
|
21
|
-
export {
|
|
13
|
+
export { releaseEnvelopePayload } from "./contract.mjs";
|
|
14
|
+
export { canonicalSerializeMicroVerticalReleaseEnvelope, canonicalSerializeMicroVerticalReleaseEnvelopePayload, digestMicroVerticalReleaseEnvelopePayload };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION = 5;
|
|
2
|
+
const MICROVERTICAL_RELEASE_ENVELOPE_KIND = 'ultramodern-target-microvertical-release-envelope';
|
|
3
|
+
const SHELL_RELEASE_ENVELOPE_KIND = 'ultramodern-target-shell-release-envelope';
|
|
4
|
+
const releaseEnvelopePayload = (envelope)=>{
|
|
5
|
+
const payload = {
|
|
6
|
+
schemaVersion: envelope.schemaVersion,
|
|
7
|
+
target: envelope.target,
|
|
8
|
+
identity: envelope.identity,
|
|
9
|
+
...envelope.ui ? {
|
|
10
|
+
ui: envelope.ui
|
|
11
|
+
} : {},
|
|
12
|
+
artifacts: envelope.artifacts
|
|
13
|
+
};
|
|
14
|
+
envelope.kind;
|
|
15
|
+
return {
|
|
16
|
+
...payload,
|
|
17
|
+
kind: envelope.kind,
|
|
18
|
+
surfaces: envelope.surfaces
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, SHELL_RELEASE_ENVELOPE_KIND, releaseEnvelopePayload };
|