@nx/angular-rspack 21.2.0 → 21.4.0-beta.9
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/LICENSE +18 -17
- package/README.md +66 -13
- package/README.md__tpl__ +50 -0
- package/dist/lib/config/create-config.d.ts.map +1 -1
- package/dist/lib/models/angular-rspack-plugin-options.d.ts +1 -0
- package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -1
- package/dist/lib/models/i18n.js +3 -1
- package/dist/lib/models/normalize-options.d.ts.map +1 -1
- package/dist/lib/models/normalize-options.js +4 -0
- package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/angular-rspack-plugin.js +53 -53
- package/dist/lib/plugins/angular-ssr-dev-server.js +25 -22
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.js +0 -1
- package/dist/lib/plugins/client/ssr-reload-client.js +0 -1
- package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/i18n-inline-plugin.js +132 -125
- package/dist/lib/plugins/index-html-plugin.js +0 -2
- package/dist/lib/plugins/ng-rspack.js +0 -3
- package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -1
- package/dist/lib/plugins/prerender-plugin.js +159 -162
- package/dist/lib/plugins/server/ssr-reload-server.js +8 -5
- package/dist/lib/plugins/stats-json-plugin.js +0 -1
- package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -1
- package/dist/lib/plugins/tools/render-worker.js +3 -1
- package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +1 -1
- package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -1
- package/dist/lib/plugins/tools/routes-extractor-worker.js +3 -1
- package/dist/lib/utils/spinner.js +7 -6
- package/dist/lib/utils/stats.d.ts.map +1 -1
- package/dist/lib/utils/stats.js +2 -1
- package/package.json +45 -16
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _PrerenderPlugin_instances, _PrerenderPlugin__options, _PrerenderPlugin_i18n, _PrerenderPlugin_prerenderAppShell, _PrerenderPlugin_prerenderSSGUniversal, _PrerenderPlugin_getRoutes, _PrerenderPlugin_normalizePrerenderOptions, _PrerenderPlugin_resolveZonePackage;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.PrerenderPlugin = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
@@ -20,200 +21,196 @@ class RoutesSet extends Set {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
class PrerenderPlugin {
|
|
23
|
-
#_options;
|
|
24
|
-
#i18n;
|
|
25
24
|
constructor(options, i18nOptions) {
|
|
26
|
-
this
|
|
27
|
-
this
|
|
25
|
+
_PrerenderPlugin_instances.add(this);
|
|
26
|
+
_PrerenderPlugin__options.set(this, void 0);
|
|
27
|
+
_PrerenderPlugin_i18n.set(this, void 0);
|
|
28
|
+
tslib_1.__classPrivateFieldSet(this, _PrerenderPlugin__options, options, "f");
|
|
29
|
+
tslib_1.__classPrivateFieldSet(this, _PrerenderPlugin_i18n, i18nOptions, "f");
|
|
28
30
|
}
|
|
29
31
|
apply(compiler) {
|
|
30
32
|
compiler.hooks.afterEmit.tapAsync('Angular Rspack', async (compilation, callback) => {
|
|
31
|
-
if (this
|
|
32
|
-
await this
|
|
33
|
+
if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").appShell) {
|
|
34
|
+
await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_prerenderAppShell).call(this, compilation);
|
|
33
35
|
}
|
|
34
|
-
if (this
|
|
35
|
-
await this
|
|
36
|
+
if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").prerender) {
|
|
37
|
+
await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_prerenderSSGUniversal).call(this, compilation);
|
|
36
38
|
}
|
|
37
39
|
callback();
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
}
|
|
43
|
+
exports.PrerenderPlugin = PrerenderPlugin;
|
|
44
|
+
_PrerenderPlugin__options = new WeakMap(), _PrerenderPlugin_i18n = new WeakMap(), _PrerenderPlugin_instances = new WeakSet(), _PrerenderPlugin_prerenderAppShell = async function _PrerenderPlugin_prerenderAppShell(compilation) {
|
|
45
|
+
// Users can specify a different base html file e.g. "src/home.html"
|
|
46
|
+
const indexFile = (0, get_index_output_file_1.getIndexOutputFile)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index);
|
|
47
|
+
const worker = new worker_pool_1.WorkerPool({
|
|
48
|
+
filename: require.resolve('./tools/render-worker'),
|
|
49
|
+
maxThreads: (0, max_workers_1.maxWorkers)(),
|
|
50
|
+
workerData: {
|
|
51
|
+
zonePackage: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_resolveZonePackage).call(this, devkit_1.workspaceRoot),
|
|
52
|
+
},
|
|
53
|
+
recordTiming: false,
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const outputPaths = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f")
|
|
57
|
+
? (0, i18n_1.ensureOutputPaths)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser, tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f"))
|
|
58
|
+
: new Map([['', tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser]]);
|
|
59
|
+
const localeOutputPaths = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f")
|
|
60
|
+
? (0, i18n_1.getLocaleOutputPaths)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f"))
|
|
61
|
+
: new Map();
|
|
62
|
+
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
63
|
+
const normalizedOutputPath = (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser, outputPath);
|
|
64
|
+
const serverBundlePath = locale
|
|
65
|
+
? (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.server, localeOutputPaths.get(locale), 'server.js')
|
|
66
|
+
: (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.server, 'server.js');
|
|
67
|
+
if (!(0, fs_1.existsSync)(serverBundlePath)) {
|
|
68
|
+
throw new Error(`Could not find the main bundle: ${serverBundlePath}`);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const options = {
|
|
72
|
+
indexFile,
|
|
73
|
+
deployUrl: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").deployUrl || '',
|
|
74
|
+
inlineCriticalCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.inlineCritical,
|
|
75
|
+
minifyCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.minify,
|
|
76
|
+
outputPath: normalizedOutputPath,
|
|
77
|
+
route: '/',
|
|
78
|
+
serverBundlePath,
|
|
79
|
+
};
|
|
80
|
+
const { errors, warnings } = await worker.run(options);
|
|
81
|
+
errors?.forEach((e) => (0, rspack_diagnostics_1.addError)(compilation, e));
|
|
82
|
+
warnings?.forEach((e) => (0, rspack_diagnostics_1.addWarning)(compilation, e));
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
(0, misc_helpers_1.assertIsError)(error);
|
|
86
|
+
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
87
|
+
}
|
|
88
|
+
if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").serviceWorker && tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").ngswConfigPath) {
|
|
69
89
|
try {
|
|
90
|
+
await (0, private_1.augmentAppWithServiceWorker)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").root, devkit_1.workspaceRoot, outputPath, tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").baseHref || '/', tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").ngswConfigPath);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
(0, misc_helpers_1.assertIsError)(error);
|
|
94
|
+
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
(0, misc_helpers_1.assertIsError)(error);
|
|
101
|
+
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
void worker.destroy();
|
|
105
|
+
}
|
|
106
|
+
}, _PrerenderPlugin_prerenderSSGUniversal = async function _PrerenderPlugin_prerenderSSGUniversal(compilation) {
|
|
107
|
+
// Users can specify a different base html file e.g. "src/home.html"
|
|
108
|
+
const indexFile = (0, get_index_output_file_1.getIndexOutputFile)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").index);
|
|
109
|
+
const worker = new worker_pool_1.WorkerPool({
|
|
110
|
+
filename: require.resolve('./tools/render-worker'),
|
|
111
|
+
maxThreads: (0, max_workers_1.maxWorkers)(),
|
|
112
|
+
workerData: {
|
|
113
|
+
zonePackage: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_resolveZonePackage).call(this, devkit_1.workspaceRoot),
|
|
114
|
+
},
|
|
115
|
+
recordTiming: false,
|
|
116
|
+
});
|
|
117
|
+
let routes;
|
|
118
|
+
try {
|
|
119
|
+
const outputPaths = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f")
|
|
120
|
+
? (0, i18n_1.ensureOutputPaths)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser, tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f"))
|
|
121
|
+
: new Map([['', tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser]]);
|
|
122
|
+
const localeOutputPaths = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f")
|
|
123
|
+
? (0, i18n_1.getLocaleOutputPaths)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_i18n, "f"))
|
|
124
|
+
: new Map();
|
|
125
|
+
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
126
|
+
const normalizedOutputPath = (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.browser, outputPath);
|
|
127
|
+
const serverBundlePath = locale
|
|
128
|
+
? (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.server, localeOutputPaths.get(locale), 'server.js')
|
|
129
|
+
: (0, path_1.join)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").outputPath.server, 'server.js');
|
|
130
|
+
if (!(0, fs_1.existsSync)(serverBundlePath)) {
|
|
131
|
+
throw new Error(`Could not find the main bundle: ${serverBundlePath}`);
|
|
132
|
+
}
|
|
133
|
+
routes ??= await tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_getRoutes).call(this, indexFile, normalizedOutputPath, serverBundlePath, devkit_1.workspaceRoot);
|
|
134
|
+
try {
|
|
135
|
+
const results = (await Promise.all(routes.map((route) => {
|
|
70
136
|
const options = {
|
|
71
137
|
indexFile,
|
|
72
|
-
deployUrl: this
|
|
73
|
-
inlineCriticalCss: !!this
|
|
74
|
-
minifyCss: !!this
|
|
138
|
+
deployUrl: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").deployUrl || '',
|
|
139
|
+
inlineCriticalCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.inlineCritical,
|
|
140
|
+
minifyCss: !!tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").optimization.styles.minify,
|
|
75
141
|
outputPath: normalizedOutputPath,
|
|
76
|
-
route
|
|
142
|
+
route,
|
|
77
143
|
serverBundlePath,
|
|
78
144
|
};
|
|
79
|
-
|
|
145
|
+
return worker.run(options);
|
|
146
|
+
})));
|
|
147
|
+
for (const { errors, warnings } of results) {
|
|
80
148
|
errors?.forEach((e) => (0, rspack_diagnostics_1.addError)(compilation, e));
|
|
81
149
|
warnings?.forEach((e) => (0, rspack_diagnostics_1.addWarning)(compilation, e));
|
|
82
150
|
}
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
(0, misc_helpers_1.assertIsError)(error);
|
|
154
|
+
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
155
|
+
}
|
|
156
|
+
if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").serviceWorker && tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").ngswConfigPath) {
|
|
157
|
+
try {
|
|
158
|
+
await (0, private_1.augmentAppWithServiceWorker)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").root, devkit_1.workspaceRoot, outputPath, tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").baseHref || '/', tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").ngswConfigPath);
|
|
159
|
+
}
|
|
83
160
|
catch (error) {
|
|
84
161
|
(0, misc_helpers_1.assertIsError)(error);
|
|
85
162
|
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
86
163
|
}
|
|
87
|
-
if (this.#_options.serviceWorker && this.#_options.ngswConfigPath) {
|
|
88
|
-
try {
|
|
89
|
-
await (0, private_1.augmentAppWithServiceWorker)(this.#_options.root, devkit_1.workspaceRoot, outputPath, this.#_options.baseHref || '/', this.#_options.ngswConfigPath);
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
(0, misc_helpers_1.assertIsError)(error);
|
|
93
|
-
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
164
|
}
|
|
97
165
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
void worker.destroy();
|
|
169
|
+
}
|
|
170
|
+
}, _PrerenderPlugin_getRoutes = async function _PrerenderPlugin_getRoutes(indexFile, outputPath, serverBundlePath, workspaceRoot) {
|
|
171
|
+
const { routes: extraRoutes = [], routesFile, discoverRoutes, } = tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_normalizePrerenderOptions).call(this);
|
|
172
|
+
const routes = new RoutesSet(extraRoutes);
|
|
173
|
+
if (routesFile) {
|
|
174
|
+
const routesFromFile = (await (0, promises_1.readFile)((0, path_1.join)(workspaceRoot, routesFile), 'utf8')).split(/\r?\n/);
|
|
175
|
+
for (const route of routesFromFile) {
|
|
176
|
+
routes.add(route);
|
|
104
177
|
}
|
|
105
178
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const zonePackage = require.resolve('zone.js', {
|
|
110
|
-
paths: [devkit_1.workspaceRoot],
|
|
111
|
-
});
|
|
112
|
-
const worker = new worker_pool_1.WorkerPool({
|
|
113
|
-
filename: require.resolve('./tools/render-worker'),
|
|
179
|
+
if (discoverRoutes) {
|
|
180
|
+
const renderWorker = new worker_pool_1.WorkerPool({
|
|
181
|
+
filename: require.resolve('./tools/routes-extractor-worker'),
|
|
114
182
|
maxThreads: (0, max_workers_1.maxWorkers)(),
|
|
115
183
|
workerData: {
|
|
116
|
-
|
|
184
|
+
indexFile,
|
|
185
|
+
outputPath,
|
|
186
|
+
serverBundlePath,
|
|
187
|
+
zonePackage: tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin_instances, "m", _PrerenderPlugin_resolveZonePackage).call(this, workspaceRoot),
|
|
117
188
|
},
|
|
118
189
|
recordTiming: false,
|
|
119
190
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const localeOutputPaths = this.#i18n
|
|
126
|
-
? (0, i18n_1.getLocaleOutputPaths)(this.#i18n)
|
|
127
|
-
: new Map();
|
|
128
|
-
for (const [locale, outputPath] of outputPaths.entries()) {
|
|
129
|
-
const normalizedOutputPath = (0, path_1.join)(this.#_options.outputPath.browser, outputPath);
|
|
130
|
-
const serverBundlePath = locale
|
|
131
|
-
? (0, path_1.join)(this.#_options.outputPath.server, localeOutputPaths.get(locale), 'server.js')
|
|
132
|
-
: (0, path_1.join)(this.#_options.outputPath.server, 'server.js');
|
|
133
|
-
if (!(0, fs_1.existsSync)(serverBundlePath)) {
|
|
134
|
-
throw new Error(`Could not find the main bundle: ${serverBundlePath}`);
|
|
135
|
-
}
|
|
136
|
-
routes ??= await this.#getRoutes(indexFile, normalizedOutputPath, serverBundlePath, devkit_1.workspaceRoot);
|
|
137
|
-
try {
|
|
138
|
-
const results = (await Promise.all(routes.map((route) => {
|
|
139
|
-
const options = {
|
|
140
|
-
indexFile,
|
|
141
|
-
deployUrl: this.#_options.deployUrl || '',
|
|
142
|
-
inlineCriticalCss: !!this.#_options.optimization.styles.inlineCritical,
|
|
143
|
-
minifyCss: !!this.#_options.optimization.styles.minify,
|
|
144
|
-
outputPath: normalizedOutputPath,
|
|
145
|
-
route,
|
|
146
|
-
serverBundlePath,
|
|
147
|
-
};
|
|
148
|
-
return worker.run(options);
|
|
149
|
-
})));
|
|
150
|
-
for (const { errors, warnings } of results) {
|
|
151
|
-
errors?.forEach((e) => (0, rspack_diagnostics_1.addError)(compilation, e));
|
|
152
|
-
warnings?.forEach((e) => (0, rspack_diagnostics_1.addWarning)(compilation, e));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
(0, misc_helpers_1.assertIsError)(error);
|
|
157
|
-
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
158
|
-
}
|
|
159
|
-
if (this.#_options.serviceWorker && this.#_options.ngswConfigPath) {
|
|
160
|
-
try {
|
|
161
|
-
await (0, private_1.augmentAppWithServiceWorker)(this.#_options.root, devkit_1.workspaceRoot, outputPath, this.#_options.baseHref || '/', this.#_options.ngswConfigPath);
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
(0, misc_helpers_1.assertIsError)(error);
|
|
165
|
-
(0, rspack_diagnostics_1.addError)(compilation, error.message);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
void worker.destroy();
|
|
191
|
+
const extractedRoutes = await renderWorker
|
|
192
|
+
.run({})
|
|
193
|
+
.finally(() => void renderWorker.destroy());
|
|
194
|
+
for (const route of extractedRoutes) {
|
|
195
|
+
routes.add(route);
|
|
172
196
|
}
|
|
173
197
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const routes = new RoutesSet(extraRoutes);
|
|
177
|
-
if (routesFile) {
|
|
178
|
-
const routesFromFile = (await (0, promises_1.readFile)((0, path_1.join)(workspaceRoot, routesFile), 'utf8')).split(/\r?\n/);
|
|
179
|
-
for (const route of routesFromFile) {
|
|
180
|
-
routes.add(route);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
if (discoverRoutes) {
|
|
184
|
-
const renderWorker = new worker_pool_1.WorkerPool({
|
|
185
|
-
filename: require.resolve('./tools/routes-extractor-worker'),
|
|
186
|
-
maxThreads: (0, max_workers_1.maxWorkers)(),
|
|
187
|
-
workerData: {
|
|
188
|
-
indexFile,
|
|
189
|
-
outputPath,
|
|
190
|
-
serverBundlePath,
|
|
191
|
-
zonePackage: require.resolve('zone.js', { paths: [workspaceRoot] }),
|
|
192
|
-
},
|
|
193
|
-
recordTiming: false,
|
|
194
|
-
});
|
|
195
|
-
const extractedRoutes = await renderWorker
|
|
196
|
-
.run({})
|
|
197
|
-
.finally(() => void renderWorker.destroy());
|
|
198
|
-
for (const route of extractedRoutes) {
|
|
199
|
-
routes.add(route);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (routes.size === 0) {
|
|
203
|
-
throw new Error('Could not find any routes to prerender.');
|
|
204
|
-
}
|
|
205
|
-
return [...routes];
|
|
198
|
+
if (routes.size === 0) {
|
|
199
|
+
throw new Error('Could not find any routes to prerender.');
|
|
206
200
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
return this.#_options.prerender;
|
|
201
|
+
return [...routes];
|
|
202
|
+
}, _PrerenderPlugin_normalizePrerenderOptions = function _PrerenderPlugin_normalizePrerenderOptions() {
|
|
203
|
+
(0, assert_1.default)(tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").prerender, 'Prerendering is not enabled.');
|
|
204
|
+
if (typeof tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").prerender === 'boolean') {
|
|
205
|
+
return {
|
|
206
|
+
routes: [],
|
|
207
|
+
routesFile: undefined,
|
|
208
|
+
discoverRoutes: true,
|
|
209
|
+
};
|
|
217
210
|
}
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
return tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").prerender;
|
|
212
|
+
}, _PrerenderPlugin_resolveZonePackage = function _PrerenderPlugin_resolveZonePackage(workspaceRoot) {
|
|
213
|
+
if (tslib_1.__classPrivateFieldGet(this, _PrerenderPlugin__options, "f").zoneless)
|
|
214
|
+
return false;
|
|
215
|
+
return require.resolve('zone.js', { paths: [workspaceRoot] });
|
|
216
|
+
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _SsrReloadServer_server;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.SsrReloadServer = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
4
6
|
const ws_1 = require("ws");
|
|
5
7
|
class SsrReloadServer {
|
|
6
|
-
#server;
|
|
7
8
|
constructor() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
process.on('
|
|
9
|
+
_SsrReloadServer_server.set(this, void 0);
|
|
10
|
+
tslib_1.__classPrivateFieldSet(this, _SsrReloadServer_server, new ws_1.WebSocket.Server({ port: 60_000 }), "f");
|
|
11
|
+
process.on('SIGTERM', () => tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").close());
|
|
12
|
+
process.on('exit', () => tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").close());
|
|
11
13
|
}
|
|
12
14
|
sendReload() {
|
|
13
|
-
this
|
|
15
|
+
tslib_1.__classPrivateFieldGet(this, _SsrReloadServer_server, "f").clients.forEach((client) => {
|
|
14
16
|
client.send('ssr-reload');
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
exports.SsrReloadServer = SsrReloadServer;
|
|
21
|
+
_SsrReloadServer_server = new WeakMap();
|
|
@@ -48,7 +48,6 @@ const promises_2 = require("node:stream/promises");
|
|
|
48
48
|
const misc_helpers_1 = require("../utils/misc-helpers");
|
|
49
49
|
const rspack_diagnostics_1 = require("../utils/rspack-diagnostics");
|
|
50
50
|
class StatsJsonPlugin {
|
|
51
|
-
statsOutputPath;
|
|
52
51
|
constructor(statsOutputPath) {
|
|
53
52
|
this.statsOutputPath = statsOutputPath;
|
|
54
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-worker.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/tools/render-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AA2BD;;GAEG;AACH,iBAAe,MAAM,CAAC,EACpB,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,iBAAiB,GAClB,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAmGvC;
|
|
1
|
+
{"version":3,"file":"render-worker.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/tools/render-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AA2BD;;GAEG;AACH,iBAAe,MAAM,CAAC,EACpB,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,KAAK,EACL,iBAAiB,GAClB,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAmGvC;AAuBD;;;GAGG;;AACH,wBAA4B"}
|
|
@@ -92,7 +92,9 @@ function isBootstrapFn(value) {
|
|
|
92
92
|
*/
|
|
93
93
|
async function initialize() {
|
|
94
94
|
// Setup Zone.js
|
|
95
|
-
|
|
95
|
+
if (zonePackage) {
|
|
96
|
+
await Promise.resolve(`${zonePackage}`).then(s => tslib_1.__importStar(require(s)));
|
|
97
|
+
}
|
|
96
98
|
// Return the render function for use
|
|
97
99
|
return render;
|
|
98
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-extractor-worker.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/tools/routes-extractor-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"routes-extractor-worker.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/tools/routes-extractor-worker.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,GAAG,KAAK,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAgBD,iBAAe,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CA8B1C;AAiBD;;;GAGG;;AACH,wBAA4B"}
|
|
@@ -36,7 +36,9 @@ async function extract() {
|
|
|
36
36
|
*/
|
|
37
37
|
async function initialize() {
|
|
38
38
|
// Setup Zone.js
|
|
39
|
-
|
|
39
|
+
if (zonePackage) {
|
|
40
|
+
await Promise.resolve(`${zonePackage}`).then(s => tslib_1.__importStar(require(s)));
|
|
41
|
+
}
|
|
40
42
|
return extract;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
* found in the LICENSE file at https://angular.dev/license
|
|
8
8
|
*/
|
|
9
|
+
var _Spinner_isTTY;
|
|
9
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
11
|
exports.Spinner = void 0;
|
|
11
12
|
const tslib_1 = require("tslib");
|
|
@@ -13,25 +14,24 @@ const ora_1 = tslib_1.__importDefault(require("ora"));
|
|
|
13
14
|
const color_1 = require("./color");
|
|
14
15
|
const tty_1 = require("./tty");
|
|
15
16
|
class Spinner {
|
|
16
|
-
spinner;
|
|
17
|
-
/** When false, only fail messages will be displayed. */
|
|
18
|
-
enabled = true;
|
|
19
|
-
#isTTY = (0, tty_1.isTTY)();
|
|
20
17
|
constructor(text) {
|
|
18
|
+
/** When false, only fail messages will be displayed. */
|
|
19
|
+
this.enabled = true;
|
|
20
|
+
_Spinner_isTTY.set(this, (0, tty_1.isTTY)());
|
|
21
21
|
this.spinner = (0, ora_1.default)({
|
|
22
22
|
text: text === undefined ? undefined : text + '\n',
|
|
23
23
|
// The below 2 options are needed because otherwise CTRL+C will be delayed
|
|
24
24
|
// when the underlying process is sync.
|
|
25
25
|
hideCursor: false,
|
|
26
26
|
discardStdin: false,
|
|
27
|
-
isEnabled: this
|
|
27
|
+
isEnabled: tslib_1.__classPrivateFieldGet(this, _Spinner_isTTY, "f"),
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
set text(text) {
|
|
31
31
|
this.spinner.text = text;
|
|
32
32
|
}
|
|
33
33
|
get isSpinning() {
|
|
34
|
-
return this.spinner.isSpinning || !this
|
|
34
|
+
return this.spinner.isSpinning || !tslib_1.__classPrivateFieldGet(this, _Spinner_isTTY, "f");
|
|
35
35
|
}
|
|
36
36
|
succeed(text) {
|
|
37
37
|
if (this.enabled) {
|
|
@@ -51,3 +51,4 @@ class Spinner {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.Spinner = Spinner;
|
|
54
|
+
_Spinner_isTTY = new WeakMap();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAMjD,MAAM,WAAW,qBAAqB;IACpC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,aAAa,CAAC,OAAO,CAAC,EACtB,MAAM,GAAG,OAAO,GAAG,SAAS,CAC7B,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,iBAAiB,EAAE,MAAM,GACxB,oBAAoB,EAAE,CAmBxB;
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,sBAAsB,EAGvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,KAAK,EACL,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,oCAAoC,EACpC,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAMjD,MAAM,WAAW,qBAAqB;IACpC,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,aAAa,CAAC,OAAO,CAAC,EACtB,MAAM,GAAG,OAAO,GAAG,SAAS,CAC7B,CAAC;AAEF,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,iBAAiB,EAAE,MAAM,GACxB,oBAAoB,EAAE,CAmBxB;AAgID,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,kBAAkB,GAC9B,MAAM,CAsDR;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,gBAAgB,EACtB,WAAW,EAAE,kBAAkB,GAC9B,MAAM,CA4DR;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAI9D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAIhE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oCAAoC,IAQrC,UAAK,EAAE,WAAM,UActB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,oCAAoC,GAC5C,eAAe,CAoDjB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,YAAY,EACzB,cAAc,CAAC,EAAE,sBAAsB,EAAE,GACxC,IAAI,CAgBN"}
|
package/dist/lib/utils/stats.js
CHANGED
|
@@ -95,7 +95,8 @@ function statsToString(stats, json, statsConfig, budgetFailures) {
|
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
97
|
rawSize += asset.size;
|
|
98
|
-
const
|
|
98
|
+
const compilationAsset = stats.compilation.getAsset(asset.name);
|
|
99
|
+
const assetInfo = compilationAsset ? compilationAsset.info : undefined;
|
|
99
100
|
if (assetInfo) {
|
|
100
101
|
if (typeof assetInfo.estimatedTransferSize === 'number') {
|
|
101
102
|
if (estimatedTransferSize === undefined) {
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular-rspack",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.4.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"description": "Rspack Plugin and Loaders for building Angular.",
|
|
9
|
-
"author": "
|
|
9
|
+
"author": "Victor Savkin",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/nrwl/
|
|
12
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/nrwl/
|
|
16
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
17
17
|
"directory": "packages/angular-rspack"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"@ampproject/remapping": "2.3.0",
|
|
48
48
|
"@babel/core": "7.26.10",
|
|
49
49
|
"@discoveryjs/json-ext": "0.6.3",
|
|
50
|
-
"@nx/devkit": "21.0.0",
|
|
51
50
|
"ansi-colors": "4.1.3",
|
|
52
51
|
"autoprefixer": "10.4.21",
|
|
53
52
|
"deepmerge": "^4.3.1",
|
|
@@ -63,19 +62,18 @@
|
|
|
63
62
|
"postcss": "8.5.3",
|
|
64
63
|
"postcss-loader": "8.1.1",
|
|
65
64
|
"resolve-url-loader": "^5.0.0",
|
|
65
|
+
"sass": "1.89.2",
|
|
66
66
|
"sass-embedded": "^1.79.3",
|
|
67
67
|
"sass-loader": "^16.0.2",
|
|
68
68
|
"source-map-loader": "^5.0.0",
|
|
69
69
|
"tslib": "^2.3.0",
|
|
70
70
|
"webpack-merge": "^6.0.1",
|
|
71
71
|
"ws": "^8.18.0",
|
|
72
|
-
"@nx/angular-rspack-compiler": "21.
|
|
72
|
+
"@nx/angular-rspack-compiler": "21.4.0-beta.9",
|
|
73
|
+
"@nx/devkit": "0.0.1"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
|
-
"
|
|
76
|
-
"@code-pushup/utils": "^0.63.0",
|
|
77
|
-
"jsonc-eslint-parser": "^2.4.0",
|
|
78
|
-
"@ng-rspack/testing-setup": "0.0.1"
|
|
76
|
+
"jsonc-eslint-parser": "^2.4.0"
|
|
79
77
|
},
|
|
80
78
|
"peerDependencies": {
|
|
81
79
|
"@angular/build": ">=19.0.0 <21.0.0",
|
|
@@ -104,14 +102,45 @@
|
|
|
104
102
|
"name": "angular-rspack",
|
|
105
103
|
"sourceRoot": "packages/angular-rspack/src",
|
|
106
104
|
"projectType": "library",
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
|
|
105
|
+
"release": {
|
|
106
|
+
"version": {
|
|
107
|
+
"preserveLocalDependencyProtocols": true,
|
|
108
|
+
"manifestRootsToUpdate": [
|
|
109
|
+
"packages/{projectName}"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
110
113
|
"targets": {
|
|
111
|
-
"
|
|
112
|
-
|
|
114
|
+
"build": {
|
|
115
|
+
"command": "node ./scripts/copy-readme.js angular-rspack packages/angular-rspack/README.md__tpl__ packages/angular-rspack/README.md",
|
|
116
|
+
"outputs": [
|
|
117
|
+
"{projectRoot}/README.md"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"test": {
|
|
121
|
+
"dependsOn": [
|
|
122
|
+
"build",
|
|
123
|
+
"^build-native",
|
|
124
|
+
"angular-rspack-compiler:build"
|
|
125
|
+
],
|
|
126
|
+
"inputs": [
|
|
127
|
+
"default",
|
|
128
|
+
"^production",
|
|
129
|
+
"{projectRoot}/vitest.config.mts"
|
|
130
|
+
],
|
|
131
|
+
"options": {
|
|
132
|
+
"args": [
|
|
133
|
+
"--passWithNoTests"
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"nx-release-publish": {
|
|
138
|
+
"executor": "@nx/js:release-publish",
|
|
139
|
+
"options": {
|
|
140
|
+
"packageRoot": "packages/angular-rspack"
|
|
141
|
+
},
|
|
113
142
|
"dependsOn": [
|
|
114
|
-
"
|
|
143
|
+
"^nx-release-publish"
|
|
115
144
|
]
|
|
116
145
|
}
|
|
117
146
|
}
|