@nx/angular-rspack 19.0.0-alpha.30
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 +21 -0
- package/README.md +15 -0
- package/code-pushup.config.ts +13 -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 +417 -0
- package/dist/lib/config/dev-server-config-utils.d.ts +3 -0
- package/dist/lib/config/dev-server-config-utils.d.ts.map +1 -0
- package/dist/lib/config/dev-server-config-utils.js +101 -0
- package/dist/lib/config/helpers.d.ts +3 -0
- package/dist/lib/config/helpers.d.ts.map +1 -0
- package/dist/lib/config/helpers.js +37 -0
- package/dist/lib/config/style-config-utils.d.ts +261 -0
- package/dist/lib/config/style-config-utils.d.ts.map +1 -0
- package/dist/lib/config/style-config-utils.js +62 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/models/angular-rspack-plugin-options.d.ts +114 -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 +11 -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/index.d.ts +4 -0
- package/dist/lib/models/index.d.ts.map +1 -0
- package/dist/lib/models/index.js +6 -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 +362 -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 +148 -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 +49 -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 +16 -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 +36 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.d.ts +3 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.d.ts.map +1 -0
- package/dist/lib/plugins/loaders/angular-transform.loader.js +39 -0
- package/dist/lib/plugins/ng-rspack.d.ts +8 -0
- package/dist/lib/plugins/ng-rspack.d.ts.map +1 -0
- package/dist/lib/plugins/ng-rspack.js +114 -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 +18 -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/ssr/server.d.ts +13 -0
- package/dist/lib/ssr/server.d.ts.map +1 -0
- package/dist/lib/ssr/server.js +47 -0
- package/eslint.next.config.js +42 -0
- package/package.json +83 -0
- package/vitest.config.mts +21 -0
- package/vitest.integration.config.mts +28 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = loader;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const models_1 = require("../../models");
|
|
6
|
+
const angular_rspack_compiler_1 = require("@nx/angular-rspack-compiler");
|
|
7
|
+
const styleUrlsResolver = new angular_rspack_compiler_1.StyleUrlsResolver();
|
|
8
|
+
const templateUrlsResolver = new angular_rspack_compiler_1.TemplateUrlsResolver();
|
|
9
|
+
function loader(content) {
|
|
10
|
+
const callback = this.async();
|
|
11
|
+
if (this._compilation[models_1.NG_RSPACK_SYMBOL_NAME] ===
|
|
12
|
+
undefined) {
|
|
13
|
+
callback(null, content);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const { typescriptFileCache } = this._compilation[models_1.NG_RSPACK_SYMBOL_NAME]();
|
|
17
|
+
const request = this.resourcePath;
|
|
18
|
+
const normalizedRequest = (0, path_1.normalize)(request);
|
|
19
|
+
const templateUrls = templateUrlsResolver.resolve(content, normalizedRequest);
|
|
20
|
+
const styleUrls = styleUrlsResolver.resolve(content, normalizedRequest);
|
|
21
|
+
for (const urlSet of [...templateUrls, ...styleUrls]) {
|
|
22
|
+
// `urlSet` is a string where a relative path is joined with an
|
|
23
|
+
// absolute path using the `|` symbol.
|
|
24
|
+
// For example: `./app.component.html|/home/projects/analog/src/app/app.component.html`.
|
|
25
|
+
const [, absoluteFileUrl] = urlSet.split('|');
|
|
26
|
+
this.addDependency(absoluteFileUrl);
|
|
27
|
+
}
|
|
28
|
+
const contents = typescriptFileCache.get(normalizedRequest);
|
|
29
|
+
if (contents === undefined) {
|
|
30
|
+
callback(null, content);
|
|
31
|
+
}
|
|
32
|
+
else if (typeof contents === 'string') {
|
|
33
|
+
callback(null, contents);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
callback(null, Buffer.from(contents));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
2
|
+
import { NormalizedAngularRspackPluginOptions } from '../models';
|
|
3
|
+
export declare class NgRspackPlugin implements RspackPluginInstance {
|
|
4
|
+
pluginOptions: NormalizedAngularRspackPluginOptions;
|
|
5
|
+
constructor(options: NormalizedAngularRspackPluginOptions);
|
|
6
|
+
apply(compiler: Compiler): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ng-rspack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ng-rspack.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/ng-rspack.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,oCAAoC,EAAc,MAAM,WAAW,CAAC;AAG7E,qBAAa,cAAe,YAAW,oBAAoB;IACzD,aAAa,EAAE,oCAAoC,CAAC;gBAExC,OAAO,EAAE,oCAAoC;IAIzD,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAkHzB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NgRspackPlugin = void 0;
|
|
4
|
+
const core_1 = require("@rspack/core");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const rxjs_esm_resolution_1 = require("./rxjs-esm-resolution");
|
|
7
|
+
const angular_rspack_plugin_1 = require("./angular-rspack-plugin");
|
|
8
|
+
const angular_ssr_dev_server_1 = require("./angular-ssr-dev-server");
|
|
9
|
+
class NgRspackPlugin {
|
|
10
|
+
pluginOptions;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.pluginOptions = options;
|
|
13
|
+
}
|
|
14
|
+
apply(compiler) {
|
|
15
|
+
const root = this.pluginOptions.root;
|
|
16
|
+
const isProduction = process.env['NODE_ENV'] === 'production';
|
|
17
|
+
const isDevServer = process.env['WEBPACK_SERVE'];
|
|
18
|
+
const polyfills = this.pluginOptions.polyfills ?? [];
|
|
19
|
+
if (polyfills.length > 0) {
|
|
20
|
+
compiler.hooks.entryOption.tap('NgRspackPlugin', (context, entry) => {
|
|
21
|
+
const keys = Object.keys(entry);
|
|
22
|
+
for (const key of keys) {
|
|
23
|
+
const entryValue = entry[key];
|
|
24
|
+
entryValue.import = [...polyfills, ...entryValue.import];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (!this.pluginOptions.hasServer) {
|
|
29
|
+
// @TODO: properly handle global styles and scripts
|
|
30
|
+
const styles = this.pluginOptions.globalStyles ?? [];
|
|
31
|
+
for (const style of styles) {
|
|
32
|
+
for (const file of style.files) {
|
|
33
|
+
new core_1.EntryPlugin(compiler.context, file, {
|
|
34
|
+
name: isProduction ? style.name : undefined,
|
|
35
|
+
}).apply(compiler);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const scripts = this.pluginOptions.globalScripts ?? [];
|
|
39
|
+
for (const script of scripts) {
|
|
40
|
+
for (const file of script.files) {
|
|
41
|
+
new core_1.EntryPlugin(compiler.context, file, {
|
|
42
|
+
name: isProduction ? script.name : undefined,
|
|
43
|
+
}).apply(compiler);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (this.pluginOptions.index) {
|
|
47
|
+
new core_1.HtmlRspackPlugin({
|
|
48
|
+
minify: false,
|
|
49
|
+
inject: 'body',
|
|
50
|
+
scriptLoading: 'module',
|
|
51
|
+
template: this.pluginOptions.index.input,
|
|
52
|
+
chunks: this.pluginOptions.index.insertionOrder.map(([name]) => name),
|
|
53
|
+
}).apply(compiler);
|
|
54
|
+
}
|
|
55
|
+
if (this.pluginOptions.ssr &&
|
|
56
|
+
typeof this.pluginOptions.ssr === 'object' &&
|
|
57
|
+
this.pluginOptions.ssr.entry !== undefined) {
|
|
58
|
+
new angular_ssr_dev_server_1.AngularSsrDevServer(this.pluginOptions.outputPath).apply(compiler);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!isDevServer) {
|
|
62
|
+
new core_1.ProgressPlugin().apply(compiler);
|
|
63
|
+
}
|
|
64
|
+
new core_1.DefinePlugin({
|
|
65
|
+
ngDevMode: isProduction ? 'false' : {},
|
|
66
|
+
ngJitMode: this.pluginOptions.aot ? undefined : 'true',
|
|
67
|
+
ngServerMode: this.pluginOptions.hasServer,
|
|
68
|
+
}).apply(compiler);
|
|
69
|
+
if (this.pluginOptions.assets) {
|
|
70
|
+
new core_1.CopyRspackPlugin({
|
|
71
|
+
patterns: (this.pluginOptions.assets ?? []).map((asset) => {
|
|
72
|
+
let { input, output = '' } = asset;
|
|
73
|
+
input = (0, node_path_1.resolve)(root, input).replace(/\\/g, '/');
|
|
74
|
+
input = input.endsWith('/') ? input : input + '/';
|
|
75
|
+
output = output.endsWith('/') ? output : output + '/';
|
|
76
|
+
if (output.startsWith('..')) {
|
|
77
|
+
throw new Error('An asset cannot be written to a location outside of the output path.');
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
context: input,
|
|
81
|
+
to: output.replace(/^\//, ''),
|
|
82
|
+
from: asset.glob,
|
|
83
|
+
noErrorOnMissing: true,
|
|
84
|
+
force: true,
|
|
85
|
+
globOptions: {
|
|
86
|
+
dot: true,
|
|
87
|
+
ignore: [
|
|
88
|
+
'.gitkeep',
|
|
89
|
+
'**/.DS_Store',
|
|
90
|
+
'**/Thumbs.db',
|
|
91
|
+
...(asset.ignore ?? []),
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
}).apply(compiler);
|
|
97
|
+
}
|
|
98
|
+
if (this.pluginOptions.extractLicenses) {
|
|
99
|
+
const { LicenseWebpackPlugin } = require('license-webpack-plugin');
|
|
100
|
+
new LicenseWebpackPlugin({
|
|
101
|
+
stats: {
|
|
102
|
+
warnings: false,
|
|
103
|
+
errors: false,
|
|
104
|
+
},
|
|
105
|
+
perChunkOutput: false,
|
|
106
|
+
outputFilename: node_path_1.posix.join((0, node_path_1.relative)(this.pluginOptions.outputPath.browser, this.pluginOptions.outputPath.base), '3rdpartylicenses.txt'),
|
|
107
|
+
skipChildCompilers: true,
|
|
108
|
+
}).apply(compiler);
|
|
109
|
+
}
|
|
110
|
+
new rxjs_esm_resolution_1.RxjsEsmResolutionPlugin().apply(compiler);
|
|
111
|
+
new angular_rspack_plugin_1.AngularRspackPlugin(this.pluginOptions).apply(compiler);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.NgRspackPlugin = NgRspackPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rxjs-esm-resolution.d.ts","sourceRoot":"","sources":["../../../src/lib/plugins/rxjs-esm-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE9D,qBAAa,uBAAwB,YAAW,oBAAoB;IAClE,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAezB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RxjsEsmResolutionPlugin = void 0;
|
|
4
|
+
class RxjsEsmResolutionPlugin {
|
|
5
|
+
apply(compiler) {
|
|
6
|
+
compiler.hooks.normalModuleFactory.tap('RxJSEsmResolution', (normalModuleFactory) => {
|
|
7
|
+
normalModuleFactory.hooks.resolve.tap('RxJSEsmResolution', (data) => {
|
|
8
|
+
if (data.request.startsWith('rxjs')) {
|
|
9
|
+
data.request = data.request.replace(/([\\/]dist[\\/])cjs([\\/])/, '$1esm$2');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RxjsEsmResolutionPlugin = RxjsEsmResolutionPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-reload-server.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/server/ssr-reload-server.ts"],"names":[],"mappings":"AAEA,qBAAa,eAAe;;;IAS1B,UAAU;CAKX"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SsrReloadServer = void 0;
|
|
4
|
+
const ws_1 = require("ws");
|
|
5
|
+
class SsrReloadServer {
|
|
6
|
+
#server;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.#server = new ws_1.WebSocket.Server({ port: 60_000 });
|
|
9
|
+
process.on('SIGTERM', () => this.#server.close());
|
|
10
|
+
process.on('exit', () => this.#server.close());
|
|
11
|
+
}
|
|
12
|
+
sendReload() {
|
|
13
|
+
this.#server.clients.forEach((client) => {
|
|
14
|
+
client.send('ssr-reload');
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.SsrReloadServer = SsrReloadServer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
9
|
+
/**
|
|
10
|
+
* This plugin adds a field to source maps that identifies which sources are
|
|
11
|
+
* vendored or runtime-injected (aka third-party) sources. These are consumed by
|
|
12
|
+
* Chrome DevTools to automatically ignore-list sources.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DevToolsIgnorePlugin implements RspackPluginInstance {
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=dev-tools-ignore-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-tools-ignore-plugin.d.ts","sourceRoot":"","sources":["../../../../src/lib/plugins/tools/dev-tools-ignore-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAe,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAa3E;;;;GAIG;AACH,qBAAa,oBAAqB,YAAW,oBAAoB;IAC/D,KAAK,CAAC,QAAQ,EAAE,QAAQ;CA4CzB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.DevToolsIgnorePlugin = void 0;
|
|
11
|
+
const core_1 = require("@rspack/core");
|
|
12
|
+
// Following the naming conventions from
|
|
13
|
+
// https://sourcemaps.info/spec.html#h.ghqpj1ytqjbm
|
|
14
|
+
const IGNORE_LIST = 'x_google_ignoreList';
|
|
15
|
+
const PLUGIN_NAME = 'devtools-ignore-plugin';
|
|
16
|
+
/**
|
|
17
|
+
* This plugin adds a field to source maps that identifies which sources are
|
|
18
|
+
* vendored or runtime-injected (aka third-party) sources. These are consumed by
|
|
19
|
+
* Chrome DevTools to automatically ignore-list sources.
|
|
20
|
+
*/
|
|
21
|
+
class DevToolsIgnorePlugin {
|
|
22
|
+
apply(compiler) {
|
|
23
|
+
const { RawSource } = compiler.rspack.sources;
|
|
24
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
25
|
+
compilation.hooks.processAssets.tap({
|
|
26
|
+
name: PLUGIN_NAME,
|
|
27
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING,
|
|
28
|
+
}, (assets) => {
|
|
29
|
+
for (const [name, asset] of Object.entries(assets)) {
|
|
30
|
+
// Instead of using `asset.map()` to fetch the source maps from
|
|
31
|
+
// SourceMapSource assets, process them directly as a RawSource.
|
|
32
|
+
// This is because `.map()` is slow and can take several seconds.
|
|
33
|
+
if (!name.endsWith('.map')) {
|
|
34
|
+
// Ignore non source map files.
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const mapContent = asset.source().toString();
|
|
38
|
+
if (!mapContent) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const map = JSON.parse(mapContent);
|
|
42
|
+
const ignoreList = [];
|
|
43
|
+
for (const [index, path] of map.sources.entries()) {
|
|
44
|
+
if (path.includes('/node_modules/') ||
|
|
45
|
+
path.startsWith('webpack/') ||
|
|
46
|
+
path.startsWith('rspack/')) {
|
|
47
|
+
ignoreList.push(index);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
map[IGNORE_LIST] = ignoreList;
|
|
51
|
+
compilation.updateAsset(name, new RawSource(JSON.stringify(map)));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.DevToolsIgnorePlugin = DevToolsIgnorePlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
interface RspackAngularServer {
|
|
3
|
+
app: express.Express;
|
|
4
|
+
listen: (port?: number) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface RspackAngularServerOptions {
|
|
7
|
+
serverDistFolder?: string;
|
|
8
|
+
browserDistFolder?: string;
|
|
9
|
+
indexHtml?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createServer(bootstrap: any, opts?: RspackAngularServerOptions): RspackAngularServer;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/lib/ssr/server.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,UAAU,mBAAmB;IAC3B,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,GAAG,EACd,IAAI,CAAC,EAAE,0BAA0B,GAChC,mBAAmB,CAmDrB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createServer = createServer;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@angular/common");
|
|
6
|
+
const node_1 = require("@angular/ssr/node");
|
|
7
|
+
const express_1 = tslib_1.__importDefault(require("express"));
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
9
|
+
function createServer(bootstrap, opts) {
|
|
10
|
+
const serverDistFolder = opts?.serverDistFolder ?? (0, node_path_1.dirname)(__filename);
|
|
11
|
+
const browserDistFolder = opts?.browserDistFolder ?? (0, node_path_1.resolve)(serverDistFolder, '../browser');
|
|
12
|
+
const indexHtml = opts?.indexHtml ?? (0, node_path_1.join)(browserDistFolder, 'index.html');
|
|
13
|
+
const app = (0, express_1.default)();
|
|
14
|
+
const commonEngine = new node_1.CommonEngine();
|
|
15
|
+
app.get('**', express_1.default.static(browserDistFolder, {
|
|
16
|
+
maxAge: '1y',
|
|
17
|
+
index: false,
|
|
18
|
+
}));
|
|
19
|
+
/**
|
|
20
|
+
* Handle all other requests by rendering the Angular application.
|
|
21
|
+
*/
|
|
22
|
+
app.get('**', async (req, res, next) => {
|
|
23
|
+
const { protocol, originalUrl, baseUrl, headers } = req;
|
|
24
|
+
commonEngine
|
|
25
|
+
.render({
|
|
26
|
+
bootstrap,
|
|
27
|
+
documentFilePath: indexHtml,
|
|
28
|
+
url: `${protocol}://${headers.host}${originalUrl}`,
|
|
29
|
+
publicPath: browserDistFolder,
|
|
30
|
+
providers: [{ provide: common_1.APP_BASE_HREF, useValue: baseUrl }],
|
|
31
|
+
})
|
|
32
|
+
.then((html) => {
|
|
33
|
+
res.send(html);
|
|
34
|
+
})
|
|
35
|
+
.catch((err) => next(err));
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
app,
|
|
39
|
+
listen: (port = process.env['PORT']
|
|
40
|
+
? Number.parseInt(process.env['PORT'], 10)
|
|
41
|
+
: 4000) => {
|
|
42
|
+
app.listen(port, () => {
|
|
43
|
+
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const baseConfig = require('../../eslint.config.js');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
...baseConfig,
|
|
5
|
+
{
|
|
6
|
+
files: ['**/*.ts'],
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parserOptions: {
|
|
9
|
+
projectService: true,
|
|
10
|
+
tsconfigRootDir: __dirname,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
files: ['**/*.json'],
|
|
16
|
+
rules: {
|
|
17
|
+
'@nx/dependency-checks': [
|
|
18
|
+
'error',
|
|
19
|
+
{
|
|
20
|
+
ignoredFiles: [
|
|
21
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
|
22
|
+
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
|
|
23
|
+
'{projectRoot}/vitest*.config.{js,ts,mjs,mts}',
|
|
24
|
+
],
|
|
25
|
+
ignoredDependencies: [
|
|
26
|
+
'nx',
|
|
27
|
+
'css-loader',
|
|
28
|
+
'less-loader',
|
|
29
|
+
'sass-loader',
|
|
30
|
+
'sass-embedded',
|
|
31
|
+
'@angular/core',
|
|
32
|
+
'rxjs',
|
|
33
|
+
'@ng-rspack/build',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parser: require('jsonc-eslint-parser'),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/angular-rspack",
|
|
3
|
+
"version": "19.0.0-alpha.30",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"description": "Rspack Plugin and Loaders for building Angular.",
|
|
9
|
+
"author": "Colum Ferry",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/nrwl/angular-rspack/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/nrwl/angular-rspack.git",
|
|
17
|
+
"directory": "packages/angular-rspack"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"Monorepo",
|
|
21
|
+
"Angular",
|
|
22
|
+
"Rspack"
|
|
23
|
+
],
|
|
24
|
+
"type": "commonjs",
|
|
25
|
+
"main": "./dist/lib/index.js",
|
|
26
|
+
"types": "./dist/lib/index.d.ts",
|
|
27
|
+
"typings": "./dist/lib/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/lib/index.d.ts",
|
|
31
|
+
"default": "./dist/lib/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./loaders/angular-partial-transform-loader": {
|
|
34
|
+
"types": "./dist/lib/plugins/loaders/angular-partial-transform.loader.d.ts",
|
|
35
|
+
"default": "./dist/lib/plugins/loaders/angular-partial-transform.loader.js"
|
|
36
|
+
},
|
|
37
|
+
"./loaders/angular-loader": {
|
|
38
|
+
"types": "./dist/lib/plugins/loaders/angular-transform.loader.d.ts",
|
|
39
|
+
"default": "./dist/lib/plugins/loaders/angular-transform.loader.js"
|
|
40
|
+
},
|
|
41
|
+
"./ssr": {
|
|
42
|
+
"types": "./dist/lib/ssr/server.d.ts",
|
|
43
|
+
"default": "./dist/lib/ssr/server.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@nx/devkit": "^20.0.0",
|
|
48
|
+
"express": "4.21.1",
|
|
49
|
+
"source-map-loader": "^5.0.0",
|
|
50
|
+
"jsonc-parser": "^3.3.1",
|
|
51
|
+
"less-loader": "^12.2.0",
|
|
52
|
+
"license-webpack-plugin": "^4.0.2",
|
|
53
|
+
"sass-embedded": "^1.79.3",
|
|
54
|
+
"sass-loader": "^16.0.2",
|
|
55
|
+
"css-loader": "^7.1.2",
|
|
56
|
+
"tslib": "^2.3.0",
|
|
57
|
+
"webpack-merge": "^6.0.1",
|
|
58
|
+
"ws": "^8.18.0",
|
|
59
|
+
"@nx/angular-rspack-compiler": "19.0.0-alpha.30"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@ng-rspack/testing-setup": "0.0.1"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"@rspack/core": ">=1.0.5 <2.0.0",
|
|
66
|
+
"@angular/common": ">=19.0.0 <20.0.0",
|
|
67
|
+
"@angular/ssr": ">=19.0.0 <20.0.0"
|
|
68
|
+
},
|
|
69
|
+
"nx": {
|
|
70
|
+
"name": "angular-rspack",
|
|
71
|
+
"sourceRoot": "packages/angular-rspack/src",
|
|
72
|
+
"projectType": "library",
|
|
73
|
+
"targets": {
|
|
74
|
+
"code-pushup": {},
|
|
75
|
+
"unit-test": {
|
|
76
|
+
"dependsOn": [
|
|
77
|
+
"build"
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"scripts": {}
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { EXCLUDED_FILES_TEST } from '@ng-rspack/testing-setup';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
cacheDir: '../../node_modules/.vite/ng-rspack-build/unit',
|
|
6
|
+
root: __dirname,
|
|
7
|
+
test: {
|
|
8
|
+
watch: false,
|
|
9
|
+
globals: true,
|
|
10
|
+
environment: 'node',
|
|
11
|
+
include: ['src/**/*.unit.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
12
|
+
coverage: {
|
|
13
|
+
provider: 'v8',
|
|
14
|
+
reporter: ['text', 'lcov'],
|
|
15
|
+
reportsDirectory: '../../coverage/build/unit',
|
|
16
|
+
exclude: [...EXCLUDED_FILES_TEST],
|
|
17
|
+
},
|
|
18
|
+
reporters: ['default'],
|
|
19
|
+
passWithNoTests: true,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { EXCLUDED_FILES_TEST } from '@ng-rspack/testing-setup';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
root: __dirname,
|
|
7
|
+
cacheDir: '../../node_modules/.vite/build/integration',
|
|
8
|
+
plugins: [],
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'@ng-rspack/testing-utils': resolve(__dirname, '../../testing/utils/src'),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
test: {
|
|
15
|
+
watch: false,
|
|
16
|
+
globals: true,
|
|
17
|
+
environment: 'node',
|
|
18
|
+
include: ['src/**/*.integration.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
|
19
|
+
passWithNoTests: true,
|
|
20
|
+
reporters: ['default'],
|
|
21
|
+
coverage: {
|
|
22
|
+
provider: 'v8',
|
|
23
|
+
reporter: ['text', 'lcov'],
|
|
24
|
+
reportsDirectory: '../../coverage/build/integration',
|
|
25
|
+
exclude: [...EXCLUDED_FILES_TEST],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
});
|