@nx/angular-rspack 0.0.0-pr-32422-a3285be
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 +22 -0
- package/README.md +98 -0
- package/README.md__tpl__ +48 -0
- package/dist/lib/config/config-utils/browser-config.d.ts +4 -0
- package/dist/lib/config/config-utils/browser-config.d.ts.map +1 -0
- package/dist/lib/config/config-utils/browser-config.js +83 -0
- package/dist/lib/config/config-utils/common-config.d.ts +3 -0
- package/dist/lib/config/config-utils/common-config.d.ts.map +1 -0
- package/dist/lib/config/config-utils/common-config.js +144 -0
- package/dist/lib/config/config-utils/dev-server-config-utils.d.ts +4 -0
- package/dist/lib/config/config-utils/dev-server-config-utils.d.ts.map +1 -0
- package/dist/lib/config/config-utils/dev-server-config-utils.js +258 -0
- package/dist/lib/config/config-utils/entry-points.d.ts +9 -0
- package/dist/lib/config/config-utils/entry-points.d.ts.map +1 -0
- package/dist/lib/config/config-utils/entry-points.js +36 -0
- package/dist/lib/config/config-utils/get-stats-options.d.ts +3 -0
- package/dist/lib/config/config-utils/get-stats-options.d.ts.map +1 -0
- package/dist/lib/config/config-utils/get-stats-options.js +39 -0
- package/dist/lib/config/config-utils/helpers.d.ts +13 -0
- package/dist/lib/config/config-utils/helpers.d.ts.map +1 -0
- package/dist/lib/config/config-utils/helpers.js +106 -0
- package/dist/lib/config/config-utils/optimization-config.d.ts +5 -0
- package/dist/lib/config/config-utils/optimization-config.d.ts.map +1 -0
- package/dist/lib/config/config-utils/optimization-config.js +69 -0
- package/dist/lib/config/config-utils/server-config.d.ts +4 -0
- package/dist/lib/config/config-utils/server-config.d.ts.map +1 -0
- package/dist/lib/config/config-utils/server-config.js +92 -0
- package/dist/lib/config/config-utils/sourcemap-utils.d.ts +7 -0
- package/dist/lib/config/config-utils/sourcemap-utils.d.ts.map +1 -0
- package/dist/lib/config/config-utils/sourcemap-utils.js +48 -0
- package/dist/lib/config/config-utils/style-config-utils.d.ts +7 -0
- package/dist/lib/config/config-utils/style-config-utils.d.ts.map +1 -0
- package/dist/lib/config/config-utils/style-config-utils.js +353 -0
- package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts +73 -0
- package/dist/lib/config/config-utils/user-defined-config-helpers.d.ts.map +1 -0
- package/dist/lib/config/config-utils/user-defined-config-helpers.js +23 -0
- package/dist/lib/config/create-config.d.ts +11 -0
- package/dist/lib/config/create-config.d.ts.map +1 -0
- package/dist/lib/config/create-config.js +35 -0
- package/dist/lib/config/i18n/create-i18n-options.d.ts +6 -0
- package/dist/lib/config/i18n/create-i18n-options.d.ts.map +1 -0
- package/dist/lib/config/i18n/create-i18n-options.js +124 -0
- package/dist/lib/index.d.ts +7 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +14 -0
- package/dist/lib/models/angular-rspack-plugin-options.d.ts +344 -0
- package/dist/lib/models/angular-rspack-plugin-options.d.ts.map +1 -0
- package/dist/lib/models/angular-rspack-plugin-options.js +2 -0
- package/dist/lib/models/augmented-compilation.d.ts +13 -0
- package/dist/lib/models/augmented-compilation.d.ts.map +1 -0
- package/dist/lib/models/augmented-compilation.js +4 -0
- package/dist/lib/models/i18n.d.ts +33 -0
- package/dist/lib/models/i18n.d.ts.map +1 -0
- package/dist/lib/models/i18n.js +41 -0
- package/dist/lib/models/index.d.ts +5 -0
- package/dist/lib/models/index.d.ts.map +1 -0
- package/dist/lib/models/index.js +7 -0
- package/dist/lib/models/normalize-options.d.ts +16 -0
- package/dist/lib/models/normalize-options.d.ts.map +1 -0
- package/dist/lib/models/normalize-options.js +424 -0
- package/dist/lib/plugins/angular-rspack-plugin.d.ts +9 -0
- package/dist/lib/plugins/angular-rspack-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/angular-rspack-plugin.js +234 -0
- package/dist/lib/plugins/angular-ssr-dev-server.d.ts +8 -0
- package/dist/lib/plugins/angular-ssr-dev-server.d.ts.map +1 -0
- package/dist/lib/plugins/angular-ssr-dev-server.js +62 -0
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts +19 -0
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/any-component-style-budget-checker-plugin.js +64 -0
- package/dist/lib/plugins/client/ssr-reload-client.d.ts +2 -0
- package/dist/lib/plugins/client/ssr-reload-client.d.ts.map +1 -0
- package/dist/lib/plugins/client/ssr-reload-client.js +15 -0
- package/dist/lib/plugins/i18n-inline-plugin.d.ts +8 -0
- package/dist/lib/plugins/i18n-inline-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/i18n-inline-plugin.js +201 -0
- package/dist/lib/plugins/index-html-plugin.d.ts +21 -0
- package/dist/lib/plugins/index-html-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/index-html-plugin.js +107 -0
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts +3 -0
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/angular-partial-transform.loader.js +39 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.d.ts +7 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.js +40 -0
- package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts +11 -0
- package/dist/lib/plugins/loaders/hmr-accept-loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/hmr-accept-loader.js +24 -0
- package/dist/lib/plugins/loaders/hmr-accept.d.ts +9 -0
- package/dist/lib/plugins/loaders/hmr-accept.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/hmr-accept.js +183 -0
- package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts +5 -0
- package/dist/lib/plugins/loaders/platform-server-exports.loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/platform-server-exports.loader.js +18 -0
- package/dist/lib/plugins/ng-rspack.d.ts +13 -0
- package/dist/lib/plugins/ng-rspack.d.ts.map +1 -0
- package/dist/lib/plugins/ng-rspack.js +134 -0
- package/dist/lib/plugins/prerender-plugin.d.ts +8 -0
- package/dist/lib/plugins/prerender-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/prerender-plugin.js +216 -0
- package/dist/lib/plugins/progress-plugin.d.ts +12 -0
- package/dist/lib/plugins/progress-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/progress-plugin.js +36 -0
- package/dist/lib/plugins/rxjs-esm-resolution.d.ts +5 -0
- package/dist/lib/plugins/rxjs-esm-resolution.d.ts.map +1 -0
- package/dist/lib/plugins/rxjs-esm-resolution.js +15 -0
- package/dist/lib/plugins/server/ssr-reload-server.d.ts +6 -0
- package/dist/lib/plugins/server/ssr-reload-server.d.ts.map +1 -0
- package/dist/lib/plugins/server/ssr-reload-server.js +21 -0
- package/dist/lib/plugins/stats-json-plugin.d.ts +14 -0
- package/dist/lib/plugins/stats-json-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/stats-json-plugin.js +69 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts +5 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/suppress-js-for-css-chunks-plugin.js +34 -0
- package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts +17 -0
- package/dist/lib/plugins/tools/dev-tools-ignore-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/tools/dev-tools-ignore-plugin.js +57 -0
- package/dist/lib/plugins/tools/render-worker.d.ts +31 -0
- package/dist/lib/plugins/tools/render-worker.d.ts.map +1 -0
- package/dist/lib/plugins/tools/render-worker.js +105 -0
- package/dist/lib/plugins/tools/routes-extractor-worker.d.ts +21 -0
- package/dist/lib/plugins/tools/routes-extractor-worker.d.ts.map +1 -0
- package/dist/lib/plugins/tools/routes-extractor-worker.js +48 -0
- package/dist/lib/plugins/tools/worker-pool.d.ts +13 -0
- package/dist/lib/plugins/tools/worker-pool.d.ts.map +1 -0
- package/dist/lib/plugins/tools/worker-pool.js +23 -0
- package/dist/lib/plugins/transfer-size-plugin.d.ts +12 -0
- package/dist/lib/plugins/transfer-size-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/transfer-size-plugin.js +49 -0
- package/dist/lib/plugins/watch-file-logs-plugin.d.ts +12 -0
- package/dist/lib/plugins/watch-file-logs-plugin.d.ts.map +1 -0
- package/dist/lib/plugins/watch-file-logs-plugin.js +27 -0
- package/dist/lib/utils/async-chunks.d.ts +17 -0
- package/dist/lib/utils/async-chunks.d.ts.map +1 -0
- package/dist/lib/utils/async-chunks.js +44 -0
- package/dist/lib/utils/color.d.ts +11 -0
- package/dist/lib/utils/color.d.ts.map +1 -0
- package/dist/lib/utils/color.js +41 -0
- package/dist/lib/utils/find-project-for-path.d.ts +16 -0
- package/dist/lib/utils/find-project-for-path.d.ts.map +1 -0
- package/dist/lib/utils/find-project-for-path.js +42 -0
- package/dist/lib/utils/get-locale-base-href.d.ts +3 -0
- package/dist/lib/utils/get-locale-base-href.d.ts.map +1 -0
- package/dist/lib/utils/get-locale-base-href.js +17 -0
- package/dist/lib/utils/graph.d.ts +3 -0
- package/dist/lib/utils/graph.d.ts.map +1 -0
- package/dist/lib/utils/graph.js +25 -0
- package/dist/lib/utils/i18n.d.ts +4 -0
- package/dist/lib/utils/i18n.d.ts.map +1 -0
- package/dist/lib/utils/i18n.js +25 -0
- package/dist/lib/utils/index-file/add-body-script.d.ts +2 -0
- package/dist/lib/utils/index-file/add-body-script.d.ts.map +1 -0
- package/dist/lib/utils/index-file/add-body-script.js +15 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts +9 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.d.ts.map +1 -0
- package/dist/lib/utils/index-file/add-event-dispatch-contract.js +27 -0
- package/dist/lib/utils/index-file/get-index-input-file.d.ts +3 -0
- package/dist/lib/utils/index-file/get-index-input-file.d.ts.map +1 -0
- package/dist/lib/utils/index-file/get-index-input-file.js +9 -0
- package/dist/lib/utils/index-file/get-index-output-file.d.ts +3 -0
- package/dist/lib/utils/index-file/get-index-output-file.d.ts.map +1 -0
- package/dist/lib/utils/index-file/get-index-output-file.js +10 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.d.ts +16 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.d.ts.map +1 -0
- package/dist/lib/utils/index-file/html-rewriting-stream.js +27 -0
- package/dist/lib/utils/max-workers.d.ts +2 -0
- package/dist/lib/utils/max-workers.d.ts.map +1 -0
- package/dist/lib/utils/max-workers.js +21 -0
- package/dist/lib/utils/misc-helpers.d.ts +7 -0
- package/dist/lib/utils/misc-helpers.d.ts.map +1 -0
- package/dist/lib/utils/misc-helpers.js +34 -0
- package/dist/lib/utils/postcss-cli-resources.d.ts +22 -0
- package/dist/lib/utils/postcss-cli-resources.d.ts.map +1 -0
- package/dist/lib/utils/postcss-cli-resources.js +159 -0
- package/dist/lib/utils/postcss-configuration.d.ts +18 -0
- package/dist/lib/utils/postcss-configuration.d.ts.map +1 -0
- package/dist/lib/utils/postcss-configuration.js +92 -0
- package/dist/lib/utils/rspack-diagnostics.d.ts +4 -0
- package/dist/lib/utils/rspack-diagnostics.d.ts.map +1 -0
- package/dist/lib/utils/rspack-diagnostics.js +22 -0
- package/dist/lib/utils/spinner.d.ts +21 -0
- package/dist/lib/utils/spinner.d.ts.map +1 -0
- package/dist/lib/utils/spinner.js +54 -0
- package/dist/lib/utils/stats.d.ts +35 -0
- package/dist/lib/utils/stats.d.ts.map +1 -0
- package/dist/lib/utils/stats.js +313 -0
- package/dist/lib/utils/tty.d.ts +9 -0
- package/dist/lib/utils/tty.d.ts.map +1 -0
- package/dist/lib/utils/tty.js +22 -0
- package/dist/lib/utils/url-join.d.ts +9 -0
- package/dist/lib/utils/url-join.d.ts.map +1 -0
- package/dist/lib/utils/url-join.js +17 -0
- package/package.json +150 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDevServerConfig = getDevServerConfig;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_assert_1 = tslib_1.__importDefault(require("node:assert"));
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const node_url_1 = require("node:url");
|
|
9
|
+
const get_index_output_file_1 = require("../../utils/index-file/get-index-output-file");
|
|
10
|
+
const misc_helpers_1 = require("../../utils/misc-helpers");
|
|
11
|
+
async function getDevServerConfig(options, platform) {
|
|
12
|
+
const { root } = options;
|
|
13
|
+
const servePath = buildServePath(options);
|
|
14
|
+
return {
|
|
15
|
+
host: options.devServer.host,
|
|
16
|
+
port: options.devServer.port,
|
|
17
|
+
headers: {
|
|
18
|
+
'Access-Control-Allow-Origin': '*',
|
|
19
|
+
...options.devServer.headers,
|
|
20
|
+
},
|
|
21
|
+
historyApiFallback: {
|
|
22
|
+
index: node_path_1.posix.join(servePath, (0, get_index_output_file_1.getIndexOutputFile)(options.index)),
|
|
23
|
+
disableDotRule: true,
|
|
24
|
+
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
25
|
+
rewrites: [
|
|
26
|
+
{
|
|
27
|
+
from: new RegExp(`^(?!${servePath})/.*`),
|
|
28
|
+
to: (context) => context.parsedUrl.href,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
compress: false,
|
|
33
|
+
static: false,
|
|
34
|
+
server: getServerConfig(options),
|
|
35
|
+
allowedHosts: getAllowedHostsConfig(options.devServer.allowedHosts, options.devServer.disableHostCheck),
|
|
36
|
+
devMiddleware: {
|
|
37
|
+
publicPath: servePath,
|
|
38
|
+
writeToDisk: platform === 'browser' && options.hasServer
|
|
39
|
+
? (file) => !file.includes('.hot-update.')
|
|
40
|
+
: undefined,
|
|
41
|
+
},
|
|
42
|
+
liveReload: options.devServer.liveReload,
|
|
43
|
+
hot: options.devServer.hmr && !options.devServer.liveReload
|
|
44
|
+
? 'only'
|
|
45
|
+
: options.devServer.hmr,
|
|
46
|
+
proxy: await getProxyConfig(root, options.devServer.proxyConfig),
|
|
47
|
+
...getWebSocketSettings(options, servePath),
|
|
48
|
+
watchFiles: ['./src/**/*.*', './public/**/*.*'],
|
|
49
|
+
onListening: platform === 'browser'
|
|
50
|
+
? (devServer) => {
|
|
51
|
+
if (!devServer) {
|
|
52
|
+
throw new Error('@rspack/dev-server is not defined');
|
|
53
|
+
}
|
|
54
|
+
const port = devServer.server?.address()?.port ??
|
|
55
|
+
options.devServer.port;
|
|
56
|
+
console.log('Listening on port:', port);
|
|
57
|
+
}
|
|
58
|
+
: undefined,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolve and build a URL _path_ that will be the root of the server. This resolves base href and
|
|
63
|
+
* deploy URL from the browser options and returns a path from the root.
|
|
64
|
+
*/
|
|
65
|
+
function buildServePath(options) {
|
|
66
|
+
let servePath = options.devServer.servePath;
|
|
67
|
+
if (servePath === undefined) {
|
|
68
|
+
const defaultPath = findDefaultServePath(options.baseHref, options.deployUrl);
|
|
69
|
+
if (defaultPath == null) {
|
|
70
|
+
console.warn(`Warning: --deploy-url and/or --base-href contain unsupported values for ng serve. Default serve path of '/' used. Use --serve-path to override.`);
|
|
71
|
+
}
|
|
72
|
+
servePath = defaultPath || '';
|
|
73
|
+
}
|
|
74
|
+
if (servePath.endsWith('/')) {
|
|
75
|
+
servePath = servePath.slice(0, -1);
|
|
76
|
+
}
|
|
77
|
+
if (!servePath.startsWith('/')) {
|
|
78
|
+
servePath = `/${servePath}`;
|
|
79
|
+
}
|
|
80
|
+
return servePath;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Find the default server path. We don't want to expose baseHref and deployUrl as arguments, only
|
|
84
|
+
* the browser options where needed.
|
|
85
|
+
*/
|
|
86
|
+
function findDefaultServePath(baseHref, deployUrl) {
|
|
87
|
+
if (!baseHref && !deployUrl) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
if (/^(\w+:)?\/\//.test(baseHref || '') ||
|
|
91
|
+
/^(\w+:)?\/\//.test(deployUrl || '')) {
|
|
92
|
+
// If baseHref or deployUrl is absolute, unsupported by ng serve
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
// normalize baseHref
|
|
96
|
+
// for ng serve the starting base is always `/` so a relative
|
|
97
|
+
// and root relative value are identical
|
|
98
|
+
const baseHrefParts = (baseHref || '')
|
|
99
|
+
.split('/')
|
|
100
|
+
.filter((part) => part !== '');
|
|
101
|
+
if (baseHref && !baseHref.endsWith('/')) {
|
|
102
|
+
baseHrefParts.pop();
|
|
103
|
+
}
|
|
104
|
+
const normalizedBaseHref = baseHrefParts.length === 0 ? '/' : `/${baseHrefParts.join('/')}/`;
|
|
105
|
+
if (deployUrl && deployUrl[0] === '/') {
|
|
106
|
+
if (baseHref && baseHref[0] === '/' && normalizedBaseHref !== deployUrl) {
|
|
107
|
+
// If baseHref and deployUrl are root relative and not equivalent, unsupported by ng serve
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
return deployUrl;
|
|
111
|
+
}
|
|
112
|
+
// Join together baseHref and deployUrl
|
|
113
|
+
return `${normalizedBaseHref}${deployUrl || ''}`;
|
|
114
|
+
}
|
|
115
|
+
function getServerConfig(options) {
|
|
116
|
+
const { root, devServer: { ssl, sslCert, sslKey }, } = options;
|
|
117
|
+
if (!ssl) {
|
|
118
|
+
return 'http';
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
type: 'https',
|
|
122
|
+
options: sslCert && sslKey
|
|
123
|
+
? {
|
|
124
|
+
key: (0, node_path_1.resolve)(root, sslKey),
|
|
125
|
+
cert: (0, node_path_1.resolve)(root, sslCert),
|
|
126
|
+
}
|
|
127
|
+
: undefined,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function getAllowedHostsConfig(allowedHosts, disableHostCheck) {
|
|
131
|
+
if (disableHostCheck || allowedHosts === true) {
|
|
132
|
+
return 'all';
|
|
133
|
+
}
|
|
134
|
+
if (Array.isArray(allowedHosts) && allowedHosts.length > 0) {
|
|
135
|
+
return allowedHosts;
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
async function getProxyConfig(root, proxyConfig) {
|
|
140
|
+
if (!proxyConfig) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
const proxyPath = (0, node_path_1.resolve)(root, proxyConfig);
|
|
144
|
+
if (!(0, node_fs_1.existsSync)(proxyPath)) {
|
|
145
|
+
throw new Error(`Proxy configuration file ${proxyPath} does not exist.`);
|
|
146
|
+
}
|
|
147
|
+
let proxyConfiguration;
|
|
148
|
+
switch ((0, node_path_1.extname)(proxyPath)) {
|
|
149
|
+
case '.json': {
|
|
150
|
+
const content = await node_fs_1.promises.readFile(proxyPath, 'utf-8');
|
|
151
|
+
const { parse, printParseErrorCode } = await Promise.resolve().then(() => tslib_1.__importStar(require('jsonc-parser')));
|
|
152
|
+
const parseErrors = [];
|
|
153
|
+
proxyConfiguration = parse(content, parseErrors, {
|
|
154
|
+
allowTrailingComma: true,
|
|
155
|
+
});
|
|
156
|
+
if (parseErrors.length > 0) {
|
|
157
|
+
let errorMessage = `Proxy configuration file ${proxyPath} contains parse errors:`;
|
|
158
|
+
for (const parseError of parseErrors) {
|
|
159
|
+
const { line, column } = getJsonErrorLineColumn(parseError.offset, content);
|
|
160
|
+
errorMessage += `\n[${line}, ${column}] ${printParseErrorCode(parseError.error)}`;
|
|
161
|
+
}
|
|
162
|
+
throw new Error(errorMessage);
|
|
163
|
+
}
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case '.mjs':
|
|
167
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
168
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
169
|
+
// changed to a direct dynamic import.
|
|
170
|
+
proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
171
|
+
break;
|
|
172
|
+
case '.cjs':
|
|
173
|
+
proxyConfiguration = require(proxyPath);
|
|
174
|
+
break;
|
|
175
|
+
default:
|
|
176
|
+
// The file could be either CommonJS or ESM.
|
|
177
|
+
// CommonJS is tried first then ESM if loading fails.
|
|
178
|
+
try {
|
|
179
|
+
proxyConfiguration = require(proxyPath);
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
assertIsError(e);
|
|
183
|
+
if (e.code !== 'ERR_REQUIRE_ESM' &&
|
|
184
|
+
e.code !== 'ERR_REQUIRE_ASYNC_MODULE') {
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
// Load the ESM configuration file using the TypeScript dynamic import workaround.
|
|
188
|
+
// Once TypeScript provides support for keeping the dynamic import this workaround can be
|
|
189
|
+
// changed to a direct dynamic import.
|
|
190
|
+
proxyConfiguration = (await (0, misc_helpers_1.loadEsmModule)((0, node_url_1.pathToFileURL)(proxyPath))).default;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return normalizeProxyConfiguration(proxyConfiguration);
|
|
194
|
+
}
|
|
195
|
+
function getWebSocketSettings(options, servePath) {
|
|
196
|
+
const { hmr, liveReload } = options.devServer;
|
|
197
|
+
if (!hmr && !liveReload) {
|
|
198
|
+
return { client: undefined, webSocketServer: false };
|
|
199
|
+
}
|
|
200
|
+
const webSocketPath = node_path_1.posix.join(servePath, 'ng-cli-ws');
|
|
201
|
+
return {
|
|
202
|
+
webSocketServer: {
|
|
203
|
+
options: { path: webSocketPath },
|
|
204
|
+
},
|
|
205
|
+
client: {
|
|
206
|
+
logging: 'info',
|
|
207
|
+
webSocketURL: getPublicHostOptions(options, webSocketPath),
|
|
208
|
+
overlay: {
|
|
209
|
+
errors: true,
|
|
210
|
+
warnings: false,
|
|
211
|
+
runtimeErrors: false,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function getPublicHostOptions(options, webSocketPath) {
|
|
217
|
+
let publicHost = options.devServer.publicHost;
|
|
218
|
+
if (publicHost) {
|
|
219
|
+
const hostWithProtocol = !/^\w+:\/\//.test(publicHost)
|
|
220
|
+
? `https://${publicHost}`
|
|
221
|
+
: publicHost;
|
|
222
|
+
publicHost = new URL(hostWithProtocol).host;
|
|
223
|
+
}
|
|
224
|
+
return `auto://${publicHost || '0.0.0.0:0'}${webSocketPath}`;
|
|
225
|
+
}
|
|
226
|
+
function getJsonErrorLineColumn(offset, content) {
|
|
227
|
+
if (offset === 0) {
|
|
228
|
+
return { line: 1, column: 1 };
|
|
229
|
+
}
|
|
230
|
+
let line = 0;
|
|
231
|
+
let position = 0;
|
|
232
|
+
while (true) {
|
|
233
|
+
++line;
|
|
234
|
+
const nextNewline = content.indexOf('\n', position);
|
|
235
|
+
if (nextNewline === -1 || nextNewline > offset) {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
position = nextNewline + 1;
|
|
239
|
+
}
|
|
240
|
+
return { line, column: offset - position + 1 };
|
|
241
|
+
}
|
|
242
|
+
function normalizeProxyConfiguration(proxy) {
|
|
243
|
+
return Array.isArray(proxy)
|
|
244
|
+
? proxy
|
|
245
|
+
: Object.entries(proxy).map(([context, value]) => ({
|
|
246
|
+
context: [context],
|
|
247
|
+
...value,
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
function assertIsError(value) {
|
|
251
|
+
const isError = value instanceof Error ||
|
|
252
|
+
// The following is needing to identify errors coming from RxJs.
|
|
253
|
+
(typeof value === 'object' &&
|
|
254
|
+
value &&
|
|
255
|
+
'name' in value &&
|
|
256
|
+
'message' in value);
|
|
257
|
+
(0, node_assert_1.default)(isError, 'catch clause variable is not an Error instance');
|
|
258
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GlobalEntry } from '../../models';
|
|
2
|
+
export declare function getEntryPoints(globalStyles: GlobalEntry[], globalScripts: GlobalEntry[], isHMREnabled?: boolean): [name: string, isModule: boolean][];
|
|
3
|
+
export declare function getPolyfillsEntry(polyfills: string[], aot: boolean): {
|
|
4
|
+
polyfills?: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function toRspackEntries(entries: GlobalEntry[], root: string, queryString?: string): Record<string, {
|
|
7
|
+
import: string[];
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=entry-points.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-points.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/entry-points.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,WAAW,EAAE,EAC3B,aAAa,EAAE,WAAW,EAAE,EAC5B,YAAY,CAAC,EAAE,OAAO,GACrB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAerC;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,EAAE,OAAO,GACX;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAW1B;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM;YAEmB,MAAM,EAAE;GAahD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntryPoints = getEntryPoints;
|
|
4
|
+
exports.getPolyfillsEntry = getPolyfillsEntry;
|
|
5
|
+
exports.toRspackEntries = toRspackEntries;
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
function getEntryPoints(globalStyles, globalScripts, isHMREnabled) {
|
|
8
|
+
return [
|
|
9
|
+
['runtime', !isHMREnabled],
|
|
10
|
+
['polyfills', true],
|
|
11
|
+
...globalStyles.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
12
|
+
...globalScripts.filter((s) => s.initial).map((s) => [s.name, false]),
|
|
13
|
+
['vendor', true],
|
|
14
|
+
['main', true],
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
function getPolyfillsEntry(polyfills, aot) {
|
|
18
|
+
const normalizedPolyfills = [...polyfills];
|
|
19
|
+
if (!aot) {
|
|
20
|
+
normalizedPolyfills.push('@angular/compiler');
|
|
21
|
+
}
|
|
22
|
+
if (normalizedPolyfills.length) {
|
|
23
|
+
return { polyfills: normalizedPolyfills };
|
|
24
|
+
}
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
function toRspackEntries(entries, root, queryString) {
|
|
28
|
+
const result = {};
|
|
29
|
+
for (const { files, name } of entries) {
|
|
30
|
+
result[name] ??= { import: [] };
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
result[name].import.push((0, node_path_1.join)(root, `${file}${queryString ? `?${queryString}` : ''}`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stats-options.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/get-stats-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,wBAAgB,eAAe,CAAC,OAAO,UAAQ,GAAG,YAAY,CAsC7D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStatsOptions = getStatsOptions;
|
|
4
|
+
function getStatsOptions(verbose = false) {
|
|
5
|
+
const rspackStatsOptions = {
|
|
6
|
+
all: false, // Fallback value for stats options when an option is not defined. It has precedence over local webpack defaults.
|
|
7
|
+
colors: true,
|
|
8
|
+
hash: true, // required by custom stat output
|
|
9
|
+
timings: true, // required by custom stat output
|
|
10
|
+
chunks: true, // required by custom stat output
|
|
11
|
+
builtAt: true, // required by custom stat output
|
|
12
|
+
warnings: true,
|
|
13
|
+
errors: true,
|
|
14
|
+
assets: true, // required by custom stat output
|
|
15
|
+
cachedAssets: true, // required for bundle size calculators
|
|
16
|
+
// Needed for markAsyncChunksNonInitial.
|
|
17
|
+
ids: true,
|
|
18
|
+
entrypoints: true,
|
|
19
|
+
};
|
|
20
|
+
const verboseStatsOutputOptions = {
|
|
21
|
+
// The verbose output will most likely be piped to a file, so colors just mess it up.
|
|
22
|
+
colors: false,
|
|
23
|
+
usedExports: true,
|
|
24
|
+
optimizationBailout: true,
|
|
25
|
+
reasons: true,
|
|
26
|
+
children: true,
|
|
27
|
+
assets: true,
|
|
28
|
+
version: true,
|
|
29
|
+
chunkModules: true,
|
|
30
|
+
errorDetails: true,
|
|
31
|
+
errorStack: true,
|
|
32
|
+
moduleTrace: true,
|
|
33
|
+
logging: 'verbose',
|
|
34
|
+
modulesSpace: Infinity,
|
|
35
|
+
};
|
|
36
|
+
return verbose
|
|
37
|
+
? { ...rspackStatsOptions, ...verboseStatsOutputOptions }
|
|
38
|
+
: rspackStatsOptions;
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AngularRspackPluginOptions, HashFormat, NormalizedAngularRspackPluginOptions, OutputHashing } from '../../models';
|
|
2
|
+
/**
|
|
3
|
+
* Delete an output directory, but error out if it's the root of the project.
|
|
4
|
+
*/
|
|
5
|
+
export declare function deleteOutputDir(root: string, outputPath: string, emptyOnlyDirectories?: string[]): Promise<void>;
|
|
6
|
+
export declare function getOutputHashFormat(outputHashing?: OutputHashing, length?: number): HashFormat;
|
|
7
|
+
export declare function normalizeOptionWithI18n(options: AngularRspackPluginOptions): Promise<{
|
|
8
|
+
i18n: import("@angular/build/private").I18nOptions;
|
|
9
|
+
i18nHash: string | (() => void);
|
|
10
|
+
normalizedOptions: NormalizedAngularRspackPluginOptions;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function getCrossOriginLoading(normalizedOptions: NormalizedAngularRspackPluginOptions): false | "anonymous" | "use-credentials";
|
|
13
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/helpers.ts"],"names":[],"mappings":"AASA,OAAO,EACL,0BAA0B,EAC1B,UAAU,EACV,oCAAoC,EAEpC,aAAa,EACd,MAAM,cAAc,CAAC;AAItB;;GAEG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAgB,mBAAmB,CACjC,aAAa,GAAE,aAAsB,EACrC,MAAM,SAAI,GACT,UAAU,CAkCZ;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,0BAA0B;;;;GAmBpC;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,oCAAoC,2CAcxD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteOutputDir = deleteOutputDir;
|
|
4
|
+
exports.getOutputHashFormat = getOutputHashFormat;
|
|
5
|
+
exports.normalizeOptionWithI18n = normalizeOptionWithI18n;
|
|
6
|
+
exports.getCrossOriginLoading = getCrossOriginLoading;
|
|
7
|
+
/**
|
|
8
|
+
* @license
|
|
9
|
+
* Copyright Google LLC All Rights Reserved.
|
|
10
|
+
*
|
|
11
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
12
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
13
|
+
*/
|
|
14
|
+
const promises_1 = require("node:fs/promises");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const models_1 = require("../../models");
|
|
17
|
+
const create_i18n_options_1 = require("../i18n/create-i18n-options");
|
|
18
|
+
/**
|
|
19
|
+
* Delete an output directory, but error out if it's the root of the project.
|
|
20
|
+
*/
|
|
21
|
+
async function deleteOutputDir(root, outputPath, emptyOnlyDirectories) {
|
|
22
|
+
const resolvedOutputPath = (0, node_path_1.resolve)(root, outputPath);
|
|
23
|
+
if (resolvedOutputPath === root) {
|
|
24
|
+
throw new Error('Output path MUST not be project root directory!');
|
|
25
|
+
}
|
|
26
|
+
const directoriesToEmpty = emptyOnlyDirectories
|
|
27
|
+
? new Set(emptyOnlyDirectories.map((directory) => (0, node_path_1.join)(resolvedOutputPath, directory)))
|
|
28
|
+
: undefined;
|
|
29
|
+
// Avoid removing the actual directory to avoid errors in cases where the output
|
|
30
|
+
// directory is mounted or symlinked. Instead the contents are removed.
|
|
31
|
+
let entries;
|
|
32
|
+
try {
|
|
33
|
+
entries = await (0, promises_1.readdir)(resolvedOutputPath);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
const fullEntry = (0, node_path_1.join)(resolvedOutputPath, entry);
|
|
43
|
+
// Leave requested directories. This allows symlinks to continue to function.
|
|
44
|
+
if (directoriesToEmpty?.has(fullEntry)) {
|
|
45
|
+
await deleteOutputDir(resolvedOutputPath, fullEntry);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
await (0, promises_1.rm)(fullEntry, { force: true, recursive: true, maxRetries: 3 });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function getOutputHashFormat(outputHashing = 'none', length = 8) {
|
|
52
|
+
const hashTemplate = `.[contenthash:${length}]`;
|
|
53
|
+
switch (outputHashing) {
|
|
54
|
+
case 'media':
|
|
55
|
+
return {
|
|
56
|
+
chunk: '',
|
|
57
|
+
extract: '',
|
|
58
|
+
file: hashTemplate,
|
|
59
|
+
script: '',
|
|
60
|
+
};
|
|
61
|
+
case 'bundles':
|
|
62
|
+
return {
|
|
63
|
+
chunk: hashTemplate,
|
|
64
|
+
extract: hashTemplate,
|
|
65
|
+
file: '',
|
|
66
|
+
script: hashTemplate,
|
|
67
|
+
};
|
|
68
|
+
case 'all':
|
|
69
|
+
return {
|
|
70
|
+
chunk: hashTemplate,
|
|
71
|
+
extract: hashTemplate,
|
|
72
|
+
file: hashTemplate,
|
|
73
|
+
script: hashTemplate,
|
|
74
|
+
};
|
|
75
|
+
case 'none':
|
|
76
|
+
default:
|
|
77
|
+
return {
|
|
78
|
+
chunk: '',
|
|
79
|
+
extract: '',
|
|
80
|
+
file: '',
|
|
81
|
+
script: '',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function normalizeOptionWithI18n(options) {
|
|
86
|
+
const { options: _options, i18n } = await (0, create_i18n_options_1.configureI18n)(options.root ?? process.cwd(), options);
|
|
87
|
+
// Update file hashes to include translation file content
|
|
88
|
+
const i18nHash = i18n.shouldInline
|
|
89
|
+
? Object.values(i18n.locales).reduce((data, locale) => data + locale.files.map((file) => file.integrity || '').join('|'), '')
|
|
90
|
+
: () => {
|
|
91
|
+
// no-op as i18n is not inlined
|
|
92
|
+
};
|
|
93
|
+
const normalizedOptions = await (0, models_1.normalizeOptions)(_options);
|
|
94
|
+
return { i18n, i18nHash, normalizedOptions };
|
|
95
|
+
}
|
|
96
|
+
function getCrossOriginLoading(normalizedOptions) {
|
|
97
|
+
let crossOriginLoading = false;
|
|
98
|
+
if (normalizedOptions.subresourceIntegrity &&
|
|
99
|
+
normalizedOptions.crossOrigin === 'none') {
|
|
100
|
+
crossOriginLoading = 'anonymous';
|
|
101
|
+
}
|
|
102
|
+
else if (normalizedOptions.crossOrigin !== 'none') {
|
|
103
|
+
crossOriginLoading = normalizedOptions.crossOrigin;
|
|
104
|
+
}
|
|
105
|
+
return crossOriginLoading;
|
|
106
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
|
+
import { NormalizedAngularRspackPluginOptions } from '../../models';
|
|
3
|
+
export declare const VENDORS_TEST: RegExp;
|
|
4
|
+
export declare function getOptimization(normalizedOptions: NormalizedAngularRspackPluginOptions, platform: 'browser' | 'server'): Configuration['optimization'];
|
|
5
|
+
//# sourceMappingURL=optimization-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimization-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/optimization-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAGpE,eAAO,MAAM,YAAY,QAA2B,CAAC;AAErD,wBAAgB,eAAe,CAC7B,iBAAiB,EAAE,oCAAoC,EACvD,QAAQ,EAAE,SAAS,GAAG,QAAQ,GAC7B,aAAa,CAAC,cAAc,CAAC,CA6D/B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VENDORS_TEST = void 0;
|
|
4
|
+
exports.getOptimization = getOptimization;
|
|
5
|
+
const core_1 = require("@rspack/core");
|
|
6
|
+
const transfer_size_plugin_1 = require("../../plugins/transfer-size-plugin");
|
|
7
|
+
exports.VENDORS_TEST = /[\\/]node_modules[\\/]/;
|
|
8
|
+
function getOptimization(normalizedOptions, platform) {
|
|
9
|
+
return {
|
|
10
|
+
chunkIds: normalizedOptions.namedChunks ? 'named' : 'deterministic',
|
|
11
|
+
emitOnErrors: false,
|
|
12
|
+
moduleIds: 'deterministic',
|
|
13
|
+
runtimeChunk: platform === 'browser' ? 'single' : false,
|
|
14
|
+
minimizer: normalizedOptions.optimization.scripts
|
|
15
|
+
? [
|
|
16
|
+
new core_1.SwcJsMinimizerRspackPlugin({
|
|
17
|
+
minimizerOptions: {
|
|
18
|
+
minify: true,
|
|
19
|
+
...(platform === 'server'
|
|
20
|
+
? {
|
|
21
|
+
mangle: {
|
|
22
|
+
reserved: [
|
|
23
|
+
'renderApplication',
|
|
24
|
+
'renderModule',
|
|
25
|
+
'ɵSERVER_CONTEXT',
|
|
26
|
+
'ɵgetRoutesFromAngularRouterConfig',
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
: {}),
|
|
31
|
+
format: {
|
|
32
|
+
comments: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
new core_1.LightningCssMinimizerRspackPlugin(),
|
|
37
|
+
...(platform === 'browser' ? [new transfer_size_plugin_1.TransferSizePlugin()] : []),
|
|
38
|
+
]
|
|
39
|
+
: [],
|
|
40
|
+
splitChunks: {
|
|
41
|
+
chunks: platform === 'browser' ? 'all' : 'async',
|
|
42
|
+
minChunks: 1,
|
|
43
|
+
minSize: 20000,
|
|
44
|
+
maxAsyncRequests: 30,
|
|
45
|
+
maxInitialRequests: 30,
|
|
46
|
+
cacheGroups: {
|
|
47
|
+
default: normalizedOptions.commonChunk && {
|
|
48
|
+
chunks: 'async',
|
|
49
|
+
minChunks: 2,
|
|
50
|
+
priority: 10,
|
|
51
|
+
},
|
|
52
|
+
common: normalizedOptions.commonChunk && {
|
|
53
|
+
name: 'common',
|
|
54
|
+
chunks: 'async',
|
|
55
|
+
minChunks: 2,
|
|
56
|
+
enforce: true,
|
|
57
|
+
priority: 5,
|
|
58
|
+
},
|
|
59
|
+
vendors: false,
|
|
60
|
+
defaultVendors: normalizedOptions.vendorChunk && {
|
|
61
|
+
name: 'vendor',
|
|
62
|
+
chunks: (chunk) => chunk.name === 'main',
|
|
63
|
+
enforce: true,
|
|
64
|
+
test: exports.VENDORS_TEST,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Configuration } from '@rspack/core';
|
|
2
|
+
import type { I18nOptions, NormalizedAngularRspackPluginOptions } from '../../models';
|
|
3
|
+
export declare function getServerConfig(normalizedOptions: NormalizedAngularRspackPluginOptions, i18n: I18nOptions, defaultConfig: Configuration): Promise<Configuration>;
|
|
4
|
+
//# sourceMappingURL=server-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../../../src/lib/config/config-utils/server-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAA4B,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EACV,WAAW,EACX,oCAAoC,EACrC,MAAM,cAAc,CAAC;AAOtB,wBAAsB,eAAe,CACnC,iBAAiB,EAAE,oCAAoC,EACvD,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,aAAa,CAAC,CAmFxB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getServerConfig = getServerConfig;
|
|
4
|
+
const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
|
|
5
|
+
const core_1 = require("@rspack/core");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const ng_rspack_1 = require("../../plugins/ng-rspack");
|
|
8
|
+
const prerender_plugin_1 = require("../../plugins/prerender-plugin");
|
|
9
|
+
const misc_helpers_1 = require("../../utils/misc-helpers");
|
|
10
|
+
const dev_server_config_utils_1 = require("./dev-server-config-utils");
|
|
11
|
+
const optimization_config_1 = require("./optimization-config");
|
|
12
|
+
async function getServerConfig(normalizedOptions, i18n, defaultConfig) {
|
|
13
|
+
const isDevServer = !!process.env['WEBPACK_SERVE'];
|
|
14
|
+
const { root } = normalizedOptions;
|
|
15
|
+
return {
|
|
16
|
+
...defaultConfig,
|
|
17
|
+
dependencies: ['browser'],
|
|
18
|
+
name: 'server',
|
|
19
|
+
target: ['node', 'es2015'],
|
|
20
|
+
entry: {
|
|
21
|
+
server: {
|
|
22
|
+
import: [
|
|
23
|
+
...((0, misc_helpers_1.isPackageInstalled)(root, '@angular/platform-server')
|
|
24
|
+
? // This import must come before any imports (direct or transitive) that rely on DOM built-ins being
|
|
25
|
+
// available, such as `@angular/elements`.
|
|
26
|
+
['@angular/platform-server/init']
|
|
27
|
+
: []),
|
|
28
|
+
...(i18n.shouldInline ? ['@angular/localize/init'] : []),
|
|
29
|
+
normalizedOptions.ssr.entry,
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
output: {
|
|
34
|
+
...defaultConfig.output,
|
|
35
|
+
path: normalizedOptions.outputPath.server,
|
|
36
|
+
filename: '[name].js',
|
|
37
|
+
chunkFilename: '[name].js',
|
|
38
|
+
library: { type: 'commonjs' },
|
|
39
|
+
},
|
|
40
|
+
resolve: {
|
|
41
|
+
...defaultConfig.resolve,
|
|
42
|
+
mainFields: ['es2020', 'es2015', 'module', 'main'],
|
|
43
|
+
},
|
|
44
|
+
devServer: await (0, dev_server_config_utils_1.getDevServerConfig)(normalizedOptions, 'server'),
|
|
45
|
+
externals: normalizedOptions.externalDependencies,
|
|
46
|
+
optimization: (0, optimization_config_1.getOptimization)(normalizedOptions, 'server'),
|
|
47
|
+
module: {
|
|
48
|
+
...defaultConfig.module,
|
|
49
|
+
rules: [
|
|
50
|
+
{
|
|
51
|
+
test: angular_rspack_compiler_1.TS_ALL_EXT_REGEX,
|
|
52
|
+
use: [
|
|
53
|
+
{
|
|
54
|
+
loader: 'builtin:swc-loader',
|
|
55
|
+
options: {
|
|
56
|
+
jsc: {
|
|
57
|
+
parser: {
|
|
58
|
+
syntax: 'typescript',
|
|
59
|
+
},
|
|
60
|
+
target: 'es2022',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
loader: require.resolve('@nx/angular-rspack/loaders/platform-server-exports-loader'),
|
|
68
|
+
include: [
|
|
69
|
+
(0, path_1.resolve)(root, normalizedOptions.ssr.entry),
|
|
70
|
+
],
|
|
71
|
+
options: {
|
|
72
|
+
angularSSRInstalled: (0, misc_helpers_1.isPackageInstalled)(root, '@angular/ssr'),
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
...(defaultConfig.module?.rules ?? []),
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
plugins: [
|
|
79
|
+
...(defaultConfig.plugins ?? []),
|
|
80
|
+
// Fixes Critical dependency: the request of a dependency is an expression
|
|
81
|
+
new core_1.ContextReplacementPlugin(/@?hapi|express[\\/]/),
|
|
82
|
+
new ng_rspack_1.NgRspackPlugin(normalizedOptions, {
|
|
83
|
+
i18nOptions: i18n,
|
|
84
|
+
platform: 'server',
|
|
85
|
+
}),
|
|
86
|
+
...(normalizedOptions.prerender ||
|
|
87
|
+
(normalizedOptions.appShell && !isDevServer)
|
|
88
|
+
? [new prerender_plugin_1.PrerenderPlugin(normalizedOptions, i18n)]
|
|
89
|
+
: []),
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|