@bleedingdev/modern-js-app-tools-extensions 3.9.0-ultramodern.4 → 3.9.0-ultramodern.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/backend-federation-build/codegen.js +256 -0
- package/dist/cjs/backend-federation-build/config.js +189 -0
- package/dist/cjs/backend-federation-build/emit.js +150 -0
- package/dist/cjs/backend-federation-build/index.js +53 -0
- package/dist/cjs/build-config/build-environment.js +268 -0
- package/dist/cjs/build-config/precompress/plugin.js +124 -0
- package/dist/cjs/build-config/precompress/types.js +18 -0
- package/dist/cjs/build-config/public.js +46 -0
- package/dist/cjs/cloudflare/constants.js +1 -1
- package/dist/cjs/cloudflare/delivery-unit.js +7 -16
- package/dist/cjs/cloudflare-output-verifier/identity.js +6 -6
- package/dist/cjs/config.js +29 -1
- package/dist/cjs/deploy-output/npmAliases.js +226 -0
- package/dist/cjs/deploy-output/plugin.js +76 -0
- package/dist/cjs/deploy-output/target.js +48 -0
- package/dist/cjs/native-type-checker.js +6 -3
- package/dist/cjs/release-envelope/framework-output.js +27 -27
- package/dist/cjs/release-envelope/plugin.js +2 -1
- package/dist/esm/backend-federation-build/codegen.mjs +205 -0
- package/dist/esm/backend-federation-build/config.mjs +116 -0
- package/dist/esm/backend-federation-build/emit.mjs +99 -0
- package/dist/esm/backend-federation-build/index.mjs +1 -0
- package/dist/esm/build-config/build-environment.mjs +224 -0
- package/dist/esm/build-config/precompress/plugin.mjs +76 -0
- package/dist/esm/build-config/precompress/types.mjs +0 -0
- package/dist/esm/build-config/public.mjs +1 -0
- package/dist/esm/cloudflare/constants.mjs +1 -1
- package/dist/esm/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm/config.mjs +1 -0
- package/dist/esm/deploy-output/npmAliases.mjs +174 -0
- package/dist/esm/deploy-output/plugin.mjs +28 -0
- package/dist/esm/deploy-output/target.mjs +10 -0
- package/dist/esm/native-type-checker.mjs +6 -3
- package/dist/esm/release-envelope/framework-output.mjs +1 -1
- package/dist/esm/release-envelope/plugin.mjs +2 -1
- package/dist/esm-node/backend-federation-build/codegen.mjs +206 -0
- package/dist/esm-node/backend-federation-build/config.mjs +117 -0
- package/dist/esm-node/backend-federation-build/emit.mjs +100 -0
- package/dist/esm-node/backend-federation-build/index.mjs +2 -0
- package/dist/esm-node/build-config/build-environment.mjs +225 -0
- package/dist/esm-node/build-config/precompress/plugin.mjs +77 -0
- package/dist/esm-node/build-config/precompress/types.mjs +1 -0
- package/dist/esm-node/build-config/public.mjs +2 -0
- package/dist/esm-node/cloudflare/constants.mjs +1 -1
- package/dist/esm-node/cloudflare/delivery-unit.mjs +1 -10
- package/dist/esm-node/cloudflare-output-verifier/identity.mjs +1 -1
- package/dist/esm-node/config.mjs +1 -0
- package/dist/esm-node/deploy-output/npmAliases.mjs +175 -0
- package/dist/esm-node/deploy-output/plugin.mjs +31 -0
- package/dist/esm-node/deploy-output/target.mjs +11 -0
- package/dist/esm-node/native-type-checker.mjs +6 -3
- package/dist/esm-node/release-envelope/framework-output.mjs +1 -1
- package/dist/esm-node/release-envelope/plugin.mjs +2 -1
- package/dist/types/backend-federation-build/codegen.d.ts +86 -0
- package/dist/types/backend-federation-build/config.d.ts +102 -0
- package/dist/types/backend-federation-build/emit.d.ts +21 -0
- package/dist/types/backend-federation-build/index.d.ts +2 -0
- package/dist/types/build-config/build-environment.d.ts +22 -0
- package/dist/types/build-config/precompress/plugin.d.ts +4 -0
- package/dist/types/build-config/precompress/types.d.ts +19 -0
- package/dist/types/build-config/public.d.ts +2 -0
- package/dist/types/cloudflare/constants.d.ts +1 -1
- package/dist/types/cloudflare/delivery-unit.d.ts +2 -2
- package/dist/types/cloudflare/worker-manifest.d.ts +2 -2
- package/dist/types/cloudflare-output-verifier/identity.d.ts +1 -1
- package/dist/types/config.d.ts +2 -0
- package/dist/types/deploy-output/npmAliases.d.ts +14 -0
- package/dist/types/deploy-output/plugin.d.ts +15 -0
- package/dist/types/deploy-output/target.d.ts +6 -0
- package/dist/types/precompress/LICENSE +20 -0
- package/dist/types/precompress/index.d.ts +76 -0
- package/package.json +50 -8
- package/src/backend-federation-build/codegen.ts +245 -0
- package/src/backend-federation-build/config.ts +356 -0
- package/src/backend-federation-build/emit.ts +202 -0
- package/src/backend-federation-build/index.ts +2 -0
- package/src/build-config/build-environment.ts +404 -0
- package/src/build-config/precompress/plugin.ts +140 -0
- package/src/build-config/precompress/types.ts +26 -0
- package/src/build-config/public.ts +6 -0
- package/src/cloudflare/constants.ts +1 -1
- package/src/cloudflare/delivery-unit.ts +3 -20
- package/src/cloudflare/worker-manifest.ts +1 -0
- package/src/cloudflare-builder.ts +1 -0
- package/src/cloudflare-output-verifier/identity.ts +1 -1
- package/src/config.ts +7 -0
- package/src/deploy-output/npmAliases.ts +333 -0
- package/src/deploy-output/plugin.ts +49 -0
- package/src/deploy-output/target.ts +23 -0
- package/src/native-type-checker.ts +11 -3
- package/src/release-envelope/framework-output.ts +1 -1
- package/src/release-envelope/plugin.ts +5 -1
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
preserveNpmAliases: ()=>preserveNpmAliases,
|
|
41
|
+
readPackageIdentity: ()=>readPackageIdentity
|
|
42
|
+
});
|
|
43
|
+
const promises_namespaceObject = require("node:fs/promises");
|
|
44
|
+
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
45
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
46
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
47
|
+
const dependencyKeys = [
|
|
48
|
+
'dependencies',
|
|
49
|
+
'optionalDependencies'
|
|
50
|
+
];
|
|
51
|
+
const exactVersionPattern = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u;
|
|
52
|
+
async function readPackageJson(filePath) {
|
|
53
|
+
return JSON.parse(await promises_default().readFile(filePath, 'utf8'));
|
|
54
|
+
}
|
|
55
|
+
function parseNpmAlias(aliasName, specifier) {
|
|
56
|
+
if (!specifier.startsWith('npm:')) return;
|
|
57
|
+
const target = specifier.slice(4);
|
|
58
|
+
const versionSeparator = target.lastIndexOf('@');
|
|
59
|
+
if (versionSeparator <= 0 || versionSeparator === target.length - 1) throw new Error(`Invalid npm alias specifier for ${aliasName}: ${specifier}`);
|
|
60
|
+
return {
|
|
61
|
+
aliasName,
|
|
62
|
+
targetName: target.slice(0, versionSeparator),
|
|
63
|
+
targetVersion: target.slice(versionSeparator + 1)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function aliasesFromPackageJson(packageJson) {
|
|
67
|
+
const aliases = [];
|
|
68
|
+
for (const dependencyKey of dependencyKeys)for (const [aliasName, specifier] of Object.entries(packageJson[dependencyKey] ?? {})){
|
|
69
|
+
const alias = parseNpmAlias(aliasName, specifier);
|
|
70
|
+
if (alias) aliases.push(alias);
|
|
71
|
+
}
|
|
72
|
+
return aliases;
|
|
73
|
+
}
|
|
74
|
+
async function collectPackageRecords(nodeModulesDirectory) {
|
|
75
|
+
const records = [];
|
|
76
|
+
const visitedNodeModules = new Set();
|
|
77
|
+
const visitPackage = async (directory)=>{
|
|
78
|
+
const packageJsonPath = external_node_path_default().join(directory, 'package.json');
|
|
79
|
+
try {
|
|
80
|
+
const packageJson = await readPackageJson(packageJsonPath);
|
|
81
|
+
if (packageJson.name && packageJson.version) records.push({
|
|
82
|
+
directory,
|
|
83
|
+
packageJson
|
|
84
|
+
});
|
|
85
|
+
} catch (error) {
|
|
86
|
+
if ('ENOENT' !== error.code) throw error;
|
|
87
|
+
}
|
|
88
|
+
await visitNodeModules(external_node_path_default().join(directory, 'node_modules'));
|
|
89
|
+
};
|
|
90
|
+
const visitScope = async (scopeDirectory)=>{
|
|
91
|
+
const entries = await promises_default().readdir(scopeDirectory, {
|
|
92
|
+
withFileTypes: true
|
|
93
|
+
});
|
|
94
|
+
for (const entry of entries)if (entry.isDirectory()) await visitPackage(external_node_path_default().join(scopeDirectory, entry.name));
|
|
95
|
+
};
|
|
96
|
+
const visitNdepeStore = async (storeDirectory)=>{
|
|
97
|
+
const entries = await promises_default().readdir(storeDirectory, {
|
|
98
|
+
withFileTypes: true
|
|
99
|
+
});
|
|
100
|
+
for (const entry of entries)if (entry.isDirectory()) {
|
|
101
|
+
const entryPath = external_node_path_default().join(storeDirectory, entry.name);
|
|
102
|
+
if (entry.name.startsWith('@')) await visitScope(entryPath);
|
|
103
|
+
else await visitNodeModules(external_node_path_default().join(entryPath, 'node_modules'));
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const visitNodeModules = async (directory)=>{
|
|
107
|
+
const resolvedDirectory = external_node_path_default().resolve(directory);
|
|
108
|
+
if (visitedNodeModules.has(resolvedDirectory)) return;
|
|
109
|
+
visitedNodeModules.add(resolvedDirectory);
|
|
110
|
+
let entries;
|
|
111
|
+
try {
|
|
112
|
+
entries = await promises_default().readdir(directory, {
|
|
113
|
+
withFileTypes: true
|
|
114
|
+
});
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if ('ENOENT' === error.code) return;
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
for (const entry of entries){
|
|
120
|
+
if (!entry.isDirectory()) continue;
|
|
121
|
+
const entryPath = external_node_path_default().join(directory, entry.name);
|
|
122
|
+
if ('.ndepe' === entry.name) await visitNdepeStore(entryPath);
|
|
123
|
+
else if (entry.name.startsWith('@')) await visitScope(entryPath);
|
|
124
|
+
else await visitPackage(entryPath);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
await visitNodeModules(nodeModulesDirectory);
|
|
128
|
+
return records;
|
|
129
|
+
}
|
|
130
|
+
async function resolveAliasTarget(ownerDirectory, alias, outputDirectory) {
|
|
131
|
+
let directory = ownerDirectory;
|
|
132
|
+
const outputRoot = external_node_path_default().resolve(outputDirectory);
|
|
133
|
+
const resolvedOutputRoot = await promises_default().realpath(outputRoot);
|
|
134
|
+
while(directory === outputRoot || directory.startsWith(`${outputRoot}${external_node_path_default().sep}`)){
|
|
135
|
+
const candidate = external_node_path_default().join(directory, 'node_modules', alias.targetName);
|
|
136
|
+
try {
|
|
137
|
+
const resolvedCandidate = await promises_default().realpath(candidate);
|
|
138
|
+
if (resolvedCandidate !== resolvedOutputRoot && !resolvedCandidate.startsWith(`${resolvedOutputRoot}${external_node_path_default().sep}`)) throw new Error(`Cannot preserve npm alias ${alias.aliasName}: emitted target ${candidate} resolves outside deployment output to ${resolvedCandidate}`);
|
|
139
|
+
const packageJson = await readPackageJson(external_node_path_default().join(candidate, 'package.json'));
|
|
140
|
+
if (packageJson.name !== alias.targetName || !packageJson.version) throw new Error(`npm alias ${alias.aliasName} resolved ${candidate} to unexpected package ${String(packageJson.name)}`);
|
|
141
|
+
if (exactVersionPattern.test(alias.targetVersion) && packageJson.version !== alias.targetVersion) return;
|
|
142
|
+
return {
|
|
143
|
+
directory: candidate,
|
|
144
|
+
packageJson
|
|
145
|
+
};
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if ('ENOENT' !== error.code) throw error;
|
|
148
|
+
}
|
|
149
|
+
if (directory === outputRoot) break;
|
|
150
|
+
directory = external_node_path_default().dirname(directory);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function ensureAliasLink(ownerDirectory, alias, target) {
|
|
154
|
+
const aliasPath = external_node_path_default().join(ownerDirectory, 'node_modules', alias.aliasName);
|
|
155
|
+
await promises_default().mkdir(external_node_path_default().dirname(aliasPath), {
|
|
156
|
+
recursive: true
|
|
157
|
+
});
|
|
158
|
+
try {
|
|
159
|
+
const [existing, expected] = await Promise.all([
|
|
160
|
+
promises_default().realpath(aliasPath),
|
|
161
|
+
promises_default().realpath(target.directory)
|
|
162
|
+
]);
|
|
163
|
+
if (existing === expected) return;
|
|
164
|
+
throw new Error(`Cannot preserve npm alias ${alias.aliasName}: ${aliasPath} already resolves to ${existing}, expected ${expected}`);
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if ('ENOENT' !== error.code) throw error;
|
|
167
|
+
}
|
|
168
|
+
const linkTarget = external_node_path_default().relative(external_node_path_default().dirname(aliasPath), target.directory);
|
|
169
|
+
await promises_default().symlink(linkTarget, aliasPath, 'dir');
|
|
170
|
+
}
|
|
171
|
+
function aliasSpecifier(alias) {
|
|
172
|
+
return `npm:${alias.targetName}@${alias.targetVersion}`;
|
|
173
|
+
}
|
|
174
|
+
async function readPackageIdentity(entryPath) {
|
|
175
|
+
let directory = external_node_path_default().dirname(entryPath);
|
|
176
|
+
const root = external_node_path_default().parse(directory).root;
|
|
177
|
+
while(directory !== root){
|
|
178
|
+
try {
|
|
179
|
+
const packageJson = await readPackageJson(external_node_path_default().join(directory, 'package.json'));
|
|
180
|
+
if (packageJson.name && packageJson.version) return {
|
|
181
|
+
name: packageJson.name,
|
|
182
|
+
version: packageJson.version
|
|
183
|
+
};
|
|
184
|
+
} catch (error) {
|
|
185
|
+
if ('ENOENT' !== error.code) throw error;
|
|
186
|
+
}
|
|
187
|
+
directory = external_node_path_default().dirname(directory);
|
|
188
|
+
}
|
|
189
|
+
throw new Error(`Cannot find owning package for deployment entry ${entryPath}`);
|
|
190
|
+
}
|
|
191
|
+
async function preserveNpmAliases({ appDirectory, outputDirectory, implicitAliases = [] }) {
|
|
192
|
+
const records = await collectPackageRecords(external_node_path_default().join(outputDirectory, 'node_modules'));
|
|
193
|
+
const appPackageJson = await readPackageJson(external_node_path_default().join(appDirectory, 'package.json'));
|
|
194
|
+
const rootAliases = [
|
|
195
|
+
...aliasesFromPackageJson(appPackageJson),
|
|
196
|
+
...implicitAliases
|
|
197
|
+
].filter((alias)=>alias.aliasName !== alias.targetName);
|
|
198
|
+
const emittedRootAliases = [];
|
|
199
|
+
for (const alias of rootAliases){
|
|
200
|
+
const target = await resolveAliasTarget(outputDirectory, alias, outputDirectory);
|
|
201
|
+
if (!target) {
|
|
202
|
+
if (implicitAliases.includes(alias)) throw new Error(`Cannot preserve implicit npm alias ${alias.aliasName}: emitted target ${alias.targetName}@${alias.targetVersion} is missing`);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
await ensureAliasLink(outputDirectory, alias, target);
|
|
206
|
+
emittedRootAliases.push(alias);
|
|
207
|
+
}
|
|
208
|
+
for (const record of records)for (const alias of aliasesFromPackageJson(record.packageJson).filter((candidate)=>candidate.aliasName !== candidate.targetName)){
|
|
209
|
+
const target = await resolveAliasTarget(record.directory, alias, outputDirectory);
|
|
210
|
+
if (target) await ensureAliasLink(record.directory, alias, target);
|
|
211
|
+
}
|
|
212
|
+
const outputPackageJsonPath = external_node_path_default().join(outputDirectory, 'package.json');
|
|
213
|
+
const outputPackageJson = await readPackageJson(outputPackageJsonPath);
|
|
214
|
+
outputPackageJson.dependencies ??= {};
|
|
215
|
+
for (const alias of emittedRootAliases)outputPackageJson.dependencies[alias.aliasName] = aliasSpecifier(alias);
|
|
216
|
+
await promises_default().writeFile(outputPackageJsonPath, `${JSON.stringify(outputPackageJson, null, 2)}\n`);
|
|
217
|
+
}
|
|
218
|
+
exports.preserveNpmAliases = __webpack_exports__.preserveNpmAliases;
|
|
219
|
+
exports.readPackageIdentity = __webpack_exports__.readPackageIdentity;
|
|
220
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
221
|
+
"preserveNpmAliases",
|
|
222
|
+
"readPackageIdentity"
|
|
223
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
224
|
+
Object.defineProperty(exports, '__esModule', {
|
|
225
|
+
value: true
|
|
226
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
createDeployOutputAliasesPlugin: ()=>createDeployOutputAliasesPlugin
|
|
41
|
+
});
|
|
42
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
43
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
44
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
45
|
+
const external_npmAliases_js_namespaceObject = require("./npmAliases.js");
|
|
46
|
+
const external_target_js_namespaceObject = require("./target.js");
|
|
47
|
+
const createDeployOutputAliasesPlugin = ({ resolveDeployTarget = external_target_js_namespaceObject.resolveDeployTarget } = {})=>({
|
|
48
|
+
name: '@modern-js/deploy-output-aliases',
|
|
49
|
+
setup (api) {
|
|
50
|
+
api.onAfterDeploy(async ()=>{
|
|
51
|
+
const { appDirectory, metaName } = api.getAppContext();
|
|
52
|
+
const config = api.getNormalizedConfig();
|
|
53
|
+
if ('modern-js' !== metaName && !config.deploy?.target && !process.env.MODERNJS_DEPLOY || 'node' !== resolveDeployTarget(config)) return;
|
|
54
|
+
const entry = (0, external_node_module_namespaceObject.createRequire)(__filename).resolve('@modern-js/prod-server');
|
|
55
|
+
const identity = await (0, external_npmAliases_js_namespaceObject.readPackageIdentity)(entry);
|
|
56
|
+
await (0, external_npmAliases_js_namespaceObject.preserveNpmAliases)({
|
|
57
|
+
appDirectory,
|
|
58
|
+
outputDirectory: external_node_path_default().join(appDirectory, '.output'),
|
|
59
|
+
implicitAliases: [
|
|
60
|
+
{
|
|
61
|
+
aliasName: '@modern-js/prod-server',
|
|
62
|
+
targetName: identity.name,
|
|
63
|
+
targetVersion: identity.version
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
exports.createDeployOutputAliasesPlugin = __webpack_exports__.createDeployOutputAliasesPlugin;
|
|
71
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
72
|
+
"createDeployOutputAliasesPlugin"
|
|
73
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
74
|
+
Object.defineProperty(exports, '__esModule', {
|
|
75
|
+
value: true
|
|
76
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
resolveDeployTarget: ()=>resolveDeployTarget
|
|
32
|
+
});
|
|
33
|
+
const external_std_env_namespaceObject = require("std-env");
|
|
34
|
+
const providerDeployTargets = {
|
|
35
|
+
vercel: 'vercel',
|
|
36
|
+
netlify: 'netlify',
|
|
37
|
+
cloudflare: 'cloudflare',
|
|
38
|
+
cloudflare_pages: 'cloudflare',
|
|
39
|
+
cloudflare_workers: 'cloudflare'
|
|
40
|
+
};
|
|
41
|
+
const resolveDeployTarget = (config, envDeployTarget = process.env.MODERNJS_DEPLOY, detectedProvider = external_std_env_namespaceObject.provider)=>config.deploy?.target || envDeployTarget || (detectedProvider ? providerDeployTargets[detectedProvider] : void 0) || 'node';
|
|
42
|
+
exports.resolveDeployTarget = __webpack_exports__.resolveDeployTarget;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"resolveDeployTarget"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -41,11 +41,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
41
41
|
configureUltramodernTypeChecker: ()=>configureUltramodernTypeChecker
|
|
42
42
|
});
|
|
43
43
|
const external_node_child_process_namespaceObject = require("node:child_process");
|
|
44
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
44
45
|
const external_node_path_namespaceObject = require("node:path");
|
|
45
46
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
46
47
|
const external_node_util_namespaceObject = require("node:util");
|
|
47
48
|
const execute = (0, external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile);
|
|
48
49
|
const native_type_checker_name = 'UltramodernNativeTypeChecker';
|
|
50
|
+
const watchDependencyPath = (file)=>'win32' === process.platform ? external_node_fs_namespaceObject.realpathSync.native(file) : file;
|
|
49
51
|
class UltramodernNativeTypeChecker {
|
|
50
52
|
async check() {
|
|
51
53
|
const { configFile, build } = this.options;
|
|
@@ -73,7 +75,8 @@ class UltramodernNativeTypeChecker {
|
|
|
73
75
|
return result.stdout;
|
|
74
76
|
} catch (cause) {
|
|
75
77
|
const output = cause;
|
|
76
|
-
|
|
78
|
+
const diagnostics = `${output.stdout ?? ''}${output.stderr ?? ''}`;
|
|
79
|
+
throw new Error(`${native_type_checker_name} failed:\n${diagnostics || (cause instanceof Error ? cause.message : String(cause))}`, {
|
|
77
80
|
cause
|
|
78
81
|
});
|
|
79
82
|
}
|
|
@@ -104,10 +107,10 @@ class UltramodernNativeTypeChecker {
|
|
|
104
107
|
}
|
|
105
108
|
apply(compiler) {
|
|
106
109
|
compiler.hooks.thisCompilation.tap(native_type_checker_name, (compilation)=>{
|
|
107
|
-
compilation.fileDependencies.add(this.options.configFile);
|
|
108
110
|
compilation.hooks.processAssets.tapPromise(native_type_checker_name, async ()=>{
|
|
109
111
|
try {
|
|
110
|
-
|
|
112
|
+
compilation.fileDependencies.add(watchDependencyPath(this.options.configFile));
|
|
113
|
+
for (const file of (await this.watchInputs()))compilation.fileDependencies.add(watchDependencyPath(file));
|
|
111
114
|
await this.check();
|
|
112
115
|
} catch (cause) {
|
|
113
116
|
compilation.errors.push(new Error(cause instanceof Error ? cause.message : String(cause), {
|
|
@@ -53,7 +53,7 @@ const promises_namespaceObject = require("node:fs/promises");
|
|
|
53
53
|
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
54
54
|
const external_node_path_namespaceObject = require("node:path");
|
|
55
55
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
56
|
-
const
|
|
56
|
+
const backend_federation_contracts_namespaceObject = require("@modern-js/backend-federation-contracts");
|
|
57
57
|
const external_index_js_namespaceObject = require("./index.js");
|
|
58
58
|
const MICROVERTICAL_RELEASE_ENVELOPE_PATH = 'release/microvertical-release-envelope.json';
|
|
59
59
|
const MICROVERTICAL_RELEASE_IDENTITY_CARRIERS_PATH = 'release/microvertical-release-identity-carriers.json';
|
|
@@ -176,9 +176,9 @@ const writeReleaseEnvelope = async (artifactRoot, envelope)=>{
|
|
|
176
176
|
await promises_default().writeFile(envelopePath, `${(0, external_index_js_namespaceObject.canonicalSerializeMicroVerticalReleaseEnvelope)(envelope)}\n`);
|
|
177
177
|
};
|
|
178
178
|
const readBuildArtifact = async (distDirectory)=>{
|
|
179
|
-
const artifactPath = external_node_path_default().join(distDirectory,
|
|
179
|
+
const artifactPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE);
|
|
180
180
|
const artifact = await readJson(artifactPath);
|
|
181
|
-
if (!(0,
|
|
181
|
+
if (!(0, backend_federation_contracts_namespaceObject.isUltramodernBuildArtifact)(artifact)) throw new Error(`[ultramodern-release-envelope] ${backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE} is missing or invalid.`);
|
|
182
182
|
if ('workspace' === artifact.deliveryUnit.sourceRevision) throw new Error('[ultramodern-release-envelope] sourceRevision "workspace" cannot produce a promotable full-stack envelope.');
|
|
183
183
|
return artifact;
|
|
184
184
|
};
|
|
@@ -195,7 +195,7 @@ const assertIdentityBlock = (value, identity, location, includeReleaseVersion)=>
|
|
|
195
195
|
for (const [field, expectedValue] of Object.entries(expected))if (value[field] !== expectedValue) throw new Error(`[ultramodern-release-envelope] ${location}.${field} must match ${expectedValue}; received ${String(value[field])}.`);
|
|
196
196
|
};
|
|
197
197
|
const readBackendManifest = async (distDirectory, identity)=>{
|
|
198
|
-
const manifest = await readJson(external_node_path_default().join(distDirectory,
|
|
198
|
+
const manifest = await readJson(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE));
|
|
199
199
|
if (!isRecord(manifest) || !isRecord(manifest.backendFederation)) throw new Error('[ultramodern-release-envelope] backend federation manifest is missing backendFederation metadata.');
|
|
200
200
|
assertIdentityBlock(manifest.backendFederation.deliveryUnit, identity, 'backendFederation.deliveryUnit', true);
|
|
201
201
|
const versionBoundary = manifest.backendFederation.versionBoundary;
|
|
@@ -324,10 +324,10 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
324
324
|
add(ssrPaths, 'node' === target ? 'nodejs' : 'workerd');
|
|
325
325
|
add(apiBackendPaths, 'node' === target ? 'nodejs' : 'workerd-effect');
|
|
326
326
|
add([
|
|
327
|
-
|
|
327
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE
|
|
328
328
|
], 'module-federation-manifest');
|
|
329
329
|
add([
|
|
330
|
-
|
|
330
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
331
331
|
], 'node' === target ? 'nodejs' : 'commonjs-module');
|
|
332
332
|
const surfaces = {
|
|
333
333
|
uiClient: [
|
|
@@ -340,8 +340,8 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
340
340
|
...apiBackendPaths
|
|
341
341
|
].sort((left, right)=>left.localeCompare(right)),
|
|
342
342
|
backendFederation: {
|
|
343
|
-
manifest:
|
|
344
|
-
container:
|
|
343
|
+
manifest: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
344
|
+
container: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
const artifacts = [
|
|
@@ -350,8 +350,8 @@ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
|
|
|
350
350
|
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(distDirectory, identity, {
|
|
351
351
|
apiBackend: apiBackendPaths,
|
|
352
352
|
backendFederation: [
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
354
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
355
355
|
],
|
|
356
356
|
ssr: [
|
|
357
357
|
...new Set([
|
|
@@ -379,8 +379,8 @@ const pathExists = async (filePath)=>{
|
|
|
379
379
|
};
|
|
380
380
|
const emitFrameworkMicroVerticalReleaseEnvelope = async ({ apiOnly, distDirectory, target })=>{
|
|
381
381
|
if (apiOnly) return;
|
|
382
|
-
const backendManifestPath = external_node_path_default().join(distDirectory,
|
|
383
|
-
const backendContainerPath = external_node_path_default().join(distDirectory,
|
|
382
|
+
const backendManifestPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE);
|
|
383
|
+
const backendContainerPath = external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
|
|
384
384
|
const [hasBackendManifest, hasBackendContainer] = await Promise.all([
|
|
385
385
|
pathExists(backendManifestPath),
|
|
386
386
|
pathExists(backendContainerPath)
|
|
@@ -428,9 +428,9 @@ const readFrameworkMicroVerticalReleaseEnvelope = async ({ artifactRoot, expecte
|
|
|
428
428
|
const verifyBuildOutputReleaseEnvelope = async (distDirectory, expectedTarget)=>{
|
|
429
429
|
const [hasEnvelope, hasBuildArtifact, hasBackendManifest, hasBackendEntry] = await Promise.all([
|
|
430
430
|
pathExists(external_node_path_default().join(distDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH)),
|
|
431
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
432
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
433
|
-
pathExists(external_node_path_default().join(distDirectory,
|
|
431
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.ULTRAMODERN_BUILD_ARTIFACT_FILE)),
|
|
432
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE)),
|
|
433
|
+
pathExists(external_node_path_default().join(distDirectory, backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE))
|
|
434
434
|
]);
|
|
435
435
|
const isFullStackMicroVertical = hasBuildArtifact && (hasBackendManifest || hasBackendEntry);
|
|
436
436
|
return readFrameworkMicroVerticalReleaseEnvelope({
|
|
@@ -451,12 +451,12 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
451
451
|
for (const requiredPath of [
|
|
452
452
|
'index.js',
|
|
453
453
|
'package.json',
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
455
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
456
456
|
])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Node staging is missing ${requiredPath}.`);
|
|
457
457
|
const backendFederationPaths = new Set([
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
459
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
460
460
|
]);
|
|
461
461
|
const uiClientPaths = files.filter((logicalPath)=>{
|
|
462
462
|
const topLevel = logicalPath.split('/')[0];
|
|
@@ -495,13 +495,13 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
495
495
|
for (const logicalPath of uiClientPaths)runtimeByPath.set(logicalPath, 'browser');
|
|
496
496
|
for (const logicalPath of ssrPaths)runtimeByPath.set(logicalPath, 'nodejs');
|
|
497
497
|
for (const logicalPath of apiBackendPaths)runtimeByPath.set(logicalPath, 'nodejs');
|
|
498
|
-
runtimeByPath.set(
|
|
499
|
-
runtimeByPath.set(
|
|
498
|
+
runtimeByPath.set(backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE, 'module-federation-manifest');
|
|
499
|
+
runtimeByPath.set(backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE, 'nodejs');
|
|
500
500
|
const identityCarrierMetadata = await writeReleaseIdentityCarrierMetadata(outputDirectory, identity, {
|
|
501
501
|
apiBackend: apiBackendPaths,
|
|
502
502
|
backendFederation: [
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
504
|
+
backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
505
505
|
],
|
|
506
506
|
ssr: [
|
|
507
507
|
...new Set([
|
|
@@ -529,8 +529,8 @@ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=
|
|
|
529
529
|
...apiBackendPaths
|
|
530
530
|
].sort((left, right)=>left.localeCompare(right)),
|
|
531
531
|
backendFederation: {
|
|
532
|
-
manifest:
|
|
533
|
-
container:
|
|
532
|
+
manifest: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE,
|
|
533
|
+
container: backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
};
|
|
@@ -566,8 +566,8 @@ const createCloudflareStagedReleaseArtifactInputs = async (outputDirectory, iden
|
|
|
566
566
|
'worker/package.json'
|
|
567
567
|
])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging is missing ${requiredPath}.`);
|
|
568
568
|
if (files.some((logicalPath)=>'public/release' === logicalPath || logicalPath.startsWith('public/release/'))) throw new Error('[ultramodern-release-envelope] final Cloudflare envelope must remain private and cannot be staged under public/release.');
|
|
569
|
-
const backendManifestPath = `public/${
|
|
570
|
-
const backendContainerPath = `public/${
|
|
569
|
+
const backendManifestPath = `public/${backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_MANIFEST_FILE}`;
|
|
570
|
+
const backendContainerPath = `public/${backend_federation_contracts_namespaceObject.BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`;
|
|
571
571
|
const apiBackendPaths = files.filter((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
|
|
572
572
|
const ssrPaths = files.filter((logicalPath)=>(logicalPath.startsWith('server/') || logicalPath.startsWith('worker/')) && COMPILED_MODULE_PATTERN.test(logicalPath) && !EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
|
|
573
573
|
const uiClientPaths = files.filter((logicalPath)=>logicalPath.startsWith('public/') && logicalPath !== backendManifestPath && logicalPath !== backendContainerPath);
|
|
@@ -52,7 +52,8 @@ const createUltramodernReleaseEnvelopePlugin = ({ resolveDeployTarget })=>({
|
|
|
52
52
|
name: '@modern-js/ultramodern-release-envelope',
|
|
53
53
|
pre: [
|
|
54
54
|
'@modern-js/backend-federation-build',
|
|
55
|
-
'@modern-js/plugin-bff'
|
|
55
|
+
'@modern-js/plugin-bff',
|
|
56
|
+
'@modern-js/deploy-output-aliases'
|
|
56
57
|
],
|
|
57
58
|
post: [
|
|
58
59
|
'@modern-js/plugin-deploy'
|