@nx/rspack 19.6.0 → 19.7.0
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/executors.json +15 -0
- package/migrations.json +17 -0
- package/module-federation.d.ts +1 -0
- package/module-federation.js +5 -0
- package/module-federation.js.map +1 -0
- package/package.json +9 -4
- package/src/executors/dev-server/dev-server.impl.d.ts +4 -1
- package/src/executors/dev-server/dev-server.impl.js +11 -11
- package/src/executors/dev-server/dev-server.impl.js.map +1 -1
- package/src/executors/dev-server/lib/get-dev-server-config.d.ts +4 -0
- package/src/executors/dev-server/lib/get-dev-server-config.js +71 -0
- package/src/executors/dev-server/lib/get-dev-server-config.js.map +1 -0
- package/src/executors/dev-server/lib/serve-path.d.ts +3 -0
- package/src/executors/dev-server/lib/serve-path.js +45 -0
- package/src/executors/dev-server/lib/serve-path.js.map +1 -0
- package/src/executors/dev-server/schema.d.ts +5 -1
- package/src/executors/dev-server/schema.json +30 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +19 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +230 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-dev-server/schema.json +100 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.d.ts +21 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +209 -0
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +1 -0
- package/src/executors/module-federation-ssr-dev-server/schema.json +82 -0
- package/src/executors/rspack/rspack.impl.js +3 -3
- package/src/executors/rspack/rspack.impl.js.map +1 -1
- package/src/executors/rspack/schema.d.ts +10 -1
- package/src/executors/rspack/schema.json +61 -7
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.d.ts +1 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js +40 -0
- package/src/executors/ssr-dev-server/lib/wait-until-server-is-listening.js.map +1 -0
- package/src/executors/ssr-dev-server/schema.d.ts +11 -0
- package/src/executors/ssr-dev-server/schema.json +39 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.d.ts +8 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js +52 -0
- package/src/executors/ssr-dev-server/ssr-dev-server.impl.js.map +1 -0
- package/src/generators/application/application.js +2 -2
- package/src/generators/application/application.js.map +1 -1
- package/src/utils/create-compiler.d.ts +3 -1
- package/src/utils/create-compiler.js +12 -2
- package/src/utils/create-compiler.js.map +1 -1
- package/src/utils/module-federation/dependencies.d.ts +6 -0
- package/src/utils/module-federation/dependencies.js +58 -0
- package/src/utils/module-federation/dependencies.js.map +1 -0
- package/src/utils/module-federation/get-remotes-for-host.d.ts +16 -0
- package/src/utils/module-federation/get-remotes-for-host.js +103 -0
- package/src/utils/module-federation/get-remotes-for-host.js.map +1 -0
- package/src/utils/module-federation/index.d.ts +6 -0
- package/src/utils/module-federation/index.js +10 -0
- package/src/utils/module-federation/index.js.map +1 -0
- package/src/utils/module-federation/models/index.d.ts +47 -0
- package/src/utils/module-federation/models/index.js +3 -0
- package/src/utils/module-federation/models/index.js.map +1 -0
- package/src/utils/module-federation/package-json.d.ts +8 -0
- package/src/utils/module-federation/package-json.js +13 -0
- package/src/utils/module-federation/package-json.js.map +1 -0
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +13 -0
- package/src/utils/module-federation/parse-static-remotes-config.js +35 -0
- package/src/utils/module-federation/parse-static-remotes-config.js.map +1 -0
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +3 -0
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +55 -0
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js.map +1 -0
- package/src/utils/module-federation/public-api.d.ts +8 -0
- package/src/utils/module-federation/public-api.js +21 -0
- package/src/utils/module-federation/public-api.js.map +1 -0
- package/src/utils/module-federation/remotes.d.ts +19 -0
- package/src/utils/module-federation/remotes.js +78 -0
- package/src/utils/module-federation/remotes.js.map +1 -0
- package/src/utils/module-federation/secondary-entry-points.d.ts +12 -0
- package/src/utils/module-federation/secondary-entry-points.js +105 -0
- package/src/utils/module-federation/secondary-entry-points.js.map +1 -0
- package/src/utils/module-federation/share.d.ts +48 -0
- package/src/utils/module-federation/share.js +232 -0
- package/src/utils/module-federation/share.js.map +1 -0
- package/src/utils/module-federation/start-remote-proxies.d.ts +5 -0
- package/src/utils/module-federation/start-remote-proxies.js +46 -0
- package/src/utils/module-federation/start-remote-proxies.js.map +1 -0
- package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +5 -0
- package/src/utils/module-federation/start-ssr-remote-proxies.js +60 -0
- package/src/utils/module-federation/start-ssr-remote-proxies.js.map +1 -0
- package/src/utils/module-federation/typescript.d.ts +4 -0
- package/src/utils/module-federation/typescript.js +53 -0
- package/src/utils/module-federation/typescript.js.map +1 -0
- package/src/utils/module-federation/with-module-federation/package-json.d.ts +8 -0
- package/src/utils/module-federation/with-module-federation/package-json.js +13 -0
- package/src/utils/module-federation/with-module-federation/package-json.js.map +1 -0
- package/src/utils/module-federation/with-module-federation/utils.d.ts +12 -0
- package/src/utils/module-federation/with-module-federation/utils.js +78 -0
- package/src/utils/module-federation/with-module-federation/utils.js.map +1 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.d.ts +3 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +42 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js.map +1 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation.d.ts +8 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +52 -0
- package/src/utils/module-federation/with-module-federation/with-module-federation.js.map +1 -0
- package/src/utils/versions.d.ts +3 -3
- package/src/utils/versions.js +3 -3
- package/src/utils/with-nx.js +41 -15
- package/src/utils/with-nx.js.map +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startRemoteProxies = startRemoteProxies;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
function startRemoteProxies(staticRemotesConfig, mappedLocationsOfRemotes, sslOptions) {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const express = require('express');
|
|
11
|
+
let sslCert;
|
|
12
|
+
let sslKey;
|
|
13
|
+
if (sslOptions && sslOptions.pathToCert && sslOptions.pathToKey) {
|
|
14
|
+
if ((0, fs_1.existsSync)(sslOptions.pathToCert) && (0, fs_1.existsSync)(sslOptions.pathToKey)) {
|
|
15
|
+
sslCert = (0, fs_1.readFileSync)(sslOptions.pathToCert);
|
|
16
|
+
sslKey = (0, fs_1.readFileSync)(sslOptions.pathToKey);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
devkit_1.logger.warn(`Encountered SSL options in project.json, however, the certificate files do not exist in the filesystem. Using http.`);
|
|
20
|
+
devkit_1.logger.warn(`Attempted to find '${sslOptions.pathToCert}' and '${sslOptions.pathToKey}'.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
|
+
const http = require('http');
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
26
|
+
const https = require('https');
|
|
27
|
+
devkit_1.logger.info(`NX Starting static remotes proxies...`);
|
|
28
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
29
|
+
const expressProxy = express();
|
|
30
|
+
expressProxy.use(createProxyMiddleware({
|
|
31
|
+
target: mappedLocationsOfRemotes[app],
|
|
32
|
+
changeOrigin: true,
|
|
33
|
+
secure: sslCert ? false : undefined,
|
|
34
|
+
}));
|
|
35
|
+
const proxyServer = (sslCert
|
|
36
|
+
? https.createServer({
|
|
37
|
+
cert: sslCert,
|
|
38
|
+
key: sslKey,
|
|
39
|
+
}, expressProxy)
|
|
40
|
+
: http.createServer(expressProxy)).listen(staticRemotesConfig.config[app].port);
|
|
41
|
+
process.on('SIGTERM', () => proxyServer.close());
|
|
42
|
+
process.on('exit', () => proxyServer.close());
|
|
43
|
+
}
|
|
44
|
+
devkit_1.logger.info(`NX Static remotes proxies started successfully`);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=start-remote-proxies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-remote-proxies.js","sourceRoot":"","sources":["../../../../../../packages/rspack/src/utils/module-federation/start-remote-proxies.ts"],"names":[],"mappings":";;AAKA,gDAwDC;AA7DD,uCAAoC;AAEpC,2BAA8C;AAG9C,SAAgB,kBAAkB,CAChC,mBAAwC,EACxC,wBAAgD,EAChD,UAAsD;IAEtD,8DAA8D;IAC9D,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAEnE,8DAA8D;IAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,OAAe,CAAC;IACpB,IAAI,MAAc,CAAC;IACnB,IAAI,UAAU,IAAI,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QAChE,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,UAAU,CAAC,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1E,OAAO,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAC9C,MAAM,GAAG,IAAA,iBAAY,EAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,eAAM,CAAC,IAAI,CACT,qHAAqH,CACtH,CAAC;YACF,eAAM,CAAC,IAAI,CACT,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|
+
export declare function startSsrRemoteProxies(staticRemotesConfig: StaticRemotesConfig, mappedLocationsOfRemotes: Record<string, string>, sslOptions?: {
|
|
3
|
+
pathToCert: string;
|
|
4
|
+
pathToKey: string;
|
|
5
|
+
}): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startSsrRemoteProxies = startSsrRemoteProxies;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
function startSsrRemoteProxies(staticRemotesConfig, mappedLocationsOfRemotes, sslOptions) {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
8
|
+
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const express = require('express');
|
|
11
|
+
let sslCert;
|
|
12
|
+
let sslKey;
|
|
13
|
+
if (sslOptions && sslOptions.pathToCert && sslOptions.pathToKey) {
|
|
14
|
+
if ((0, fs_1.existsSync)(sslOptions.pathToCert) && (0, fs_1.existsSync)(sslOptions.pathToKey)) {
|
|
15
|
+
sslCert = (0, fs_1.readFileSync)(sslOptions.pathToCert);
|
|
16
|
+
sslKey = (0, fs_1.readFileSync)(sslOptions.pathToKey);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
devkit_1.logger.warn(`Encountered SSL options in project.json, however, the certificate files do not exist in the filesystem. Using http.`);
|
|
20
|
+
devkit_1.logger.warn(`Attempted to find '${sslOptions.pathToCert}' and '${sslOptions.pathToKey}'.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
|
+
const http = require('http');
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
26
|
+
const https = require('https');
|
|
27
|
+
devkit_1.logger.info(`NX Starting static remotes proxies...`);
|
|
28
|
+
for (const app of staticRemotesConfig.remotes) {
|
|
29
|
+
const expressProxy = express();
|
|
30
|
+
/**
|
|
31
|
+
* SSR remotes have two output paths: one for the browser and one for the server.
|
|
32
|
+
* We need to handle paths for both of them.
|
|
33
|
+
* The browser output path is used to serve the client-side code.
|
|
34
|
+
* The server output path is used to serve the server-side code.
|
|
35
|
+
*/
|
|
36
|
+
expressProxy.use(createProxyMiddleware({
|
|
37
|
+
target: `${mappedLocationsOfRemotes[app]}`,
|
|
38
|
+
secure: sslCert ? false : undefined,
|
|
39
|
+
changeOrigin: true,
|
|
40
|
+
pathRewrite: (path) => {
|
|
41
|
+
if (path.includes('/server')) {
|
|
42
|
+
return path;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return `browser/${path}`;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
49
|
+
const proxyServer = (sslCert
|
|
50
|
+
? https.createServer({
|
|
51
|
+
cert: sslCert,
|
|
52
|
+
key: sslKey,
|
|
53
|
+
}, expressProxy)
|
|
54
|
+
: http.createServer(expressProxy)).listen(staticRemotesConfig.config[app].port);
|
|
55
|
+
process.on('SIGTERM', () => proxyServer.close());
|
|
56
|
+
process.on('exit', () => proxyServer.close());
|
|
57
|
+
}
|
|
58
|
+
devkit_1.logger.info(`Nx SSR Static remotes proxies started successfully`);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=start-ssr-remote-proxies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start-ssr-remote-proxies.js","sourceRoot":"","sources":["../../../../../../packages/rspack/src/utils/module-federation/start-ssr-remote-proxies.ts"],"names":[],"mappings":";;AAKA,sDAuEC;AA5ED,uCAAoC;AAEpC,2BAA8C;AAG9C,SAAgB,qBAAqB,CACnC,mBAAwC,EACxC,wBAAgD,EAChD,UAAsD;IAEtD,8DAA8D;IAC9D,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,uBAAuB,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C,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC7B,OAAO,IAAI,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACN,OAAO,WAAW,IAAI,EAAE,CAAC;gBAC3B,CAAC;YACH,CAAC;SACF,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,GAAG,CAClB,OAAO;YACL,CAAC,CAAC,KAAK,CAAC,YAAY,CAChB;gBACE,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,MAAM;aACZ,EACD,YAAY,CACb;YACH,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CACpC,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,eAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ParsedCommandLine } from 'typescript';
|
|
2
|
+
export declare function readTsPathMappings(tsConfigPath?: string): ParsedCommandLine['options']['paths'];
|
|
3
|
+
export declare function readTsConfig(tsConfigPath: string): ParsedCommandLine;
|
|
4
|
+
export declare function getRootTsConfigPath(): string | null;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTsPathMappings = readTsPathMappings;
|
|
4
|
+
exports.readTsConfig = readTsConfig;
|
|
5
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const tsConfig = new Map();
|
|
10
|
+
const tsPathMappings = new Map();
|
|
11
|
+
function readTsPathMappings(tsConfigPath) {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
if (tsConfigPath === void 0) { tsConfigPath = (_a = process.env.NX_TSCONFIG_PATH) !== null && _a !== void 0 ? _a : getRootTsConfigPath(); }
|
|
14
|
+
if (tsPathMappings.has(tsConfigPath)) {
|
|
15
|
+
return tsPathMappings.get(tsConfigPath);
|
|
16
|
+
}
|
|
17
|
+
if (!tsConfig.has(tsConfigPath)) {
|
|
18
|
+
tsConfig.set(tsConfigPath, readTsConfiguration(tsConfigPath));
|
|
19
|
+
}
|
|
20
|
+
tsPathMappings.set(tsConfigPath, {});
|
|
21
|
+
Object.entries((_c = (_b = tsConfig.get(tsConfigPath).options) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {}).forEach(([alias, paths]) => {
|
|
22
|
+
tsPathMappings.set(tsConfigPath, Object.assign(Object.assign({}, tsPathMappings.get(tsConfigPath)), { [alias]: paths.map((path) => path.replace(/^\.\//, '')) }));
|
|
23
|
+
});
|
|
24
|
+
return tsPathMappings.get(tsConfigPath);
|
|
25
|
+
}
|
|
26
|
+
function readTsConfiguration(tsConfigPath) {
|
|
27
|
+
if (!(0, fs_1.existsSync)(tsConfigPath)) {
|
|
28
|
+
throw new Error(`NX MF: TsConfig Path for workspace libraries does not exist! (${tsConfigPath}).`);
|
|
29
|
+
}
|
|
30
|
+
return readTsConfig(tsConfigPath);
|
|
31
|
+
}
|
|
32
|
+
let tsModule;
|
|
33
|
+
function readTsConfig(tsConfigPath) {
|
|
34
|
+
if (!tsModule) {
|
|
35
|
+
tsModule = require('typescript');
|
|
36
|
+
}
|
|
37
|
+
const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
|
|
38
|
+
return tsModule.parseJsonConfigFileContent(readResult.config, tsModule.sys, (0, path_1.dirname)(tsConfigPath));
|
|
39
|
+
}
|
|
40
|
+
function getRootTsConfigPath() {
|
|
41
|
+
const tsConfigFileName = getRootTsConfigFileName();
|
|
42
|
+
return tsConfigFileName ? (0, path_1.join)(devkit_1.workspaceRoot, tsConfigFileName) : null;
|
|
43
|
+
}
|
|
44
|
+
function getRootTsConfigFileName() {
|
|
45
|
+
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
46
|
+
const tsConfigPath = (0, path_1.join)(devkit_1.workspaceRoot, tsConfigName);
|
|
47
|
+
if ((0, fs_1.existsSync)(tsConfigPath)) {
|
|
48
|
+
return tsConfigName;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../../../../packages/rspack/src/utils/module-federation/typescript.ts"],"names":[],"mappings":";;AASA,gDAqBC;AAcD,oCAaC;AAED,kDAIC;AA/DD,2BAAgC;AAEhC,+BAAqC;AACrC,uCAA2C;AAE3C,MAAM,QAAQ,GAAmC,IAAI,GAAG,EAAE,CAAC;AAC3D,MAAM,cAAc,GAClB,IAAI,GAAG,EAAE,CAAC;AAEZ,SAAgB,kBAAkB,CAChC,YAA4E;;iCAA5E,EAAA,qBAAuB,OAAO,CAAC,GAAG,CAAC,gBAAgB,mCAAI,mBAAmB,EAAE;IAE5E,IAAI,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,cAAc,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACr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CAAC,IAAA,WAAI,EAAC,sBAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,SAAS,uBAAuB;IAC9B,KAAK,MAAM,YAAY,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EAAE,CAAC;QACnE,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,sBAAa,EAAE,YAAY,CAAC,CAAC;QACvD,IAAI,IAAA,eAAU,EAAC,YAAY,CAAC,EAAE,CAAC;YAC7B,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readRootPackageJson = readRootPackageJson;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
function readRootPackageJson() {
|
|
7
|
+
const pkgJsonPath = (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'package.json');
|
|
8
|
+
if (!(0, fs_1.existsSync)(pkgJsonPath)) {
|
|
9
|
+
throw new Error('NX MFE: Could not find root package.json to determine dependency versions.');
|
|
10
|
+
}
|
|
11
|
+
return (0, devkit_1.readJsonFile)(pkgJsonPath);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=package-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/utils/module-federation/with-module-federation/package-json.ts"],"names":[],"mappings":";;AAGA,kDAYC;AAfD,uCAA4E;AAC5E,2BAAgC;AAEhC,SAAgB,mBAAmB;IAIjC,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,sBAAa,EAAE,cAAc,CAAC,CAAC;IACrE,IAAI,CAAC,IAAA,eAAU,EAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,qBAAY,EAAC,WAAW,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleFederationConfig } from '../models';
|
|
2
|
+
export declare function getFunctionDeterminateRemoteUrl(isServer?: boolean): (remote: string) => string;
|
|
3
|
+
export declare function getModuleFederationConfig(mfConfig: ModuleFederationConfig, options?: {
|
|
4
|
+
isServer: boolean;
|
|
5
|
+
determineRemoteUrl?: (remote: string) => string;
|
|
6
|
+
}): Promise<{
|
|
7
|
+
sharedLibraries: import("../models").SharedWorkspaceLibraryConfig;
|
|
8
|
+
sharedDependencies: {
|
|
9
|
+
[x: string]: import("../models").SharedLibraryConfig;
|
|
10
|
+
};
|
|
11
|
+
mappedRemotes: {};
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFunctionDeterminateRemoteUrl = getFunctionDeterminateRemoteUrl;
|
|
4
|
+
exports.getModuleFederationConfig = getModuleFederationConfig;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const project_graph_1 = require("nx/src/project-graph/project-graph");
|
|
8
|
+
const dependencies_1 = require("../dependencies");
|
|
9
|
+
const remotes_1 = require("../remotes");
|
|
10
|
+
const share_1 = require("../share");
|
|
11
|
+
function getFunctionDeterminateRemoteUrl(isServer = false) {
|
|
12
|
+
const target = 'serve';
|
|
13
|
+
const remoteEntry = isServer ? 'server/remoteEntry.js' : 'remoteEntry.js';
|
|
14
|
+
return function (remote) {
|
|
15
|
+
var _a, _b, _c, _d, _e;
|
|
16
|
+
const mappedStaticRemotesFromEnv = process.env
|
|
17
|
+
.NX_MF_DEV_SERVER_STATIC_REMOTES
|
|
18
|
+
? JSON.parse(process.env.NX_MF_DEV_SERVER_STATIC_REMOTES)
|
|
19
|
+
: undefined;
|
|
20
|
+
if (mappedStaticRemotesFromEnv && mappedStaticRemotesFromEnv[remote]) {
|
|
21
|
+
return `${mappedStaticRemotesFromEnv[remote]}/${remoteEntry}`;
|
|
22
|
+
}
|
|
23
|
+
let remoteConfiguration = null;
|
|
24
|
+
try {
|
|
25
|
+
remoteConfiguration = (0, project_graph_1.readCachedProjectConfiguration)(remote);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new Error(`Cannot find remote: "${remote}". Check that the remote name is correct in your module federation config file.\n`);
|
|
29
|
+
}
|
|
30
|
+
const serveTarget = (_a = remoteConfiguration === null || remoteConfiguration === void 0 ? void 0 : remoteConfiguration.targets) === null || _a === void 0 ? void 0 : _a[target];
|
|
31
|
+
if (!serveTarget) {
|
|
32
|
+
throw new Error(`Cannot automatically determine URL of remote (${remote}). Looked for property "host" in the project's "${serveTarget}" target.\n
|
|
33
|
+
You can also use the tuple syntax in your webpack config to configure your remotes. e.g. \`remotes: [['remote1', 'http://localhost:4201']]\``);
|
|
34
|
+
}
|
|
35
|
+
const host = (_c = (_b = serveTarget.options) === null || _b === void 0 ? void 0 : _b.host) !== null && _c !== void 0 ? _c : `http${serveTarget.options.ssl ? 's' : ''}://localhost`;
|
|
36
|
+
const port = (_e = (_d = serveTarget.options) === null || _d === void 0 ? void 0 : _d.port) !== null && _e !== void 0 ? _e : 4201;
|
|
37
|
+
return `${host.endsWith('/') ? host.slice(0, -1) : host}:${port}/${remoteEntry}`;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function getModuleFederationConfig(mfConfig_1) {
|
|
41
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (mfConfig, options = { isServer: false }) {
|
|
42
|
+
var _a;
|
|
43
|
+
let projectGraph;
|
|
44
|
+
try {
|
|
45
|
+
projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
projectGraph = yield (0, devkit_1.createProjectGraphAsync)();
|
|
49
|
+
}
|
|
50
|
+
const project = (_a = projectGraph.nodes[mfConfig.name]) === null || _a === void 0 ? void 0 : _a.data;
|
|
51
|
+
if (!project) {
|
|
52
|
+
throw Error(`Cannot find project "${mfConfig.name}". Check that the name is correct in module-federation.config.js`);
|
|
53
|
+
}
|
|
54
|
+
const dependencies = (0, dependencies_1.getDependentPackagesForProject)(projectGraph, mfConfig.name);
|
|
55
|
+
if (mfConfig.shared) {
|
|
56
|
+
dependencies.workspaceLibraries = dependencies.workspaceLibraries.filter((lib) => mfConfig.shared(lib.importKey, {}) !== false);
|
|
57
|
+
dependencies.npmPackages = dependencies.npmPackages.filter((pkg) => mfConfig.shared(pkg, {}) !== false);
|
|
58
|
+
}
|
|
59
|
+
const sharedLibraries = (0, share_1.shareWorkspaceLibraries)(dependencies.workspaceLibraries);
|
|
60
|
+
const npmPackages = (0, share_1.sharePackages)(dependencies.npmPackages);
|
|
61
|
+
const sharedDependencies = Object.assign(Object.assign({}, sharedLibraries.getLibraries(project.root)), npmPackages);
|
|
62
|
+
(0, share_1.applySharedFunction)(sharedDependencies, mfConfig.shared);
|
|
63
|
+
(0, share_1.applyAdditionalShared)(sharedDependencies, mfConfig.additionalShared, projectGraph);
|
|
64
|
+
// Choose the correct mapRemotes function based on the server state.
|
|
65
|
+
const mapRemotesFunction = options.isServer ? remotes_1.mapRemotesForSSR : remotes_1.mapRemotes;
|
|
66
|
+
// Determine the URL function, either from provided options or by using a default.
|
|
67
|
+
const determineRemoteUrlFunction = options.determineRemoteUrl
|
|
68
|
+
? options.determineRemoteUrl
|
|
69
|
+
: getFunctionDeterminateRemoteUrl(options.isServer);
|
|
70
|
+
// Map the remotes if they exist, otherwise default to an empty object.
|
|
71
|
+
let mappedRemotes = {};
|
|
72
|
+
if (mfConfig.remotes && mfConfig.remotes.length > 0) {
|
|
73
|
+
mappedRemotes = mapRemotesFunction(mfConfig.remotes, 'js', determineRemoteUrlFunction);
|
|
74
|
+
}
|
|
75
|
+
return { sharedLibraries, sharedDependencies, mappedRemotes };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/utils/module-federation/with-module-federation/utils.ts"],"names":[],"mappings":";;AAgBA,0EAsCC;AAED,8DA0EC;;AAlID,uCAIoB;AACpB,sEAAoF;AACpF,kDAAiE;AAEjE,wCAA0D;AAC1D,oCAKkB;AAElB,SAAgB,+BAA+B,CAAC,QAAQ,GAAG,KAAK;IAC9D,MAAM,MAAM,GAAG,OAAO,CAAC;IACvB,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAE1E,OAAO,UAAU,MAAc;;QAC7B,MAAM,0BAA0B,GAAG,OAAO,CAAC,GAAG;aAC3C,+BAA+B;YAChC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC;YACzD,CAAC,CAAC,SAAS,CAAC;QACd,IAAI,0BAA0B,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,OAAO,GAAG,0BAA0B,CAAC,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;QAChE,CAAC;QAED,IAAI,mBAAmB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC;YACH,mBAAmB,GAAG,IAAA,8CAA8B,EAAC,MAAM,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,mFAAmF,CAClH,CAAC;QACJ,CAAC;QACD,MAAM,WAAW,GAAG,MAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,OAAO,0CAAG,MAAM,CAAC,CAAC;QAE3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,CAAC,OAAO,EAChB,IAAI,EACJ,0BAA0B,CAC3B,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,CAAC;IAChE,CAAC;CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SharedConfigContext } from '../../model';
|
|
2
|
+
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../models';
|
|
3
|
+
export declare function withModuleFederationForSSR(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: any, { context }: SharedConfigContext) => any>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederationForSSR = withModuleFederationForSSR;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@rspack/core");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
function withModuleFederationForSSR(options, configOverride) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
if (global.NX_GRAPH_CREATION) {
|
|
10
|
+
return (config) => config;
|
|
11
|
+
}
|
|
12
|
+
const { sharedLibraries, sharedDependencies, mappedRemotes } = yield (0, utils_1.getModuleFederationConfig)(options, {
|
|
13
|
+
isServer: true,
|
|
14
|
+
});
|
|
15
|
+
return (config, { context }) => {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
config.target = 'async-node';
|
|
18
|
+
config.output.uniqueName = options.name;
|
|
19
|
+
config.optimization = Object.assign(Object.assign({}, ((_a = config.optimization) !== null && _a !== void 0 ? _a : {})), { runtimeChunk: false });
|
|
20
|
+
config.plugins.push(
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
22
|
+
new (require('@module-federation/enhanced/rspack').ModuleFederationPlugin)(Object.assign(Object.assign({ name: options.name, filename: 'remoteEntry.js', exposes: options.exposes, remotes: mappedRemotes, shared: Object.assign({}, sharedDependencies), isServer: true }, (configOverride ? configOverride : {})), { runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
23
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
|
24
|
+
? [
|
|
25
|
+
...((_b = configOverride === null || configOverride === void 0 ? void 0 : configOverride.runtimePlugins) !== null && _b !== void 0 ? _b : []),
|
|
26
|
+
require.resolve('@module-federation/node/runtimePlugin'),
|
|
27
|
+
require.resolve('@nx/rspack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
|
28
|
+
]
|
|
29
|
+
: [
|
|
30
|
+
...((_c = configOverride === null || configOverride === void 0 ? void 0 : configOverride.runtimePlugins) !== null && _c !== void 0 ? _c : []),
|
|
31
|
+
require.resolve('@module-federation/node/runtimePlugin'),
|
|
32
|
+
], virtualRuntimeEntry: true }), {}), sharedLibraries.getReplacementPlugin());
|
|
33
|
+
// The env var is only set from the module-federation-dev-server
|
|
34
|
+
// Attach the runtime plugin
|
|
35
|
+
config.plugins.push(new core_1.DefinePlugin({
|
|
36
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
37
|
+
}));
|
|
38
|
+
return config;
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=with-module-federation-ssr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-module-federation-ssr.js","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/utils/module-federation/with-module-federation/with-module-federation-ssr.ts"],"names":[],"mappings":";;AAQA,gEAoEC;;AA5ED,uCAA4C;AAM5C,mCAAoD;AAEpD,SAAsB,0BAA0B,CAC9C,OAA+B,EAC/B,cAAiD;;QAEjD,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC7B,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;QAC5B,CAAC;QAED,MAAM,EAAE,eAAe,EAAE,kBAAkB,EA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,KAE3B,EAAE,CACH,EACD,eAAe,CAAC,oBAAoB,EAAE,CACvC,CAAC;YAEF,gEAAgE;YAChE,4BAA4B;YAC5B,MAAM,CAAC,OAAO,CAAC,IAAI,CACjB,IAAI,mBAAY,CAAC;gBACf,+BAA+B,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;aAC/D,CAAC,CACH,CAAC;YAEF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Configuration } from '@rspack/core';
|
|
2
|
+
import { SharedConfigContext } from '../../model';
|
|
3
|
+
import { ModuleFederationConfig, NxModuleFederationConfigOverride } from '../models';
|
|
4
|
+
/**
|
|
5
|
+
* @param {ModuleFederationConfig} options
|
|
6
|
+
* @param {NxModuleFederationConfigOverride} configOverride
|
|
7
|
+
*/
|
|
8
|
+
export declare function withModuleFederation(options: ModuleFederationConfig, configOverride?: NxModuleFederationConfigOverride): Promise<(config: Configuration, { context }: SharedConfigContext) => Configuration>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withModuleFederation = withModuleFederation;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const rspack_1 = require("@module-federation/enhanced/rspack");
|
|
6
|
+
const core_1 = require("@rspack/core");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
|
|
9
|
+
/**
|
|
10
|
+
* @param {ModuleFederationConfig} options
|
|
11
|
+
* @param {NxModuleFederationConfigOverride} configOverride
|
|
12
|
+
*/
|
|
13
|
+
function withModuleFederation(options, configOverride) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
var _a;
|
|
16
|
+
if (global.NX_GRAPH_CREATION) {
|
|
17
|
+
return function makeConfig(config) {
|
|
18
|
+
return config;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const { sharedDependencies, sharedLibraries, mappedRemotes } = yield (0, utils_1.getModuleFederationConfig)(options);
|
|
22
|
+
const isGlobal = isVarOrWindow((_a = options.library) === null || _a === void 0 ? void 0 : _a.type);
|
|
23
|
+
return function makeConfig(config, { context }) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
config.output.uniqueName = options.name;
|
|
26
|
+
config.output.publicPath = 'auto';
|
|
27
|
+
if (isGlobal) {
|
|
28
|
+
config.output.scriptType = 'text/javascript';
|
|
29
|
+
}
|
|
30
|
+
config.optimization = Object.assign(Object.assign({}, ((_a = config.optimization) !== null && _a !== void 0 ? _a : {})), { runtimeChunk: false });
|
|
31
|
+
if (config.mode === 'development' &&
|
|
32
|
+
Object.keys(mappedRemotes).length > 1 &&
|
|
33
|
+
!options.exposes) {
|
|
34
|
+
config.optimization.runtimeChunk = 'single';
|
|
35
|
+
}
|
|
36
|
+
config.plugins.push(new rspack_1.ModuleFederationPlugin(Object.assign(Object.assign(Object.assign({ name: options.name, filename: 'remoteEntry.js', exposes: options.exposes, remotes: mappedRemotes, shared: Object.assign({}, sharedDependencies) }, (isGlobal ? { remoteType: 'script' } : {})), (configOverride ? configOverride : {})), { runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
37
|
+
!options.disableNxRuntimeLibraryControlPlugin
|
|
38
|
+
? [
|
|
39
|
+
...((_b = configOverride === null || configOverride === void 0 ? void 0 : configOverride.runtimePlugins) !== null && _b !== void 0 ? _b : []),
|
|
40
|
+
require.resolve('@nx/rspack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
|
41
|
+
]
|
|
42
|
+
: configOverride === null || configOverride === void 0 ? void 0 : configOverride.runtimePlugins, virtualRuntimeEntry: true })), sharedLibraries.getReplacementPlugin());
|
|
43
|
+
// The env var is only set from the module-federation-dev-server
|
|
44
|
+
// Attach the runtime plugin
|
|
45
|
+
config.plugins.push(new core_1.DefinePlugin({
|
|
46
|
+
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
47
|
+
}));
|
|
48
|
+
return config;
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=with-module-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-module-federation.js","sourceRoot":"","sources":["../../../../../../../packages/rspack/src/utils/module-federation/with-module-federation/with-module-federation.ts"],"names":[],"mappings":";;AAiBA,oDAmFC;;AApGD,+DAA4E;AAE5E,uCAA4C;AAM5C,mCAAoD;AAEpD,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAE,EAAE,CACzC,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,QAAQ,CAAC;AAE5C;;;GAGG;AACH,SAAsB,oBAAoB,CACxC,OAA+B,EAC/B,cAAiD;;;QAEjD,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;YAC7B,OAAO,SAAS,UAAU,CAAC,MAAqB;gBAC9C,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,GAC1D,MAAM,IAAA,iCAAyB,EAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC;QAEtD,OAAO,SAAS,UAAU,CACxB,MAAqB,EACrB,EAAE,OAAO,EAAuB;;YAEhC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;YACxC,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;YAElC,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,iBAAiB,CAAC;YAC/C,CAAC;YAED,MAAM,CAAC,YAAY,mCACd,CAAC,MAAA,MAAM,CAAC,YA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AC;QAChB,CAAC,CAAC;IACJ,CAAC;CAAA"}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare const rspackCoreVersion = "^0.
|
|
2
|
-
export declare const rspackDevServerVersion = "^0.
|
|
1
|
+
export declare const rspackCoreVersion = "^1.0.2";
|
|
2
|
+
export declare const rspackDevServerVersion = "^1.0.2";
|
|
3
3
|
export declare const rspackPluginMinifyVersion = "^0.7.5";
|
|
4
|
-
export declare const rspackPluginReactRefreshVersion = "^0.
|
|
4
|
+
export declare const rspackPluginReactRefreshVersion = "^1.0.0";
|
|
5
5
|
export declare const lessLoaderVersion = "~11.1.3";
|
|
6
6
|
export declare const reactVersion = "~18.2.0";
|
|
7
7
|
export declare const reactRefreshVersion = "~0.14.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eslintPluginReactHooksVersion = exports.eslintPluginReactVersion = exports.eslintPluginJsxA11yVersion = exports.eslintPluginImportVersion = exports.stylusVersion = exports.sassVersion = exports.lessVersion = exports.nestjsMicroservicesVersion = exports.nestjsPlatformExpressVersion = exports.nestjsCoreVersion = exports.nestjsCommonVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.reactDomVersion = exports.reactRefreshVersion = exports.reactVersion = exports.lessLoaderVersion = exports.rspackPluginReactRefreshVersion = exports.rspackPluginMinifyVersion = exports.rspackDevServerVersion = exports.rspackCoreVersion = void 0;
|
|
4
|
-
exports.rspackCoreVersion = '^0.
|
|
5
|
-
exports.rspackDevServerVersion = '^0.
|
|
4
|
+
exports.rspackCoreVersion = '^1.0.2';
|
|
5
|
+
exports.rspackDevServerVersion = '^1.0.2';
|
|
6
6
|
exports.rspackPluginMinifyVersion = '^0.7.5';
|
|
7
|
-
exports.rspackPluginReactRefreshVersion = '^0.
|
|
7
|
+
exports.rspackPluginReactRefreshVersion = '^1.0.0';
|
|
8
8
|
exports.lessLoaderVersion = '~11.1.3';
|
|
9
9
|
exports.reactVersion = '~18.2.0';
|
|
10
10
|
exports.reactRefreshVersion = '~0.14.0';
|
package/src/utils/with-nx.js
CHANGED
|
@@ -3,14 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withNx = withNx;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const core_1 = require("@rspack/core");
|
|
6
|
+
const fs_1 = require("fs");
|
|
6
7
|
const license_webpack_plugin_1 = require("license-webpack-plugin");
|
|
7
8
|
const path = tslib_1.__importStar(require("path"));
|
|
9
|
+
const path_1 = require("path");
|
|
8
10
|
const generate_package_json_plugin_1 = require("../plugins/generate-package-json-plugin");
|
|
9
11
|
const get_copy_patterns_1 = require("./get-copy-patterns");
|
|
10
12
|
const normalize_assets_1 = require("./normalize-assets");
|
|
11
13
|
function withNx(_opts = {}) {
|
|
12
14
|
return function makeConfig(config, { options, context }) {
|
|
13
|
-
var _a, _b;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14
16
|
const isProd = process.env.NODE_ENV === 'production' || options.mode === 'production';
|
|
15
17
|
const project = context.projectGraph.nodes[context.projectName];
|
|
16
18
|
const sourceRoot = path.join(context.root, project.data.sourceRoot);
|
|
@@ -23,12 +25,37 @@ function withNx(_opts = {}) {
|
|
|
23
25
|
}, {});
|
|
24
26
|
const plugins = (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
|
|
25
27
|
if (options.extractLicenses) {
|
|
28
|
+
/**
|
|
29
|
+
* Needed to prevent an issue with Rspack and Workspaces where the
|
|
30
|
+
* workspace's root package.json file is added to the dependency tree
|
|
31
|
+
*/
|
|
32
|
+
let rootPackageJsonName;
|
|
33
|
+
const pathToRootPackageJson = (0, path_1.join)(context.root, 'package.json');
|
|
34
|
+
if ((0, fs_1.existsSync)(pathToRootPackageJson)) {
|
|
35
|
+
try {
|
|
36
|
+
const rootPackageJson = JSON.parse((0, fs_1.readFileSync)(pathToRootPackageJson, 'utf-8'));
|
|
37
|
+
rootPackageJsonName = rootPackageJson.name;
|
|
38
|
+
}
|
|
39
|
+
catch (_h) {
|
|
40
|
+
// do nothing
|
|
41
|
+
}
|
|
42
|
+
}
|
|
26
43
|
plugins.push(new license_webpack_plugin_1.LicenseWebpackPlugin({
|
|
27
44
|
stats: {
|
|
28
45
|
warnings: false,
|
|
29
46
|
errors: false,
|
|
30
47
|
},
|
|
31
48
|
outputFilename: `3rdpartylicenses.txt`,
|
|
49
|
+
/**
|
|
50
|
+
* Needed to prevent an issue with Rspack and Workspaces where the
|
|
51
|
+
* workspace's root package.json file is added to the dependency tree
|
|
52
|
+
*/
|
|
53
|
+
excludedPackageTest: (packageName) => {
|
|
54
|
+
if (!rootPackageJsonName) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return packageName === rootPackageJsonName;
|
|
58
|
+
},
|
|
32
59
|
}));
|
|
33
60
|
}
|
|
34
61
|
if (options.generatePackageJson) {
|
|
@@ -58,15 +85,11 @@ function withNx(_opts = {}) {
|
|
|
58
85
|
}
|
|
59
86
|
externalsType = 'commonjs';
|
|
60
87
|
}
|
|
61
|
-
const updated = Object.assign(Object.assign({}, config), { target: options.target, mode: options.mode, context: context.root, devtool: options.sourceMap === 'hidden'
|
|
88
|
+
const updated = Object.assign(Object.assign({}, config), { target: options.target, mode: options.mode, entry: {}, context: (0, path_1.join)(context.root, context.projectGraph.nodes[context.projectName].data.root), devtool: options.sourceMap === 'hidden'
|
|
62
89
|
? 'hidden-source-map'
|
|
63
90
|
: options.sourceMap
|
|
64
91
|
? 'source-map'
|
|
65
|
-
: false,
|
|
66
|
-
main: {
|
|
67
|
-
import: [path.join(context.root, options.main)],
|
|
68
|
-
},
|
|
69
|
-
}, output: {
|
|
92
|
+
: false, output: {
|
|
70
93
|
path: path.join(context.root, options.outputPath),
|
|
71
94
|
publicPath: '/',
|
|
72
95
|
filename: isProd && options.target !== 'node'
|
|
@@ -84,10 +107,7 @@ function withNx(_opts = {}) {
|
|
|
84
107
|
assetModuleFilename: isProd && options.target !== 'node'
|
|
85
108
|
? '[name].[contenthash:8][ext]'
|
|
86
109
|
: '[name][ext]',
|
|
87
|
-
}, devServer: {
|
|
88
|
-
port: 4200,
|
|
89
|
-
hot: true,
|
|
90
|
-
}, module: {
|
|
110
|
+
}, devServer: Object.assign(Object.assign({}, ((_c = config.devServer) !== null && _c !== void 0 ? _c : {})), { port: (_e = (_d = config.devServer) === null || _d === void 0 ? void 0 : _d.port) !== null && _e !== void 0 ? _e : 4200, hot: (_g = (_f = config.devServer) === null || _f === void 0 ? void 0 : _f.hot) !== null && _g !== void 0 ? _g : true }), module: {
|
|
91
111
|
rules: [
|
|
92
112
|
{
|
|
93
113
|
test: /\.js$/,
|
|
@@ -111,25 +131,25 @@ function withNx(_opts = {}) {
|
|
|
111
131
|
jsc: {
|
|
112
132
|
parser: {
|
|
113
133
|
syntax: 'typescript',
|
|
114
|
-
decorators: true
|
|
134
|
+
decorators: true,
|
|
115
135
|
},
|
|
116
136
|
transform: {
|
|
117
137
|
legacyDecorator: true,
|
|
118
|
-
decoratorMetadata: true
|
|
138
|
+
decoratorMetadata: true,
|
|
119
139
|
},
|
|
120
140
|
externalHelpers: true,
|
|
121
141
|
},
|
|
122
142
|
},
|
|
123
143
|
type: 'javascript/auto',
|
|
124
144
|
},
|
|
125
|
-
]
|
|
145
|
+
],
|
|
126
146
|
}, plugins: plugins, resolve: {
|
|
127
147
|
// There are some issues resolving workspace libs in a monorepo.
|
|
128
148
|
// It looks to be an issue with rspack itself, but will check back after Nx 16 release
|
|
129
149
|
// once I can reproduce a small example repo with rspack only.
|
|
130
150
|
alias,
|
|
131
151
|
// We need to define the extensions that rspack can resolve
|
|
132
|
-
extensions: [
|
|
152
|
+
extensions: ['...', '.ts', '.tsx', '.jsx'],
|
|
133
153
|
// tsConfigPath: path.join(context.root, options.tsConfig),
|
|
134
154
|
}, infrastructureLogging: {
|
|
135
155
|
debug: false,
|
|
@@ -138,6 +158,12 @@ function withNx(_opts = {}) {
|
|
|
138
158
|
colors: true,
|
|
139
159
|
preset: 'normal',
|
|
140
160
|
} });
|
|
161
|
+
const mainEntry = options.main
|
|
162
|
+
? options.outputFileName
|
|
163
|
+
? path.parse(options.outputFileName).name
|
|
164
|
+
: 'main'
|
|
165
|
+
: 'main';
|
|
166
|
+
updated.entry[mainEntry] = path.resolve(context.root, options.main);
|
|
141
167
|
return updated;
|
|
142
168
|
};
|
|
143
169
|
}
|