@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.9 → 3.9.3-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/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 +30 -165
- package/dist/cjs/build-config/internal-effect-discovery.js +231 -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 +180 -17
- 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 +9 -6
- package/dist/cjs/renderer-build-identity.js +144 -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 +547 -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 +31 -163
- package/dist/esm/build-config/internal-effect-discovery.mjs +187 -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 +175 -18
- 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 +9 -6
- package/dist/esm/renderer-build-identity.mjs +92 -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 +547 -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 +31 -163
- package/dist/esm-node/build-config/internal-effect-discovery.mjs +188 -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 +175 -18
- 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 +9 -6
- package/dist/esm-node/renderer-build-identity.mjs +93 -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 +547 -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 +4 -10
- package/dist/types/build-config/internal-effect-discovery.d.ts +6 -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 +20 -4
- 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 +102 -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 +28 -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 +13 -2
- package/dist/types/renderer-build-identity.d.ts +41 -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 +69 -293
- package/src/build-config/internal-effect-discovery.ts +458 -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 +115 -13
- 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 +105 -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 +284 -27
- 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 +30 -4
- package/src/renderer-build-identity.ts +208 -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 +547 -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,48 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_os from "node:os";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
const SYSTEM_ROOTS = 'win32' === process.platform ? [] : [
|
|
5
|
+
'/dev',
|
|
6
|
+
'/etc',
|
|
7
|
+
'/proc',
|
|
8
|
+
'/run',
|
|
9
|
+
'/sys',
|
|
10
|
+
'/var/run'
|
|
11
|
+
];
|
|
12
|
+
const GLOB_SEGMENT = /[*?[{]/;
|
|
13
|
+
const isInside = (parent, child)=>child === parent || child.startsWith(`${parent}${node_path.sep}`);
|
|
14
|
+
const globRoot = (absolutePattern)=>{
|
|
15
|
+
const { root } = node_path.parse(absolutePattern);
|
|
16
|
+
const segments = absolutePattern.slice(root.length).split(node_path.sep);
|
|
17
|
+
const index = segments.findIndex((segment)=>GLOB_SEGMENT.test(segment));
|
|
18
|
+
return -1 === index ? void 0 : node_path.join(root, ...segments.slice(0, index));
|
|
19
|
+
};
|
|
20
|
+
const createBuildHostIgnore = (base)=>{
|
|
21
|
+
const wholeDirectories = new Set([
|
|
22
|
+
node_path.parse(node_path.resolve(base)).root,
|
|
23
|
+
node_path.resolve(node_os.homedir()),
|
|
24
|
+
node_path.resolve(node_os.tmpdir())
|
|
25
|
+
]);
|
|
26
|
+
return (relativePath)=>{
|
|
27
|
+
const absolutePath = node_path.resolve(base, relativePath);
|
|
28
|
+
if (SYSTEM_ROOTS.some((root)=>isInside(root, absolutePath))) return true;
|
|
29
|
+
const root = globRoot(absolutePath);
|
|
30
|
+
return void 0 !== root && wholeDirectories.has(root);
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const traceDeployFiles = ({ entryFiles, sourceDir, base = '/' })=>{
|
|
34
|
+
const resolvedBase = node_path.resolve(base);
|
|
35
|
+
const ignore = createBuildHostIgnore(resolvedBase);
|
|
36
|
+
try {
|
|
37
|
+
const options = {
|
|
38
|
+
base: resolvedBase,
|
|
39
|
+
processCwd: node_path.resolve(sourceDir || resolvedBase),
|
|
40
|
+
ignore
|
|
41
|
+
};
|
|
42
|
+
const entries = entryFiles.map((file)=>node_path.resolve(file));
|
|
43
|
+
return import("@vercel/nft").then(({ nodeFileTrace })=>nodeFileTrace(entries, options));
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return Promise.reject(error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export { createBuildHostIgnore, traceDeployFiles };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
import { inspectModuleFederationConfigSource } from "./inspect.mjs";
|
|
5
|
+
const moduleFederationConfigFile = 'module-federation.config.ts';
|
|
6
|
+
function readModuleFederationConfigInspection(workspaceRoot, appDirectory) {
|
|
7
|
+
const configPath = node_path.join(workspaceRoot, appDirectory, moduleFederationConfigFile);
|
|
8
|
+
if (!node_fs.existsSync(configPath)) return;
|
|
9
|
+
try {
|
|
10
|
+
const source = node_fs.readFileSync(configPath, 'utf-8');
|
|
11
|
+
return inspectModuleFederationConfigSource(source, appDirectory, node_path.join(appDirectory, moduleFederationConfigFile));
|
|
12
|
+
} catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function readModuleFederationExposePaths(workspaceRoot, appDirectory) {
|
|
17
|
+
return readModuleFederationConfigInspection(workspaceRoot, appDirectory)?.exposePaths;
|
|
18
|
+
}
|
|
19
|
+
export { readModuleFederationConfigInspection, readModuleFederationExposePaths };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
export { readModuleFederationConfigInspection, readModuleFederationExposePaths } from "./exposes.mjs";
|
|
3
|
+
export { inspectModuleFederationConfigSource } from "./inspect.mjs";
|
|
4
|
+
export { parseArrayLiteral, parseLiteralString, parseObjectLiteral } from "./object-literal.mjs";
|
|
5
|
+
export { findCreateModuleFederationConfigObject, findExportDefaultObject, locateCreateModuleFederationConfigObject, parseConfigModule, parseStaticExpression } from "./syntax.mjs";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { parseArrayLiteral, parseLiteralString, parseObjectLiteral } from "./object-literal.mjs";
|
|
3
|
+
import { findCreateModuleFederationConfigObject, findExportDefaultObject, parseConfigModule } from "./syntax.mjs";
|
|
4
|
+
function extractExposes(configPath, value) {
|
|
5
|
+
if (void 0 === value) return {
|
|
6
|
+
exposePaths: {},
|
|
7
|
+
exposes: []
|
|
8
|
+
};
|
|
9
|
+
const object = parseObjectLiteral(value);
|
|
10
|
+
if (object) {
|
|
11
|
+
if (object.hasSpread) throw new Error(`Cannot statically extract Module Federation exposes from ${configPath}; use a literal exposes object without spreads.`);
|
|
12
|
+
const exposePaths = {};
|
|
13
|
+
for (const [expose, source] of object.properties){
|
|
14
|
+
const exposePath = parseLiteralString(source);
|
|
15
|
+
if (void 0 !== exposePath) exposePaths[expose] = exposePath;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
exposePaths,
|
|
19
|
+
exposes: Array.from(object.properties.keys()).sort()
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const array = parseArrayLiteral(value);
|
|
23
|
+
if (array) return {
|
|
24
|
+
exposePaths: {},
|
|
25
|
+
exposes: array.sort()
|
|
26
|
+
};
|
|
27
|
+
throw new Error(`Cannot statically extract Module Federation exposes from ${configPath}; use a literal exposes object or string array.`);
|
|
28
|
+
}
|
|
29
|
+
function extractDtsSettings(configPath, value, exposes) {
|
|
30
|
+
if ('false' === value) {
|
|
31
|
+
if (exposes.length > 0) throw new Error(`Module Federation DTS cannot be disabled for exposed app ${configPath}.`);
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
if (void 0 === value) return {};
|
|
35
|
+
const dts = parseObjectLiteral(value);
|
|
36
|
+
if (!dts || dts.hasSpread) throw new Error(`Cannot statically extract Module Federation DTS settings from ${configPath}; use a literal dts object.`);
|
|
37
|
+
const generateTypes = parseObjectLiteral(dts.properties.get('generateTypes'));
|
|
38
|
+
if (generateTypes?.hasSpread) throw new Error(`Cannot statically extract Module Federation generateTypes settings from ${configPath}; use a literal generateTypes object.`);
|
|
39
|
+
const compilerInstanceSource = generateTypes?.properties.get('compilerInstance');
|
|
40
|
+
return {
|
|
41
|
+
compilerInstance: parseLiteralString(compilerInstanceSource) ?? ('tsgoCompilerInstance' === compilerInstanceSource ? 'effect-tsgo' : void 0),
|
|
42
|
+
tsConfigPath: parseLiteralString(dts.properties.get('tsConfigPath'))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function hasHostOnlyNoExposesDeclaration(source) {
|
|
46
|
+
return (parseConfigModule(source).comments ?? []).some((comment)=>/@?ultramodern-mf\s*:?\s*(?:host-only|no-exposes)\b/iu.test(comment.value));
|
|
47
|
+
}
|
|
48
|
+
function inspectModuleFederationConfigSource(source, appDir, configPath) {
|
|
49
|
+
const configObject = findCreateModuleFederationConfigObject(source) ?? findExportDefaultObject(source);
|
|
50
|
+
if (!configObject) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; export or pass a literal config object.`);
|
|
51
|
+
const properties = parseObjectLiteral(configObject);
|
|
52
|
+
if (!properties) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; expected a literal config object.`);
|
|
53
|
+
if (properties.hasSpread) throw new Error(`Cannot statically inspect Module Federation config ${configPath}; top-level config spreads are not supported.`);
|
|
54
|
+
const { exposePaths, exposes } = extractExposes(configPath, properties.properties.get('exposes'));
|
|
55
|
+
const hostOnlyNoExposes = hasHostOnlyNoExposesDeclaration(source);
|
|
56
|
+
if (hostOnlyNoExposes && exposes.length > 0) throw new Error(`Module Federation host-only/no-exposes declaration conflicts with actual exposes in ${configPath}.`);
|
|
57
|
+
return {
|
|
58
|
+
appDir,
|
|
59
|
+
configPath,
|
|
60
|
+
dts: extractDtsSettings(configPath, properties.properties.get('dts'), exposes),
|
|
61
|
+
exposePaths,
|
|
62
|
+
exposes,
|
|
63
|
+
hostOnlyNoExposes
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export { inspectModuleFederationConfigSource };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { parseStaticExpression } from "./syntax.mjs";
|
|
3
|
+
function parseLiteralString(source) {
|
|
4
|
+
const node = parseStaticExpression(source);
|
|
5
|
+
if (node?.type === 'StringLiteral') return node.value;
|
|
6
|
+
if (node?.type === 'TemplateLiteral' && 0 === node.expressions.length) return node.quasis[0]?.value.cooked ?? void 0;
|
|
7
|
+
}
|
|
8
|
+
function parseObjectLiteral(source) {
|
|
9
|
+
const node = parseStaticExpression(source);
|
|
10
|
+
if (void 0 === source || node?.type !== 'ObjectExpression') return;
|
|
11
|
+
const properties = new Map();
|
|
12
|
+
let hasSpread = false;
|
|
13
|
+
for (const property of node.properties){
|
|
14
|
+
if ('ObjectProperty' !== property.type || property.computed || property.shorthand) {
|
|
15
|
+
hasSpread = true;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const key = 'Identifier' === property.key.type ? property.key.name : 'StringLiteral' === property.key.type ? property.key.value : void 0;
|
|
19
|
+
const value = parseStaticExpression(source.slice(property.value.start ?? 0, property.value.end ?? 0));
|
|
20
|
+
if (void 0 === key || properties.has(key) || !value || null == value.start || null == value.end) {
|
|
21
|
+
hasSpread = true;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const rawValue = source.slice(property.value.start ?? 0, property.value.end ?? 0);
|
|
25
|
+
properties.set(key, rawValue.slice(value.start, value.end));
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
hasSpread,
|
|
29
|
+
properties
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function parseArrayLiteral(source) {
|
|
33
|
+
const node = parseStaticExpression(source);
|
|
34
|
+
if (void 0 === source || node?.type !== 'ArrayExpression') return;
|
|
35
|
+
const values = [];
|
|
36
|
+
for (const element of node.elements){
|
|
37
|
+
if (!element || 'SpreadElement' === element.type) return;
|
|
38
|
+
const value = parseLiteralString(source.slice(element.start ?? 0, element.end ?? 0));
|
|
39
|
+
if (void 0 === value) return;
|
|
40
|
+
values.push(value);
|
|
41
|
+
}
|
|
42
|
+
return values;
|
|
43
|
+
}
|
|
44
|
+
export { parseArrayLiteral, parseLiteralString, parseObjectLiteral };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { parse, parseExpression } from "@babel/parser";
|
|
3
|
+
function unwrapExpression(node) {
|
|
4
|
+
while('TSAsExpression' === node.type || 'TSSatisfiesExpression' === node.type || 'TSNonNullExpression' === node.type || 'TSTypeAssertion' === node.type || 'ParenthesizedExpression' === node.type)node = node.expression;
|
|
5
|
+
return node;
|
|
6
|
+
}
|
|
7
|
+
function parseStaticExpression(source) {
|
|
8
|
+
if (void 0 === source) return;
|
|
9
|
+
try {
|
|
10
|
+
return unwrapExpression(parseExpression(source, {
|
|
11
|
+
plugins: [
|
|
12
|
+
"typescript"
|
|
13
|
+
]
|
|
14
|
+
}));
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function parseConfigModule(source) {
|
|
20
|
+
return parse(source, {
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
plugins: [
|
|
23
|
+
"typescript"
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function locateExportedConfig(source, factory) {
|
|
28
|
+
const module = parseConfigModule(source);
|
|
29
|
+
const constants = new Map();
|
|
30
|
+
const bindingStarts = new Map();
|
|
31
|
+
const resolvedBindings = new Set();
|
|
32
|
+
const allowedReferences = new Set();
|
|
33
|
+
const factories = new Set();
|
|
34
|
+
const namespaces = new Set();
|
|
35
|
+
const defaults = [];
|
|
36
|
+
for (const statement of module.program.body){
|
|
37
|
+
if ('ImportDeclaration' === statement.type && 'type' !== statement.importKind && '@module-federation/modern-js-v3' === statement.source.value) {
|
|
38
|
+
for (const specifier of statement.specifiers)if ('ImportNamespaceSpecifier' === specifier.type) namespaces.add(specifier.local.name);
|
|
39
|
+
else if ('ImportSpecifier' === specifier.type && 'type' !== specifier.importKind && ('Identifier' === specifier.imported.type ? specifier.imported.name : specifier.imported.value) === 'createModuleFederationConfig') factories.add(specifier.local.name);
|
|
40
|
+
}
|
|
41
|
+
const declaration = 'ExportNamedDeclaration' === statement.type ? statement.declaration : statement;
|
|
42
|
+
if (declaration?.type === 'VariableDeclaration' && 'const' === declaration.kind) {
|
|
43
|
+
for (const binding of declaration.declarations)if ('Identifier' === binding.id.type && binding.init) {
|
|
44
|
+
constants.set(binding.id.name, binding.init);
|
|
45
|
+
bindingStarts.set(binding.id.name, binding.id.start);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if ('ExportDefaultDeclaration' === statement.type) defaults.push(statement.declaration);
|
|
49
|
+
else if ('ExportNamedDeclaration' === statement.type && !statement.source && 'type' !== statement.exportKind) {
|
|
50
|
+
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);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const resolve = (node, seen = new Set())=>{
|
|
54
|
+
if (!node) return;
|
|
55
|
+
if ('Identifier' === node.type) {
|
|
56
|
+
if (seen.has(node.name)) return;
|
|
57
|
+
seen.add(node.name);
|
|
58
|
+
resolvedBindings.add(node.name);
|
|
59
|
+
if (null != node.start) allowedReferences.add(node.start);
|
|
60
|
+
const bindingStart = bindingStarts.get(node.name);
|
|
61
|
+
if (null != bindingStart) allowedReferences.add(bindingStart);
|
|
62
|
+
return resolve(constants.get(node.name), seen);
|
|
63
|
+
}
|
|
64
|
+
if ('TSAsExpression' === node.type || 'TSSatisfiesExpression' === node.type || 'TSNonNullExpression' === node.type || 'TSTypeAssertion' === node.type || 'ParenthesizedExpression' === node.type) return resolve(node.expression, seen);
|
|
65
|
+
return node;
|
|
66
|
+
};
|
|
67
|
+
if (1 !== defaults.length) return;
|
|
68
|
+
let node = resolve(defaults[0]);
|
|
69
|
+
if (factory) {
|
|
70
|
+
if (node?.type !== 'CallExpression' || 1 !== node.arguments.length) return;
|
|
71
|
+
const callee = node.callee;
|
|
72
|
+
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;
|
|
73
|
+
if (!supported) return;
|
|
74
|
+
const argument = node.arguments[0];
|
|
75
|
+
if (!argument || 'SpreadElement' === argument.type || 'ArgumentPlaceholder' === argument.type) return;
|
|
76
|
+
node = resolve(argument);
|
|
77
|
+
}
|
|
78
|
+
if (node?.type !== 'ObjectExpression' || null == node.start || null == node.end) return;
|
|
79
|
+
const hasOtherReference = (value)=>{
|
|
80
|
+
if (!value || 'object' != typeof value) return false;
|
|
81
|
+
if (Array.isArray(value)) return value.some(hasOtherReference);
|
|
82
|
+
const entry = value;
|
|
83
|
+
if ('Identifier' === entry.type && 'string' == typeof entry.name && resolvedBindings.has(entry.name) && ('number' != typeof entry.start || !allowedReferences.has(entry.start))) return true;
|
|
84
|
+
return Object.entries(entry).some(([key, child])=>'loc' !== key && 'comments' !== key && 'leadingComments' !== key && 'trailingComments' !== key && hasOtherReference(child));
|
|
85
|
+
};
|
|
86
|
+
if (hasOtherReference(module.program)) return;
|
|
87
|
+
return {
|
|
88
|
+
start: node.start,
|
|
89
|
+
end: node.end,
|
|
90
|
+
source: source.slice(node.start, node.end)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function locateCreateModuleFederationConfigObject(source) {
|
|
94
|
+
return locateExportedConfig(source, true);
|
|
95
|
+
}
|
|
96
|
+
function findCreateModuleFederationConfigObject(source) {
|
|
97
|
+
return locateCreateModuleFederationConfigObject(source)?.source;
|
|
98
|
+
}
|
|
99
|
+
function findExportDefaultObject(source) {
|
|
100
|
+
return locateExportedConfig(source, false)?.source;
|
|
101
|
+
}
|
|
102
|
+
export { findCreateModuleFederationConfigObject, findExportDefaultObject, locateCreateModuleFederationConfigObject, parseConfigModule, parseStaticExpression };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
|
@@ -1,11 +1,60 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { execFile } from "node:child_process";
|
|
3
|
-
import {
|
|
2
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { existsSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
4
6
|
import node_path from "node:path";
|
|
5
7
|
import { promisify } from "node:util";
|
|
6
8
|
import { refreshTsgoCheckerConfig } from "@modern-js/builder";
|
|
9
|
+
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
10
|
+
import { resolveEffectTsgoCompiler } from "./build-config/build-environment.mjs";
|
|
7
11
|
const execute = promisify(execFile);
|
|
8
12
|
const native_type_checker_name = 'UltramodernNativeTypeChecker';
|
|
13
|
+
function resolveNativeTypeCheckerCommand(from) {
|
|
14
|
+
const executable = resolveEffectTsgoCompiler({
|
|
15
|
+
from
|
|
16
|
+
});
|
|
17
|
+
const version = execFileSync(executable, [
|
|
18
|
+
'--version'
|
|
19
|
+
], {
|
|
20
|
+
encoding: 'utf8',
|
|
21
|
+
env: {
|
|
22
|
+
...process.env,
|
|
23
|
+
TSRS_CHECKER_ASSIGNMENT: process.env.TSRS_CHECKER_ASSIGNMENT || 'go'
|
|
24
|
+
},
|
|
25
|
+
timeout: 10000
|
|
26
|
+
});
|
|
27
|
+
if (version.includes('(tsrs ')) return {
|
|
28
|
+
executable,
|
|
29
|
+
args: [],
|
|
30
|
+
configApi: createRequire(from).resolve('tsrs/sync')
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
executable,
|
|
34
|
+
args: []
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const inspectNativeConfig = `
|
|
38
|
+
import { pathToFileURL } from 'node:url';
|
|
39
|
+
const [modulePath, compiler, configFile] = process.argv.slice(1);
|
|
40
|
+
const { API, formatDiagnostics } = await import(pathToFileURL(modulePath).href);
|
|
41
|
+
const api = new API({ tsserverPath: compiler });
|
|
42
|
+
try {
|
|
43
|
+
const config = api.parseConfigFile(configFile);
|
|
44
|
+
if (config.errors.length) {
|
|
45
|
+
process.stdout.write(formatDiagnostics(config.errors, api));
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
} else {
|
|
48
|
+
process.stdout.write(JSON.stringify({
|
|
49
|
+
compilerOptions: config.options,
|
|
50
|
+
files: config.fileNames,
|
|
51
|
+
references: config.projectReferences,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
} finally {
|
|
55
|
+
api.close();
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
9
58
|
const watchDependencyPath = (file)=>{
|
|
10
59
|
if ('win32' !== process.platform) return file;
|
|
11
60
|
try {
|
|
@@ -14,9 +63,87 @@ const watchDependencyPath = (file)=>{
|
|
|
14
63
|
return file;
|
|
15
64
|
}
|
|
16
65
|
};
|
|
66
|
+
function missingJsxRuntimeHint(diagnostics) {
|
|
67
|
+
const source = /error TS2875: This JSX tag requires the module path '(.+?)\/jsx-(?:dev-)?runtime'/u.exec(diagnostics)?.[1];
|
|
68
|
+
if (!source) return '';
|
|
69
|
+
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`;
|
|
70
|
+
}
|
|
17
71
|
class UltramodernNativeTypeChecker {
|
|
18
72
|
async check() {
|
|
19
|
-
const
|
|
73
|
+
const configFile = await this.projectConfigFile();
|
|
74
|
+
try {
|
|
75
|
+
await this.checkProject(configFile);
|
|
76
|
+
} finally{
|
|
77
|
+
this.removeProjection(configFile);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async projectConfigFile() {
|
|
81
|
+
const { configFile, configOverwrite } = this.options;
|
|
82
|
+
if (!configOverwrite) return configFile;
|
|
83
|
+
const errors = [];
|
|
84
|
+
const source = readFileSync(configFile, 'utf8');
|
|
85
|
+
const project = parse(0xfeff === source.charCodeAt(0) ? source.slice(1) : source, errors, {
|
|
86
|
+
allowTrailingComma: true
|
|
87
|
+
});
|
|
88
|
+
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(', ')}`);
|
|
89
|
+
if (!project || 'object' != typeof project || Array.isArray(project)) throw new Error(`${native_type_checker_name} requires a JSONC object in ${configFile}.`);
|
|
90
|
+
const projectedConfig = {
|
|
91
|
+
...project,
|
|
92
|
+
...configOverwrite,
|
|
93
|
+
compilerOptions: {
|
|
94
|
+
...project.compilerOptions,
|
|
95
|
+
...configOverwrite.compilerOptions
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const projected = node_path.join(node_path.dirname(configFile), `.ultramodern-native-checker.${randomUUID()}.json`);
|
|
99
|
+
writeFileSync(projected, `${JSON.stringify(projectedConfig, null, 2)}\n`, {
|
|
100
|
+
flag: 'wx'
|
|
101
|
+
});
|
|
102
|
+
try {
|
|
103
|
+
const resolved = JSON.parse(await this.run([
|
|
104
|
+
'--showConfig',
|
|
105
|
+
'--project',
|
|
106
|
+
projected
|
|
107
|
+
]));
|
|
108
|
+
const options = resolved.compilerOptions ?? {};
|
|
109
|
+
if ((this.options.build || true === options.incremental || true === options.composite) && !options.tsBuildInfoFile) {
|
|
110
|
+
const original = configFile.slice(0, configFile.length - node_path.extname(configFile).length);
|
|
111
|
+
let buildInfo = original;
|
|
112
|
+
if ('string' == typeof options.outDir) {
|
|
113
|
+
const outDir = node_path.resolve(node_path.dirname(configFile), options.outDir);
|
|
114
|
+
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));
|
|
115
|
+
}
|
|
116
|
+
projectedConfig.compilerOptions = {
|
|
117
|
+
...projectedConfig.compilerOptions,
|
|
118
|
+
tsBuildInfoFile: `${buildInfo}.tsbuildinfo`
|
|
119
|
+
};
|
|
120
|
+
writeFileSync(projected, `${JSON.stringify(projectedConfig, null, 2)}\n`);
|
|
121
|
+
}
|
|
122
|
+
return projected;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
unlinkSync(projected);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
removeProjection(configFile) {
|
|
129
|
+
if (configFile !== this.options.configFile) unlinkSync(configFile);
|
|
130
|
+
}
|
|
131
|
+
async checkProject(configFile) {
|
|
132
|
+
const { build } = this.options;
|
|
133
|
+
if (!build) {
|
|
134
|
+
const config = JSON.parse(await this.run([
|
|
135
|
+
'--showConfig',
|
|
136
|
+
'--project',
|
|
137
|
+
configFile
|
|
138
|
+
]));
|
|
139
|
+
if (config.references?.length) await this.run([
|
|
140
|
+
'--build',
|
|
141
|
+
...config.references.map((reference)=>node_path.resolve(node_path.dirname(configFile), reference.path)),
|
|
142
|
+
'--stopBuildOnErrors',
|
|
143
|
+
'--pretty',
|
|
144
|
+
'false'
|
|
145
|
+
]);
|
|
146
|
+
}
|
|
20
147
|
const args = build ? [
|
|
21
148
|
'--build',
|
|
22
149
|
configFile,
|
|
@@ -34,30 +161,56 @@ class UltramodernNativeTypeChecker {
|
|
|
34
161
|
}
|
|
35
162
|
async run(args) {
|
|
36
163
|
try {
|
|
37
|
-
const
|
|
164
|
+
const selected = this.options.compiler();
|
|
165
|
+
const command = 'string' == typeof selected ? {
|
|
166
|
+
executable: selected,
|
|
167
|
+
args: []
|
|
168
|
+
} : selected;
|
|
169
|
+
const inspect = '--showConfig' === args[0] && command.configApi;
|
|
170
|
+
const result = await execute(inspect ? process.execPath : command.executable, inspect ? [
|
|
171
|
+
'--input-type=module',
|
|
172
|
+
'--eval',
|
|
173
|
+
inspectNativeConfig,
|
|
174
|
+
command.configApi,
|
|
175
|
+
command.executable,
|
|
176
|
+
args[args.indexOf('--project') + 1]
|
|
177
|
+
] : [
|
|
178
|
+
...command.args,
|
|
179
|
+
...args
|
|
180
|
+
], {
|
|
38
181
|
cwd: node_path.dirname(this.options.configFile),
|
|
39
|
-
|
|
182
|
+
env: {
|
|
183
|
+
...process.env,
|
|
184
|
+
TSRS_CHECKER_ASSIGNMENT: process.env.TSRS_CHECKER_ASSIGNMENT || 'go'
|
|
185
|
+
},
|
|
186
|
+
maxBuffer: 16777216,
|
|
187
|
+
...inspect ? {
|
|
188
|
+
timeout: 10000
|
|
189
|
+
} : {}
|
|
40
190
|
});
|
|
41
191
|
return result.stdout;
|
|
42
192
|
} catch (cause) {
|
|
43
193
|
const output = cause;
|
|
44
194
|
const diagnostics = `${output.stdout ?? ''}${output.stderr ?? ''}`;
|
|
45
|
-
throw new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}`, {
|
|
195
|
+
throw Object.assign(new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}${missingJsxRuntimeHint(diagnostics)}`, {
|
|
46
196
|
cause
|
|
197
|
+
}), {
|
|
198
|
+
code: output.code,
|
|
199
|
+
signal: output.signal
|
|
47
200
|
});
|
|
48
201
|
}
|
|
49
202
|
}
|
|
50
|
-
async watchInputs() {
|
|
203
|
+
async watchInputs(configFile) {
|
|
51
204
|
const inputs = new Set();
|
|
52
205
|
const missing = new Set();
|
|
53
206
|
const projects = [
|
|
54
|
-
|
|
207
|
+
configFile
|
|
55
208
|
];
|
|
56
209
|
const visited = new Set();
|
|
57
210
|
for (const configFile of projects){
|
|
58
211
|
if (visited.has(configFile)) continue;
|
|
59
212
|
visited.add(configFile);
|
|
60
|
-
inputs.add(configFile);
|
|
213
|
+
if (configFile === this.options.configFile || configFile !== projects[0]) inputs.add(configFile);
|
|
61
214
|
if (!existsSync(configFile)) {
|
|
62
215
|
missing.add(configFile);
|
|
63
216
|
continue;
|
|
@@ -95,14 +248,17 @@ class UltramodernNativeTypeChecker {
|
|
|
95
248
|
compilation.fileDependencies.add(watched);
|
|
96
249
|
if (!existsSync(projectConfigFile)) compilation.missingDependencies.add(watched);
|
|
97
250
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
251
|
+
const configFile = await this.projectConfigFile();
|
|
252
|
+
try {
|
|
253
|
+
const { inputs, missing } = await this.watchInputs(configFile);
|
|
254
|
+
for (const file of inputs)compilation.fileDependencies.add(watchDependencyPath(file));
|
|
255
|
+
for (const file of missing)compilation.missingDependencies.add(watchDependencyPath(file));
|
|
256
|
+
await this.checkProject(configFile);
|
|
257
|
+
} finally{
|
|
258
|
+
this.removeProjection(configFile);
|
|
259
|
+
}
|
|
102
260
|
} catch (cause) {
|
|
103
|
-
compilation.errors.push(
|
|
104
|
-
cause
|
|
105
|
-
}));
|
|
261
|
+
compilation.errors.push(cause instanceof Error ? cause : new Error(String(cause)));
|
|
106
262
|
}
|
|
107
263
|
});
|
|
108
264
|
});
|
|
@@ -122,8 +278,9 @@ function configureUltramodernTypeChecker(chain, pluginId, resolveCompiler) {
|
|
|
122
278
|
{
|
|
123
279
|
build: true === typescript.build,
|
|
124
280
|
compiler: ()=>resolveCompiler(configFile),
|
|
125
|
-
configFile
|
|
281
|
+
configFile,
|
|
282
|
+
configOverwrite: typescript.configOverwrite
|
|
126
283
|
}
|
|
127
284
|
]);
|
|
128
285
|
}
|
|
129
|
-
export { UltramodernNativeTypeChecker, configureUltramodernTypeChecker };
|
|
286
|
+
export { UltramodernNativeTypeChecker, configureUltramodernTypeChecker, missingJsxRuntimeHint, resolveNativeTypeCheckerCommand };
|
|
@@ -3,44 +3,50 @@ import { collectRuntimePackageModuleDirectories, createRuntimePackageResolutionP
|
|
|
3
3
|
const RENDERER_EXTENSIONS_PACKAGE = '@modern-js/runtime-renderer-extensions';
|
|
4
4
|
const RENDERER_EXTENSIONS_PLUGIN_NAME = 'rendererHead';
|
|
5
5
|
const SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/app-tools/server-plugin';
|
|
6
|
+
const ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME = '@modern-js/ultramodern-app-tools/server-plugin';
|
|
6
7
|
const POLICY_DEFAULTS_PLUGIN_NAME = '@modern-js/ultramodern-policy-defaults';
|
|
7
|
-
const applyPolicyDefaults = (api, options = {})=>{
|
|
8
|
-
if (false !== options.rendererExtensions) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const applyPolicyDefaults = (api, options = {}, composition = {})=>{
|
|
9
|
+
if (false !== options.rendererExtensions) api._internalRuntimePlugins(({ entrypoint, plugins })=>{
|
|
10
|
+
if (!plugins.some((plugin)=>plugin.path === RENDERER_EXTENSIONS_PACKAGE)) plugins.push({
|
|
11
|
+
name: RENDERER_EXTENSIONS_PLUGIN_NAME,
|
|
12
|
+
path: RENDERER_EXTENSIONS_PACKAGE,
|
|
13
|
+
config: {}
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
entrypoint,
|
|
17
|
+
plugins
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
const runtimePackages = [
|
|
21
|
+
...false !== options.rendererExtensions ? [
|
|
22
|
+
RENDERER_EXTENSIONS_PACKAGE
|
|
23
|
+
] : [],
|
|
24
|
+
...(composition.runtimePackages ?? []).filter((packageName)=>packageName !== RENDERER_EXTENSIONS_PACKAGE)
|
|
25
|
+
];
|
|
26
|
+
const moduleDirectories = collectRuntimePackageModuleDirectories(runtimePackages, composition.registrarUrl ?? import.meta.url);
|
|
27
|
+
if (moduleDirectories.length > 0) api.modifyResolvedConfig((config)=>({
|
|
28
|
+
...config,
|
|
29
|
+
builderPlugins: [
|
|
30
|
+
...config.builderPlugins ?? [],
|
|
31
|
+
createRuntimePackageResolutionPlugin(moduleDirectories)
|
|
32
|
+
]
|
|
33
|
+
}));
|
|
34
|
+
if (false !== options.serverExtensions) {
|
|
35
|
+
const serverPluginName = composition.serverPluginName ?? SERVER_EXTENSIONS_PLUGIN_NAME;
|
|
36
|
+
api._internalServerPlugins(({ plugins })=>{
|
|
37
|
+
if (!plugins.some((plugin)=>plugin.name === serverPluginName || plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME || plugin.name === ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME)) plugins.push({
|
|
38
|
+
name: serverPluginName
|
|
14
39
|
});
|
|
15
40
|
return {
|
|
16
|
-
entrypoint,
|
|
17
41
|
plugins
|
|
18
42
|
};
|
|
19
43
|
});
|
|
20
|
-
const moduleDirectories = collectRuntimePackageModuleDirectories([
|
|
21
|
-
RENDERER_EXTENSIONS_PACKAGE
|
|
22
|
-
], import.meta.url);
|
|
23
|
-
if (moduleDirectories.length > 0) api.modifyResolvedConfig((config)=>({
|
|
24
|
-
...config,
|
|
25
|
-
builderPlugins: [
|
|
26
|
-
...config.builderPlugins ?? [],
|
|
27
|
-
createRuntimePackageResolutionPlugin(moduleDirectories)
|
|
28
|
-
]
|
|
29
|
-
}));
|
|
30
44
|
}
|
|
31
|
-
if (false !== options.serverExtensions) api._internalServerPlugins(({ plugins })=>{
|
|
32
|
-
if (!plugins.some((plugin)=>plugin.name === SERVER_EXTENSIONS_PLUGIN_NAME)) plugins.push({
|
|
33
|
-
name: SERVER_EXTENSIONS_PLUGIN_NAME
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
plugins
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
45
|
};
|
|
40
|
-
const createPolicyDefaultsPlugin = (options = {})=>({
|
|
41
|
-
name: POLICY_DEFAULTS_PLUGIN_NAME,
|
|
46
|
+
const createPolicyDefaultsPlugin = (options = {}, composition = {})=>({
|
|
47
|
+
name: composition.pluginName ?? POLICY_DEFAULTS_PLUGIN_NAME,
|
|
42
48
|
setup (api) {
|
|
43
|
-
applyPolicyDefaults(api, options);
|
|
49
|
+
applyPolicyDefaults(api, options, composition);
|
|
44
50
|
}
|
|
45
51
|
});
|
|
46
|
-
export { POLICY_DEFAULTS_PLUGIN_NAME, RENDERER_EXTENSIONS_PACKAGE, RENDERER_EXTENSIONS_PLUGIN_NAME, SERVER_EXTENSIONS_PLUGIN_NAME, applyPolicyDefaults, createPolicyDefaultsPlugin };
|
|
52
|
+
export { POLICY_DEFAULTS_PLUGIN_NAME, RENDERER_EXTENSIONS_PACKAGE, RENDERER_EXTENSIONS_PLUGIN_NAME, SERVER_EXTENSIONS_PLUGIN_NAME, ULTRAMODERN_SERVER_EXTENSIONS_PLUGIN_NAME, applyPolicyDefaults, createPolicyDefaultsPlugin };
|
|
@@ -8,15 +8,8 @@ const serializeCanonicalValue = (value)=>{
|
|
|
8
8
|
if (Array.isArray(value)) return `[${value.map(serializeCanonicalValue).join(',')}]`;
|
|
9
9
|
return `{${Object.keys(value).sort().map((key)=>`${JSON.stringify(key)}:${serializeCanonicalValue(value[key])}`).join(',')}}`;
|
|
10
10
|
};
|
|
11
|
-
const releaseEnvelopePayload = (envelope)=>({
|
|
12
|
-
schemaVersion: envelope.schemaVersion,
|
|
13
|
-
kind: envelope.kind,
|
|
14
|
-
target: envelope.target,
|
|
15
|
-
identity: envelope.identity,
|
|
16
|
-
artifacts: envelope.artifacts,
|
|
17
|
-
surfaces: envelope.surfaces
|
|
18
|
-
});
|
|
19
11
|
const canonicalSerializeMicroVerticalReleaseEnvelopePayload = (payload)=>serializeCanonicalValue(payload);
|
|
20
12
|
const canonicalSerializeMicroVerticalReleaseEnvelope = (envelope)=>serializeCanonicalValue(envelope);
|
|
21
13
|
const digestMicroVerticalReleaseEnvelopePayload = (payload)=>createHash('sha256').update(canonicalSerializeMicroVerticalReleaseEnvelopePayload(payload)).digest('hex');
|
|
22
|
-
export {
|
|
14
|
+
export { releaseEnvelopePayload } from "./contract.mjs";
|
|
15
|
+
export { canonicalSerializeMicroVerticalReleaseEnvelope, canonicalSerializeMicroVerticalReleaseEnvelopePayload, digestMicroVerticalReleaseEnvelopePayload };
|