@nx/rspack 20.2.0-beta.2 → 20.2.0-beta.3
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/app-plugin.d.ts +2 -0
- package/app-plugin.js +5 -0
- package/generators.json +10 -0
- package/migrations.json +21 -1
- package/module-federation.d.ts +4 -1
- package/module-federation.js +7 -2
- package/package.json +10 -8
- package/react-plugin.d.ts +1 -0
- package/react-plugin.js +5 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +5 -7
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +5 -7
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.d.ts +1 -1
- package/src/executors/module-federation-static-server/module-federation-static-server.impl.js +4 -5
- package/src/executors/rspack/schema.d.ts +1 -1
- package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.d.ts +7 -0
- package/src/generators/convert-config-to-rspack-plugin/convert-config-to-rspack-plugin.js +92 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.d.ts +6 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/extract-rspack-options.js +106 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/normalize-path-options.d.ts +2 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/normalize-path-options.js +73 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/utils.d.ts +1 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/utils.js +13 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/validate-project.d.ts +9 -0
- package/src/generators/convert-config-to-rspack-plugin/lib/validate-project.js +40 -0
- package/src/generators/convert-config-to-rspack-plugin/schema.json +19 -0
- package/src/generators/convert-to-inferred/__snapshots__/convert-to-inferred.spec.ts.snap +268 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +12 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +114 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
- package/src/generators/convert-to-inferred/utils/ast.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/ast.js +40 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/build-post-target-transformer.js +210 -0
- package/src/generators/convert-to-inferred/utils/index.d.ts +3 -0
- package/src/generators/convert-to-inferred/utils/index.js +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/utils/serve-post-target-transformer.js +207 -0
- package/src/generators/convert-to-inferred/utils/types.d.ts +11 -0
- package/src/generators/convert-webpack/lib/transform-cjs.js +5 -5
- package/src/generators/convert-webpack/lib/transform-esm.js +5 -5
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.d.ts +2 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +35 -0
- package/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.d.ts +16 -0
- package/src/plugins/nx-app-rspack-plugin/nx-app-rspack-plugin.js +43 -0
- package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.d.ts +8 -0
- package/src/plugins/nx-react-rspack-plugin/nx-react-rspack-plugin.js +13 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.d.ts +31 -0
- package/src/plugins/use-legacy-nx-plugin/use-legacy-nx-plugin.js +73 -0
- package/src/plugins/utils/apply-base-config.js +1 -0
- package/src/plugins/utils/apply-web-config.d.ts +2 -2
- package/src/plugins/utils/apply-web-config.js +1 -1
- package/src/plugins/utils/plugins/normalize-options.js +1 -1
- package/src/plugins/utils/plugins/nx-tsconfig-paths-rspack-plugin.js +3 -2
- package/src/utils/create-compiler.js +3 -1
- package/src/utils/generator-utils.d.ts +2 -2
- package/src/utils/generator-utils.js +134 -67
- package/src/utils/has-plugin.d.ts +2 -0
- package/src/utils/has-plugin.js +10 -0
- package/src/utils/module-federation/build-static.remotes.d.ts +1 -1
- package/src/utils/versions.d.ts +2 -2
- package/src/utils/versions.js +2 -2
- package/src/utils/module-federation/dependencies.d.ts +0 -6
- package/src/utils/module-federation/dependencies.js +0 -56
- package/src/utils/module-federation/get-remotes-for-host.d.ts +0 -16
- package/src/utils/module-federation/get-remotes-for-host.js +0 -99
- package/src/utils/module-federation/index.d.ts +0 -6
- package/src/utils/module-federation/index.js +0 -9
- package/src/utils/module-federation/models/index.d.ts +0 -47
- package/src/utils/module-federation/package-json.d.ts +0 -8
- package/src/utils/module-federation/package-json.js +0 -12
- package/src/utils/module-federation/parse-static-remotes-config.d.ts +0 -13
- package/src/utils/module-federation/parse-static-remotes-config.js +0 -34
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.d.ts +0 -3
- package/src/utils/module-federation/plugins/runtime-library-control.plugin.js +0 -54
- package/src/utils/module-federation/public-api.d.ts +0 -8
- package/src/utils/module-federation/public-api.js +0 -20
- package/src/utils/module-federation/remotes.d.ts +0 -19
- package/src/utils/module-federation/remotes.js +0 -85
- package/src/utils/module-federation/secondary-entry-points.d.ts +0 -12
- package/src/utils/module-federation/secondary-entry-points.js +0 -104
- package/src/utils/module-federation/share.d.ts +0 -48
- package/src/utils/module-federation/share.js +0 -235
- package/src/utils/module-federation/start-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-remote-proxies.js +0 -45
- package/src/utils/module-federation/start-ssr-remote-proxies.d.ts +0 -5
- package/src/utils/module-federation/start-ssr-remote-proxies.js +0 -59
- package/src/utils/module-federation/typescript.d.ts +0 -4
- package/src/utils/module-federation/typescript.js +0 -53
- package/src/utils/module-federation/with-module-federation/package-json.d.ts +0 -8
- package/src/utils/module-federation/with-module-federation/package-json.js +0 -12
- package/src/utils/module-federation/with-module-federation/utils.d.ts +0 -12
- package/src/utils/module-federation/with-module-federation/utils.js +0 -76
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.d.ts +0 -3
- package/src/utils/module-federation/with-module-federation/with-module-federation-ssr.js +0 -62
- package/src/utils/module-federation/with-module-federation/with-module-federation.d.ts +0 -8
- package/src/utils/module-federation/with-module-federation/with-module-federation.js +0 -70
- /package/src/{utils/module-federation/models/index.js → generators/convert-to-inferred/utils/types.js} +0 -0
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withModuleFederation = withModuleFederation;
|
|
4
|
-
const rspack_1 = require("@module-federation/enhanced/rspack");
|
|
5
|
-
const core_1 = require("@rspack/core");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
|
-
const isVarOrWindow = (libType) => libType === 'var' || libType === 'window';
|
|
8
|
-
/**
|
|
9
|
-
* @param {ModuleFederationConfig} options
|
|
10
|
-
* @param {NxModuleFederationConfigOverride} configOverride
|
|
11
|
-
*/
|
|
12
|
-
async function withModuleFederation(options, configOverride) {
|
|
13
|
-
if (global.NX_GRAPH_CREATION) {
|
|
14
|
-
return function makeConfig(config) {
|
|
15
|
-
return config;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const { sharedDependencies, sharedLibraries, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
|
19
|
-
const isGlobal = isVarOrWindow(options.library?.type);
|
|
20
|
-
return function makeConfig(config, { context }) {
|
|
21
|
-
config.output.uniqueName = options.name;
|
|
22
|
-
config.output.publicPath = 'auto';
|
|
23
|
-
if (isGlobal) {
|
|
24
|
-
config.output.scriptType = 'text/javascript';
|
|
25
|
-
}
|
|
26
|
-
config.optimization = {
|
|
27
|
-
...(config.optimization ?? {}),
|
|
28
|
-
runtimeChunk: false,
|
|
29
|
-
};
|
|
30
|
-
if (config.mode === 'development' &&
|
|
31
|
-
Object.keys(mappedRemotes).length > 1 &&
|
|
32
|
-
!options.exposes) {
|
|
33
|
-
config.optimization.runtimeChunk = 'single';
|
|
34
|
-
}
|
|
35
|
-
config.plugins.push(new rspack_1.ModuleFederationPlugin({
|
|
36
|
-
name: options.name.replace(/-/g, '_'),
|
|
37
|
-
filename: 'remoteEntry.js',
|
|
38
|
-
exposes: options.exposes,
|
|
39
|
-
remotes: mappedRemotes,
|
|
40
|
-
shared: {
|
|
41
|
-
...sharedDependencies,
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* remoteType: 'script' is required for the remote to be loaded as a script tag.
|
|
45
|
-
* remotes will need to be defined as:
|
|
46
|
-
* { appX: 'appX@http://localhost:3001/remoteEntry.js' }
|
|
47
|
-
* { appY: 'appY@http://localhost:3002/remoteEntry.js' }
|
|
48
|
-
*/
|
|
49
|
-
...(isGlobal ? { remoteType: 'script' } : {}),
|
|
50
|
-
/**
|
|
51
|
-
* Apply user-defined config overrides
|
|
52
|
-
*/
|
|
53
|
-
...(configOverride ? configOverride : {}),
|
|
54
|
-
runtimePlugins: process.env.NX_MF_DEV_REMOTES &&
|
|
55
|
-
!options.disableNxRuntimeLibraryControlPlugin
|
|
56
|
-
? [
|
|
57
|
-
...(configOverride?.runtimePlugins ?? []),
|
|
58
|
-
require.resolve('@nx/rspack/src/utils/module-federation/plugins/runtime-library-control.plugin.js'),
|
|
59
|
-
]
|
|
60
|
-
: configOverride?.runtimePlugins,
|
|
61
|
-
virtualRuntimeEntry: true,
|
|
62
|
-
}), sharedLibraries.getReplacementPlugin());
|
|
63
|
-
// The env var is only set from the module-federation-dev-server
|
|
64
|
-
// Attach the runtime plugin
|
|
65
|
-
config.plugins.push(new core_1.DefinePlugin({
|
|
66
|
-
'process.env.NX_MF_DEV_REMOTES': process.env.NX_MF_DEV_REMOTES,
|
|
67
|
-
}));
|
|
68
|
-
return config;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
File without changes
|