@emailmaker/emailmaker 1.1.31 → 1.1.36
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/{emailmaker-core.25e2342b.js → emailmaker-core.4a2946bd.js} +1 -1
- package/emailmaker-esm.js +17 -6
- package/emailmaker.d.ts +9 -2
- package/emailmaker.js +176 -12
- package/iframe/js/amp.DieSnBUu.js +1 -0
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.CNqvmp_P.js +1 -1
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{76f5295d.js → 369b60a1.js} +1 -1
- package/static/core/{13ca3f502.js → 539179022.js} +1 -1
- package/static/core/548145dc.js +3 -0
- package/static/core/{4686eabe.js → 61af40b8.js} +3 -3
- package/static/core/{cc38c423.js → 6d27d0a8.js} +2 -2
- package/static/core/77441b5e.js +51 -0
- package/static/core/{25d26369.js → 7865066d.js} +2 -2
- package/static/core/8f709c0d.js +1 -0
- package/static/core/{ca58f6cf.js → a73f6ffb.js} +1 -1
- package/static/core/{bfefb58d.js → af40ecaa.js} +2 -2
- package/static/core/{d06bc0bd.js → b6d3de9a.js} +50 -50
- package/static/core/{91634ef3.js → ba40f70e.js} +1 -1
- package/static/core/bc0b6b3f.js +78 -0
- package/static/core/{df4b4fe2.js → d856ee32.js} +2 -2
- package/static/core/{1da27b3c.js → e5d13a1c.js} +1 -1
- package/static/core/{558afaa1.js → ef4e808c.js} +1 -1
- package/static/core/{e37f6763.js → f47646dc.js} +2 -2
- package/static/core/{e4ba0190.js → fc5712ae.js} +1 -1
- package/static/esm/533d7587.js +1 -0
- package/two_step_headless_plugin.html +1 -1
- package/vite/index.cjs +109 -18
- package/vite/index.js +109 -18
- package/webpack/index.cjs +108 -11
- package/webpack/index.js +108 -11
- package/iframe/js/amp.BLBsfH3J.js +0 -1
- package/static/core/3c291097.js +0 -78
- package/static/core/62c48605.js +0 -3
- package/static/core/8a188b85.js +0 -51
- package/static/core/8aba252b.js +0 -1
- /package/iframe/{iframe-eblock.25e2342b.html → iframe-eblock.4a2946bd.html} +0 -0
- /package/iframe/{iframe.25e2342b.html → iframe.4a2946bd.html} +0 -0
package/webpack/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ let path = require("path");
|
|
|
24
24
|
path = __toESM(path);
|
|
25
25
|
let fs = require("fs");
|
|
26
26
|
fs = __toESM(fs);
|
|
27
|
+
let module$1 = require("module");
|
|
27
28
|
//#region src/shared/stringCase.ts
|
|
28
29
|
function toPascalCase(str) {
|
|
29
30
|
return `${str}`.toLowerCase().replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(/\s+(.)(\w*)/g, (_m, a, b) => `${a.toUpperCase()}${b}`).replace(/\w/, (s) => s.toUpperCase());
|
|
@@ -42,6 +43,11 @@ function toPascalCase(str) {
|
|
|
42
43
|
* (`/product` -> `/product/`, resolved against the host `document.baseURI`).
|
|
43
44
|
* - With `publicPath`: `http://host:3032` + `/product` -> `http://host:3032/product/`.
|
|
44
45
|
*/
|
|
46
|
+
function normalizeHostBundlerPublicPath(publicPath) {
|
|
47
|
+
const value = String(publicPath ?? "").trim();
|
|
48
|
+
if (!value || value === "auto" || value === "automatic") return "";
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
45
51
|
function joinHostPublicPath(publicPath, outputFolder, defaultOutputFolder) {
|
|
46
52
|
const folder = outputFolder != null && outputFolder !== "" ? String(outputFolder) : defaultOutputFolder;
|
|
47
53
|
const base = String(publicPath || "").replace(/\/+$/, "");
|
|
@@ -84,12 +90,29 @@ function createInitFragment(environmentVariable, publicPath, startupPrefetchMode
|
|
|
84
90
|
`if (!window.${environmentVariable}.startupPrefetchMode) window.${environmentVariable}.startupPrefetchMode = "${startupPrefetchMode}";`
|
|
85
91
|
].join(" ");
|
|
86
92
|
}
|
|
93
|
+
function moduleSourceContainsFacadeSentinel(source) {
|
|
94
|
+
return typeof source === "string" && source.includes("@shared-runtime:init-complete");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* True when host bootstrap was already prepended (avoid double injection).
|
|
98
|
+
*
|
|
99
|
+
* Must match the host-plugin assignment shape from `createInitFragment` /
|
|
100
|
+
* `createNormalizedPublicPathAssignment`, NOT a bare `window.__ns__.publicPath`
|
|
101
|
+
* substring — publish diagnostics embed that substring inside string literals and
|
|
102
|
+
* would otherwise false-positive and block all host injection.
|
|
103
|
+
*/
|
|
104
|
+
function moduleSourceHasHostPublicPathBootstrap(source, environmentVariable) {
|
|
105
|
+
if (typeof source !== "string" || !source) return false;
|
|
106
|
+
return source.includes(`if (!window.${environmentVariable}.publicPath) window.${environmentVariable}.publicPath =`);
|
|
107
|
+
}
|
|
87
108
|
//#endregion
|
|
88
109
|
//#region src/shared/hostPackageEntryMatch.ts
|
|
89
110
|
/**
|
|
90
111
|
* Match main product entry modules for host bootstrap injection (Vite + Webpack).
|
|
91
112
|
* Uses suffix matching so absolute node_modules ids ending with `{packagePath}/{appName}-esm.js`
|
|
92
113
|
* match the same way as Webpack `renderModuleContent` (endsWith), not exact relative paths.
|
|
114
|
+
* When path matching fails (alias, wrapper re-export), falls back to publish facade sentinel
|
|
115
|
+
* in module source (`@shared-runtime:init-complete`).
|
|
93
116
|
*/
|
|
94
117
|
function normalizeHostModulePath(value) {
|
|
95
118
|
return String(value || "").replace(/#.*$/s, "").replace(/\?.*$/s, "").replace(/\\/g, "/");
|
|
@@ -111,6 +134,50 @@ function shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimize
|
|
|
111
134
|
}
|
|
112
135
|
return false;
|
|
113
136
|
}
|
|
137
|
+
function shouldPatchProductEntry(options) {
|
|
138
|
+
const { moduleId, source, packagePath, appName, optimizedDepFileName, environmentVariable } = options;
|
|
139
|
+
if (environmentVariable && moduleSourceHasHostPublicPathBootstrap(source, environmentVariable)) return false;
|
|
140
|
+
if (shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimizedDepFileName)) return true;
|
|
141
|
+
return moduleSourceContainsFacadeSentinel(source);
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/shared/resolvePublishedPackage.ts
|
|
145
|
+
/**
|
|
146
|
+
* Resolve the on-disk root of the published main package (handles pnpm hoisting / symlinks).
|
|
147
|
+
* Prefers `modulesPath/<packagePath>` under `cwd` when `package.json` exists there.
|
|
148
|
+
*/
|
|
149
|
+
function resolvePublishedPackageRoot(packagePath, modulesPath = "node_modules", cwd = process.cwd()) {
|
|
150
|
+
const modulesRoot = path.default.isAbsolute(modulesPath) ? modulesPath : path.default.join(cwd, modulesPath);
|
|
151
|
+
const localRoot = path.default.join(modulesRoot, ...packagePath.split("/"));
|
|
152
|
+
const localPackageJson = path.default.join(localRoot, "package.json");
|
|
153
|
+
if (fs.default.existsSync(localPackageJson)) return localRoot;
|
|
154
|
+
try {
|
|
155
|
+
const packageJsonPath = (0, module$1.createRequire)(path.default.join(cwd, "package.json")).resolve(`${packagePath}/package.json`);
|
|
156
|
+
return path.default.dirname(packageJsonPath);
|
|
157
|
+
} catch {
|
|
158
|
+
return localRoot;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var PublishedPackageNotFoundError = class extends Error {
|
|
162
|
+
constructor(packagePath, resolvedPath) {
|
|
163
|
+
super(`[host-plugin] Published package "${packagePath}" was not found at "${resolvedPath}". Install the product npm package or set \`modulesPath\` to the directory that contains it.`);
|
|
164
|
+
this.packagePath = packagePath;
|
|
165
|
+
this.resolvedPath = resolvedPath;
|
|
166
|
+
this.name = "PublishedPackageNotFoundError";
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function assertPublishedPackageExists(packageRoot, packagePath) {
|
|
170
|
+
if (!fs.default.existsSync(packageRoot) || !fs.default.statSync(packageRoot).isDirectory()) throw new PublishedPackageNotFoundError(packagePath, packageRoot);
|
|
171
|
+
}
|
|
172
|
+
function assertCoreChunkInCompilationAssets(assetNames, appName, outputFolder) {
|
|
173
|
+
const folderPrefix = String(outputFolder || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
174
|
+
const corePattern = new RegExp(`(^|/)${appName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-core\\.[^/]+\\.js$`);
|
|
175
|
+
if (!Array.from(assetNames).some((name) => {
|
|
176
|
+
const normalized = name.replace(/\\/g, "/");
|
|
177
|
+
if (folderPrefix && !(normalized === folderPrefix || normalized.startsWith(`${folderPrefix}/`))) return false;
|
|
178
|
+
return corePattern.test(normalized);
|
|
179
|
+
})) throw new Error(`[host-plugin] No "${appName}-core.*.js" asset was emitted under "${folderPrefix || "(output)"}" after copy. The published package may be incomplete or IGNORED_PATTERNS filtered the core chunk.`);
|
|
180
|
+
}
|
|
114
181
|
//#endregion
|
|
115
182
|
//#region src/shared/branding.ts
|
|
116
183
|
/**
|
|
@@ -158,12 +225,43 @@ function getWebpackModulePath(module) {
|
|
|
158
225
|
const name = typeof module.nameForCondition === "function" ? module.nameForCondition() : null;
|
|
159
226
|
return typeof name === "string" && name ? name : void 0;
|
|
160
227
|
}
|
|
161
|
-
function
|
|
228
|
+
function getConcatenatedInnerModules(module) {
|
|
229
|
+
const inner = module?.modules;
|
|
230
|
+
if (!inner) return [];
|
|
231
|
+
if (Array.isArray(inner)) return inner;
|
|
232
|
+
if (typeof inner[Symbol.iterator] === "function") return Array.from(inner);
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
235
|
+
function getWebpackModuleSource(source) {
|
|
236
|
+
if (typeof source === "string") return source;
|
|
162
237
|
if (source && typeof source === "object" && "source" in source && typeof source.source === "function") return source.source();
|
|
163
|
-
return
|
|
238
|
+
return "";
|
|
164
239
|
}
|
|
165
|
-
|
|
166
|
-
|
|
240
|
+
/**
|
|
241
|
+
* With `optimization.concatenateModules` (scope hoisting) `renderModuleContent` fires once for
|
|
242
|
+
* the `ConcatenatedModule`: its own `resource` is undefined and `nameForCondition`/`rootModule`
|
|
243
|
+
* point at the host entry, not the product facade. We inspect the concatenated inner modules so
|
|
244
|
+
* the publicPath bootstrap still reaches the facade (regression: enKod / Angular prod webpack).
|
|
245
|
+
* Content sentinel fallback covers alias / wrapper paths where inner module paths do not match.
|
|
246
|
+
*/
|
|
247
|
+
function shouldInjectRuntimeBootstrap(module, source) {
|
|
248
|
+
const sourceCode = getWebpackModuleSource(source);
|
|
249
|
+
if (moduleSourceHasHostPublicPathBootstrap(sourceCode, ENVIRONMENT_VARIABLE)) return false;
|
|
250
|
+
const shared = {
|
|
251
|
+
packagePath: BUNDLER_DEFAULT_PACKAGE_NAME,
|
|
252
|
+
appName: BUNDLER_DEFAULT_APP_NAME,
|
|
253
|
+
environmentVariable: ENVIRONMENT_VARIABLE
|
|
254
|
+
};
|
|
255
|
+
if (shouldPatchProductEntry({
|
|
256
|
+
moduleId: getWebpackModulePath(module) || "",
|
|
257
|
+
source: sourceCode,
|
|
258
|
+
...shared
|
|
259
|
+
})) return true;
|
|
260
|
+
return getConcatenatedInnerModules(module).some((inner) => shouldPatchProductEntry({
|
|
261
|
+
moduleId: getWebpackModulePath(inner) || "",
|
|
262
|
+
source: void 0,
|
|
263
|
+
...shared
|
|
264
|
+
}));
|
|
167
265
|
}
|
|
168
266
|
/**
|
|
169
267
|
* Webpack plugin for host applications.
|
|
@@ -208,7 +306,7 @@ var WebpackPlugin = class {
|
|
|
208
306
|
apply(compiler) {
|
|
209
307
|
const rawPub = compiler.options.output.publicPath;
|
|
210
308
|
const optionsPublicPath = typeof rawPub === "string" ? rawPub : "";
|
|
211
|
-
const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath, this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
|
|
309
|
+
const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(normalizeHostBundlerPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath), this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
|
|
212
310
|
const webpack = compiler.webpack;
|
|
213
311
|
const javascript = webpack.javascript;
|
|
214
312
|
this._sources = webpack.sources;
|
|
@@ -218,18 +316,17 @@ var WebpackPlugin = class {
|
|
|
218
316
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
|
|
219
317
|
}, async (_unusedAssets, cb) => {
|
|
220
318
|
try {
|
|
221
|
-
|
|
319
|
+
const packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, this._modulesPath, compilation.compiler.context);
|
|
320
|
+
assertPublishedPackageExists(packageRoot, BUNDLER_DEFAULT_PACKAGE_NAME);
|
|
321
|
+
await this.copyFiles(compilation, packageRoot, this._outputFolder);
|
|
322
|
+
assertCoreChunkInCompilationAssets(compilation.getAssets().map((asset) => asset.name), BUNDLER_DEFAULT_APP_NAME, toAssetPath(this._outputFolder));
|
|
222
323
|
cb(null);
|
|
223
324
|
} catch (error) {
|
|
224
325
|
cb(error);
|
|
225
326
|
}
|
|
226
327
|
});
|
|
227
328
|
javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderModuleContent.tap(PLUGIN_NAME, (source, module) => {
|
|
228
|
-
if (shouldInjectRuntimeBootstrap(
|
|
229
|
-
const sources = this._sources || compilation.compiler.webpack.sources;
|
|
230
|
-
const patched = `${initFragment}\n${getModuleSourceCode(source)}`;
|
|
231
|
-
return new sources.RawSource(patched);
|
|
232
|
-
}
|
|
329
|
+
if (shouldInjectRuntimeBootstrap(module, source)) return new (this._sources || compilation.compiler.webpack.sources).ConcatSource(`${initFragment}\n`, source);
|
|
233
330
|
return source;
|
|
234
331
|
});
|
|
235
332
|
});
|
package/webpack/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
+
import { createRequire } from "module";
|
|
3
4
|
//#region src/shared/stringCase.ts
|
|
4
5
|
function toPascalCase(str) {
|
|
5
6
|
return `${str}`.toLowerCase().replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(/\s+(.)(\w*)/g, (_m, a, b) => `${a.toUpperCase()}${b}`).replace(/\w/, (s) => s.toUpperCase());
|
|
@@ -18,6 +19,11 @@ function toPascalCase(str) {
|
|
|
18
19
|
* (`/product` -> `/product/`, resolved against the host `document.baseURI`).
|
|
19
20
|
* - With `publicPath`: `http://host:3032` + `/product` -> `http://host:3032/product/`.
|
|
20
21
|
*/
|
|
22
|
+
function normalizeHostBundlerPublicPath(publicPath) {
|
|
23
|
+
const value = String(publicPath ?? "").trim();
|
|
24
|
+
if (!value || value === "auto" || value === "automatic") return "";
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
21
27
|
function joinHostPublicPath(publicPath, outputFolder, defaultOutputFolder) {
|
|
22
28
|
const folder = outputFolder != null && outputFolder !== "" ? String(outputFolder) : defaultOutputFolder;
|
|
23
29
|
const base = String(publicPath || "").replace(/\/+$/, "");
|
|
@@ -60,12 +66,29 @@ function createInitFragment(environmentVariable, publicPath, startupPrefetchMode
|
|
|
60
66
|
`if (!window.${environmentVariable}.startupPrefetchMode) window.${environmentVariable}.startupPrefetchMode = "${startupPrefetchMode}";`
|
|
61
67
|
].join(" ");
|
|
62
68
|
}
|
|
69
|
+
function moduleSourceContainsFacadeSentinel(source) {
|
|
70
|
+
return typeof source === "string" && source.includes("@shared-runtime:init-complete");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* True when host bootstrap was already prepended (avoid double injection).
|
|
74
|
+
*
|
|
75
|
+
* Must match the host-plugin assignment shape from `createInitFragment` /
|
|
76
|
+
* `createNormalizedPublicPathAssignment`, NOT a bare `window.__ns__.publicPath`
|
|
77
|
+
* substring — publish diagnostics embed that substring inside string literals and
|
|
78
|
+
* would otherwise false-positive and block all host injection.
|
|
79
|
+
*/
|
|
80
|
+
function moduleSourceHasHostPublicPathBootstrap(source, environmentVariable) {
|
|
81
|
+
if (typeof source !== "string" || !source) return false;
|
|
82
|
+
return source.includes(`if (!window.${environmentVariable}.publicPath) window.${environmentVariable}.publicPath =`);
|
|
83
|
+
}
|
|
63
84
|
//#endregion
|
|
64
85
|
//#region src/shared/hostPackageEntryMatch.ts
|
|
65
86
|
/**
|
|
66
87
|
* Match main product entry modules for host bootstrap injection (Vite + Webpack).
|
|
67
88
|
* Uses suffix matching so absolute node_modules ids ending with `{packagePath}/{appName}-esm.js`
|
|
68
89
|
* match the same way as Webpack `renderModuleContent` (endsWith), not exact relative paths.
|
|
90
|
+
* When path matching fails (alias, wrapper re-export), falls back to publish facade sentinel
|
|
91
|
+
* in module source (`@shared-runtime:init-complete`).
|
|
69
92
|
*/
|
|
70
93
|
function normalizeHostModulePath(value) {
|
|
71
94
|
return String(value || "").replace(/#.*$/s, "").replace(/\?.*$/s, "").replace(/\\/g, "/");
|
|
@@ -87,6 +110,50 @@ function shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimize
|
|
|
87
110
|
}
|
|
88
111
|
return false;
|
|
89
112
|
}
|
|
113
|
+
function shouldPatchProductEntry(options) {
|
|
114
|
+
const { moduleId, source, packagePath, appName, optimizedDepFileName, environmentVariable } = options;
|
|
115
|
+
if (environmentVariable && moduleSourceHasHostPublicPathBootstrap(source, environmentVariable)) return false;
|
|
116
|
+
if (shouldMatchProductPackageEntry(moduleId, packagePath, appName, optimizedDepFileName)) return true;
|
|
117
|
+
return moduleSourceContainsFacadeSentinel(source);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/shared/resolvePublishedPackage.ts
|
|
121
|
+
/**
|
|
122
|
+
* Resolve the on-disk root of the published main package (handles pnpm hoisting / symlinks).
|
|
123
|
+
* Prefers `modulesPath/<packagePath>` under `cwd` when `package.json` exists there.
|
|
124
|
+
*/
|
|
125
|
+
function resolvePublishedPackageRoot(packagePath, modulesPath = "node_modules", cwd = process.cwd()) {
|
|
126
|
+
const modulesRoot = path.isAbsolute(modulesPath) ? modulesPath : path.join(cwd, modulesPath);
|
|
127
|
+
const localRoot = path.join(modulesRoot, ...packagePath.split("/"));
|
|
128
|
+
const localPackageJson = path.join(localRoot, "package.json");
|
|
129
|
+
if (fs.existsSync(localPackageJson)) return localRoot;
|
|
130
|
+
try {
|
|
131
|
+
const packageJsonPath = createRequire(path.join(cwd, "package.json")).resolve(`${packagePath}/package.json`);
|
|
132
|
+
return path.dirname(packageJsonPath);
|
|
133
|
+
} catch {
|
|
134
|
+
return localRoot;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
var PublishedPackageNotFoundError = class extends Error {
|
|
138
|
+
constructor(packagePath, resolvedPath) {
|
|
139
|
+
super(`[host-plugin] Published package "${packagePath}" was not found at "${resolvedPath}". Install the product npm package or set \`modulesPath\` to the directory that contains it.`);
|
|
140
|
+
this.packagePath = packagePath;
|
|
141
|
+
this.resolvedPath = resolvedPath;
|
|
142
|
+
this.name = "PublishedPackageNotFoundError";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
function assertPublishedPackageExists(packageRoot, packagePath) {
|
|
146
|
+
if (!fs.existsSync(packageRoot) || !fs.statSync(packageRoot).isDirectory()) throw new PublishedPackageNotFoundError(packagePath, packageRoot);
|
|
147
|
+
}
|
|
148
|
+
function assertCoreChunkInCompilationAssets(assetNames, appName, outputFolder) {
|
|
149
|
+
const folderPrefix = String(outputFolder || "").replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
150
|
+
const corePattern = new RegExp(`(^|/)${appName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}-core\\.[^/]+\\.js$`);
|
|
151
|
+
if (!Array.from(assetNames).some((name) => {
|
|
152
|
+
const normalized = name.replace(/\\/g, "/");
|
|
153
|
+
if (folderPrefix && !(normalized === folderPrefix || normalized.startsWith(`${folderPrefix}/`))) return false;
|
|
154
|
+
return corePattern.test(normalized);
|
|
155
|
+
})) throw new Error(`[host-plugin] No "${appName}-core.*.js" asset was emitted under "${folderPrefix || "(output)"}" after copy. The published package may be incomplete or IGNORED_PATTERNS filtered the core chunk.`);
|
|
156
|
+
}
|
|
90
157
|
//#endregion
|
|
91
158
|
//#region src/shared/branding.ts
|
|
92
159
|
/**
|
|
@@ -134,12 +201,43 @@ function getWebpackModulePath(module) {
|
|
|
134
201
|
const name = typeof module.nameForCondition === "function" ? module.nameForCondition() : null;
|
|
135
202
|
return typeof name === "string" && name ? name : void 0;
|
|
136
203
|
}
|
|
137
|
-
function
|
|
204
|
+
function getConcatenatedInnerModules(module) {
|
|
205
|
+
const inner = module?.modules;
|
|
206
|
+
if (!inner) return [];
|
|
207
|
+
if (Array.isArray(inner)) return inner;
|
|
208
|
+
if (typeof inner[Symbol.iterator] === "function") return Array.from(inner);
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
function getWebpackModuleSource(source) {
|
|
212
|
+
if (typeof source === "string") return source;
|
|
138
213
|
if (source && typeof source === "object" && "source" in source && typeof source.source === "function") return source.source();
|
|
139
|
-
return
|
|
214
|
+
return "";
|
|
140
215
|
}
|
|
141
|
-
|
|
142
|
-
|
|
216
|
+
/**
|
|
217
|
+
* With `optimization.concatenateModules` (scope hoisting) `renderModuleContent` fires once for
|
|
218
|
+
* the `ConcatenatedModule`: its own `resource` is undefined and `nameForCondition`/`rootModule`
|
|
219
|
+
* point at the host entry, not the product facade. We inspect the concatenated inner modules so
|
|
220
|
+
* the publicPath bootstrap still reaches the facade (regression: enKod / Angular prod webpack).
|
|
221
|
+
* Content sentinel fallback covers alias / wrapper paths where inner module paths do not match.
|
|
222
|
+
*/
|
|
223
|
+
function shouldInjectRuntimeBootstrap(module, source) {
|
|
224
|
+
const sourceCode = getWebpackModuleSource(source);
|
|
225
|
+
if (moduleSourceHasHostPublicPathBootstrap(sourceCode, ENVIRONMENT_VARIABLE)) return false;
|
|
226
|
+
const shared = {
|
|
227
|
+
packagePath: BUNDLER_DEFAULT_PACKAGE_NAME,
|
|
228
|
+
appName: BUNDLER_DEFAULT_APP_NAME,
|
|
229
|
+
environmentVariable: ENVIRONMENT_VARIABLE
|
|
230
|
+
};
|
|
231
|
+
if (shouldPatchProductEntry({
|
|
232
|
+
moduleId: getWebpackModulePath(module) || "",
|
|
233
|
+
source: sourceCode,
|
|
234
|
+
...shared
|
|
235
|
+
})) return true;
|
|
236
|
+
return getConcatenatedInnerModules(module).some((inner) => shouldPatchProductEntry({
|
|
237
|
+
moduleId: getWebpackModulePath(inner) || "",
|
|
238
|
+
source: void 0,
|
|
239
|
+
...shared
|
|
240
|
+
}));
|
|
143
241
|
}
|
|
144
242
|
/**
|
|
145
243
|
* Webpack plugin for host applications.
|
|
@@ -184,7 +282,7 @@ var WebpackPlugin = class {
|
|
|
184
282
|
apply(compiler) {
|
|
185
283
|
const rawPub = compiler.options.output.publicPath;
|
|
186
284
|
const optionsPublicPath = typeof rawPub === "string" ? rawPub : "";
|
|
187
|
-
const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath, this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
|
|
285
|
+
const initFragment = createInitFragment(ENVIRONMENT_VARIABLE, joinHostPublicPath(normalizeHostBundlerPublicPath(this._publicPath === void 0 ? optionsPublicPath : this._publicPath), this._outputFolder, DEFAULT_OUTPUT_FOLDER), this._startupPrefetchMode);
|
|
188
286
|
const webpack = compiler.webpack;
|
|
189
287
|
const javascript = webpack.javascript;
|
|
190
288
|
this._sources = webpack.sources;
|
|
@@ -194,18 +292,17 @@ var WebpackPlugin = class {
|
|
|
194
292
|
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
|
|
195
293
|
}, async (_unusedAssets, cb) => {
|
|
196
294
|
try {
|
|
197
|
-
|
|
295
|
+
const packageRoot = resolvePublishedPackageRoot(BUNDLER_DEFAULT_PACKAGE_NAME, this._modulesPath, compilation.compiler.context);
|
|
296
|
+
assertPublishedPackageExists(packageRoot, BUNDLER_DEFAULT_PACKAGE_NAME);
|
|
297
|
+
await this.copyFiles(compilation, packageRoot, this._outputFolder);
|
|
298
|
+
assertCoreChunkInCompilationAssets(compilation.getAssets().map((asset) => asset.name), BUNDLER_DEFAULT_APP_NAME, toAssetPath(this._outputFolder));
|
|
198
299
|
cb(null);
|
|
199
300
|
} catch (error) {
|
|
200
301
|
cb(error);
|
|
201
302
|
}
|
|
202
303
|
});
|
|
203
304
|
javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderModuleContent.tap(PLUGIN_NAME, (source, module) => {
|
|
204
|
-
if (shouldInjectRuntimeBootstrap(
|
|
205
|
-
const sources = this._sources || compilation.compiler.webpack.sources;
|
|
206
|
-
const patched = `${initFragment}\n${getModuleSourceCode(source)}`;
|
|
207
|
-
return new sources.RawSource(patched);
|
|
208
|
-
}
|
|
305
|
+
if (shouldInjectRuntimeBootstrap(module, source)) return new (this._sources || compilation.compiler.webpack.sources).ConcatSource(`${initFragment}\n`, source);
|
|
209
306
|
return source;
|
|
210
307
|
});
|
|
211
308
|
});
|