@nx/react 0.0.0-pr-29464-73fdcbb → 0.0.0-pr-30565-cfe2164
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/package.json +6 -6
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +1 -3
- package/src/generators/application/application.js +20 -21
- package/src/generators/application/files/react-router-ssr/common/app/app-nav.tsx__tmpl__ +1 -0
- package/src/generators/application/lib/add-e2e.js +0 -4
- package/src/generators/application/lib/add-jest.js +2 -26
- package/src/generators/application/lib/create-application-files.d.ts +0 -61
- package/src/generators/application/lib/create-application-files.js +44 -49
- package/src/generators/application/lib/normalize-options.js +1 -4
- package/src/generators/host/files/rspack-module-federation/rspack.config.js__tmpl__ +13 -37
- package/src/generators/host/files/rspack-module-federation/rspack.config.prod.js__tmpl__ +32 -60
- package/src/generators/host/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -6
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +16 -0
- package/src/generators/host/files/rspack-module-federation-ssr/server.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -6
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +16 -0
- package/src/generators/host/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +1 -1
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.prod.ts__tmpl__ +9 -37
- package/src/generators/host/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +14 -37
- package/src/generators/host/host.js +15 -15
- package/src/generators/host/lib/add-module-federation-files.js +12 -28
- package/src/generators/host/lib/setup-ssr-for-host.d.ts +3 -3
- package/src/generators/host/lib/setup-ssr-for-host.js +22 -46
- package/src/generators/library/library.js +1 -1
- package/src/generators/remote/files/rspack-module-federation/rspack.config.js__tmpl__ +13 -40
- package/src/generators/remote/files/rspack-module-federation-ssr/module-federation.server.config.js__tmpl__ +0 -6
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__ +16 -0
- package/src/generators/remote/files/rspack-module-federation-ssr/server.ts__tmpl__ +2 -2
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +0 -6
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__ +16 -0
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/server.ts__tmpl__ +2 -2
- package/src/generators/remote/files/rspack-module-federation-ts/rspack.config.ts__tmpl__ +13 -40
- package/src/generators/remote/lib/setup-ssr-for-remote.d.ts +1 -1
- package/src/generators/remote/lib/setup-ssr-for-remote.js +15 -37
- package/src/generators/remote/remote.js +21 -27
- package/src/rules/update-module-federation-project.d.ts +1 -2
- package/src/rules/update-module-federation-project.js +47 -28
- package/src/utils/assertion.d.ts +0 -2
- package/src/utils/assertion.js +0 -6
- package/src/utils/ct-utils.d.ts +1 -1
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +11 -0
- package/src/generators/host/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -66
- package/src/generators/host/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -49
- package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -66
- package/src/generators/host/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -49
- package/src/generators/host/lib/normalize-host-name.d.ts +0 -2
- package/src/generators/host/lib/normalize-host-name.js +0 -12
- package/src/generators/remote/files/rspack-module-federation-ssr/rspack.config.js__tmpl__ +0 -69
- package/src/generators/remote/files/rspack-module-federation-ssr/src/main.server.tsx__tmpl__ +0 -45
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/rspack.config.ts__tmpl__ +0 -69
- package/src/generators/remote/files/rspack-module-federation-ssr-ts/src/main.server.tsx__tmpl__ +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-30565-cfe2164",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"minimatch": "9.0.3",
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@nx/devkit": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-30565-cfe2164",
|
|
42
|
+
"@nx/js": "0.0.0-pr-30565-cfe2164",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-30565-cfe2164",
|
|
44
|
+
"@nx/web": "0.0.0-pr-30565-cfe2164",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-30565-cfe2164",
|
|
46
46
|
"express": "^4.21.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
|
48
48
|
"semver": "^7.6.3"
|
|
@@ -57,9 +57,7 @@ function applyReactConfig(options, config = {}) {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
function addHotReload(config) {
|
|
60
|
-
if (config.mode === 'development' &&
|
|
61
|
-
typeof config['devServer'] === 'object' &&
|
|
62
|
-
config['devServer']?.hot) {
|
|
60
|
+
if (config.mode === 'development' && config['devServer']?.hot) {
|
|
63
61
|
// add `react-refresh/babel` to babel loader plugin
|
|
64
62
|
const babelLoader = config.module.rules.find((rule) => rule &&
|
|
65
63
|
typeof rule !== 'string' &&
|
|
@@ -46,26 +46,25 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
46
46
|
});
|
|
47
47
|
tasks.push(jsInitTask);
|
|
48
48
|
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
|
|
49
|
-
options.useReactRouter =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
: false;
|
|
49
|
+
options.useReactRouter = options.routing
|
|
50
|
+
? options.useReactRouter ??
|
|
51
|
+
(await (0, prompt_1.promptWhenInteractive)({
|
|
52
|
+
name: 'response',
|
|
53
|
+
message: 'Would you like to use react-router for server-side rendering?',
|
|
54
|
+
type: 'autocomplete',
|
|
55
|
+
choices: [
|
|
56
|
+
{
|
|
57
|
+
name: 'Yes',
|
|
58
|
+
message: 'I want to use react-router [ https://reactrouter.com/start/framework/routing ]',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'No',
|
|
62
|
+
message: 'I do not want to use react-router for server-side rendering',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
initial: 0,
|
|
66
|
+
}, { response: 'No' }).then((r) => r.response === 'Yes'))
|
|
67
|
+
: false;
|
|
69
68
|
(0, show_possible_warnings_1.showPossibleWarnings)(tree, options);
|
|
70
69
|
const initTask = await (0, init_1.default)(tree, {
|
|
71
70
|
...options,
|
|
@@ -168,7 +167,7 @@ async function applicationGeneratorInternal(tree, schema) {
|
|
|
168
167
|
moduleResolution: 'bundler',
|
|
169
168
|
}, options.linter === 'eslint'
|
|
170
169
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
171
|
-
: undefined
|
|
170
|
+
: undefined);
|
|
172
171
|
(0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
|
|
173
172
|
if (!options.skipFormat) {
|
|
174
173
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -27,10 +27,6 @@ async function addE2e(tree, options) {
|
|
|
27
27
|
const { getWebpackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
|
28
28
|
e2eWebServerInfo = await getWebpackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `webpack.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
|
|
29
29
|
}
|
|
30
|
-
else if (options.bundler === 'rspack') {
|
|
31
|
-
const { getRspackE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
|
32
|
-
e2eWebServerInfo = await getRspackE2EWebServerInfo(tree, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `rspack.config.${options.js ? 'js' : 'ts'}`), options.addPlugin, options.devServerPort ?? 4200);
|
|
33
|
-
}
|
|
34
30
|
else if (options.bundler === 'vite') {
|
|
35
31
|
const { getViteE2EWebServerInfo, getReactRouterE2EWebServerInfo } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
36
32
|
e2eWebServerInfo = options.useReactRouter
|
|
@@ -3,43 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = addJest;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
|
6
|
-
const node_path_1 = require("node:path");
|
|
7
6
|
async function addJest(host, options) {
|
|
8
7
|
if (options.unitTestRunner === 'none') {
|
|
9
8
|
return () => { };
|
|
10
9
|
}
|
|
11
10
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
12
|
-
await configurationGenerator(host, {
|
|
11
|
+
return await configurationGenerator(host, {
|
|
13
12
|
...options,
|
|
14
13
|
project: options.projectName,
|
|
15
14
|
supportTsx: true,
|
|
16
15
|
skipSerializers: true,
|
|
17
|
-
setupFile:
|
|
16
|
+
setupFile: 'none',
|
|
18
17
|
compiler: options.compiler,
|
|
19
18
|
skipFormat: true,
|
|
20
19
|
runtimeTsconfigFileName: 'tsconfig.app.json',
|
|
21
20
|
});
|
|
22
|
-
if (options.useReactRouter) {
|
|
23
|
-
(0, devkit_1.updateJson)(host, (0, node_path_1.join)(options.appProjectRoot, 'tsconfig.spec.json'), (json) => {
|
|
24
|
-
json.include = json.include ?? [];
|
|
25
|
-
const reactRouterTestGlob = options.js
|
|
26
|
-
? [
|
|
27
|
-
'test/**/*.spec.jsx',
|
|
28
|
-
'test/**/*.spec.js',
|
|
29
|
-
'test/**/*.test.jsx',
|
|
30
|
-
'test/**/*.test.js',
|
|
31
|
-
]
|
|
32
|
-
: [
|
|
33
|
-
'test/**/*.spec.tsx',
|
|
34
|
-
'test/**/*.spec.ts',
|
|
35
|
-
'test/**/*.test.tsx',
|
|
36
|
-
'test/**/*.test.ts',
|
|
37
|
-
];
|
|
38
|
-
return {
|
|
39
|
-
...json,
|
|
40
|
-
include: Array.from(new Set([...json.include, ...reactRouterTestGlob])),
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return () => { };
|
|
45
21
|
}
|
|
@@ -1,64 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { WithNxOptions } from '@nx/webpack';
|
|
3
|
-
import { WithReactOptions } from '../../../../plugins/with-react';
|
|
4
2
|
import { NormalizedSchema } from '../schema';
|
|
5
|
-
export declare function getDefaultTemplateVariables(host: Tree, options: NormalizedSchema): {
|
|
6
|
-
typesNodeVersion: string;
|
|
7
|
-
typesReactDomVersion: string;
|
|
8
|
-
reactRouterVersion: string;
|
|
9
|
-
typesReactVersion: string;
|
|
10
|
-
reactDomVersion: string;
|
|
11
|
-
reactVersion: string;
|
|
12
|
-
reactRouterIsBotVersion: string;
|
|
13
|
-
js: boolean;
|
|
14
|
-
tmpl: string;
|
|
15
|
-
offsetFromRoot: string;
|
|
16
|
-
appTests: string;
|
|
17
|
-
inSourceVitestTests: string;
|
|
18
|
-
style: "none" | "styled-components" | "@emotion/styled" | "styled-jsx" | "css" | "scss" | "less";
|
|
19
|
-
hasStyleFile: boolean;
|
|
20
|
-
isUsingTsSolutionSetup: boolean;
|
|
21
|
-
projectName: string;
|
|
22
|
-
appProjectRoot: string;
|
|
23
|
-
e2eProjectName: string;
|
|
24
|
-
e2eProjectRoot: string;
|
|
25
|
-
importPath: string;
|
|
26
|
-
parsedTags: string[];
|
|
27
|
-
fileName: string;
|
|
28
|
-
styledModule: null | import("../../../..").SupportedStyles;
|
|
29
|
-
hasStyles: boolean;
|
|
30
|
-
unitTestRunner: "jest" | "vitest" | "none";
|
|
31
|
-
addPlugin?: boolean;
|
|
32
|
-
names: ReturnType<typeof import("@nx/devkit").names>;
|
|
33
|
-
isUsingTsSolutionConfig?: boolean;
|
|
34
|
-
directory: string;
|
|
35
|
-
name: string;
|
|
36
|
-
skipFormat?: boolean;
|
|
37
|
-
tags?: string;
|
|
38
|
-
inSourceTests?: boolean;
|
|
39
|
-
e2eTestRunner: "cypress" | "playwright" | "none";
|
|
40
|
-
linter: import("@nx/eslint").Linter | import("@nx/eslint").LinterType;
|
|
41
|
-
classComponent?: boolean;
|
|
42
|
-
routing?: boolean;
|
|
43
|
-
useReactRouter?: boolean;
|
|
44
|
-
skipNxJson?: boolean;
|
|
45
|
-
globalCss?: boolean;
|
|
46
|
-
strict?: boolean;
|
|
47
|
-
setParserOptionsProject?: boolean;
|
|
48
|
-
compiler?: "babel" | "swc";
|
|
49
|
-
remotes?: string[];
|
|
50
|
-
devServerPort?: number;
|
|
51
|
-
skipPackageJson?: boolean;
|
|
52
|
-
rootProject?: boolean;
|
|
53
|
-
bundler?: "webpack" | "vite" | "rspack" | "rsbuild";
|
|
54
|
-
minimal?: boolean;
|
|
55
|
-
nxCloudToken?: string;
|
|
56
|
-
useTsSolution?: boolean;
|
|
57
|
-
formatter?: "prettier" | "none";
|
|
58
|
-
useProjectJson?: boolean;
|
|
59
|
-
className: string;
|
|
60
|
-
propertyName: string;
|
|
61
|
-
constantName: string;
|
|
62
|
-
};
|
|
63
|
-
export declare function createNxRspackPluginOptions(options: NormalizedSchema, rootOffset: string, tsx?: boolean): WithNxOptions & WithReactOptions;
|
|
64
3
|
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): Promise<void>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDefaultTemplateVariables = getDefaultTemplateVariables;
|
|
4
|
-
exports.createNxRspackPluginOptions = createNxRspackPluginOptions;
|
|
5
3
|
exports.createApplicationFiles = createApplicationFiles;
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
7
5
|
const js_1 = require("@nx/js");
|
|
@@ -15,52 +13,6 @@ const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
|
|
15
13
|
const has_rspack_plugin_1 = require("../../../utils/has-rspack-plugin");
|
|
16
14
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
17
15
|
const versions_1 = require("../../../utils/versions");
|
|
18
|
-
function getDefaultTemplateVariables(host, options) {
|
|
19
|
-
const hasStyleFile = ['scss', 'css', 'less'].includes(options.style);
|
|
20
|
-
const appTests = (0, get_app_tests_1.getAppTests)(options);
|
|
21
|
-
return {
|
|
22
|
-
...options.names,
|
|
23
|
-
...options,
|
|
24
|
-
typesNodeVersion: versions_1.typesNodeVersion,
|
|
25
|
-
typesReactDomVersion: versions_1.typesReactDomVersion,
|
|
26
|
-
reactRouterVersion: versions_1.reactRouterVersion,
|
|
27
|
-
typesReactVersion: versions_1.typesReactVersion,
|
|
28
|
-
reactDomVersion: versions_1.reactDomVersion,
|
|
29
|
-
reactVersion: versions_1.reactVersion,
|
|
30
|
-
reactRouterIsBotVersion: versions_1.reactRouterIsBotVersion,
|
|
31
|
-
js: !!options.js, // Ensure this is defined in template
|
|
32
|
-
tmpl: '',
|
|
33
|
-
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
34
|
-
appTests,
|
|
35
|
-
inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
|
|
36
|
-
style: options.style === 'tailwind' ? 'css' : options.style,
|
|
37
|
-
hasStyleFile,
|
|
38
|
-
isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createNxRspackPluginOptions(options, rootOffset, tsx = true) {
|
|
42
|
-
return {
|
|
43
|
-
target: 'web',
|
|
44
|
-
outputPath: options.isUsingTsSolutionConfig
|
|
45
|
-
? 'dist'
|
|
46
|
-
: (0, devkit_1.joinPathFragments)(rootOffset, 'dist', options.appProjectRoot != '.'
|
|
47
|
-
? options.appProjectRoot
|
|
48
|
-
: options.projectName),
|
|
49
|
-
index: './src/index.html',
|
|
50
|
-
baseHref: '/',
|
|
51
|
-
main: (0, maybe_js_1.maybeJs)({
|
|
52
|
-
js: options.js,
|
|
53
|
-
useJsx: true,
|
|
54
|
-
}, `./src/main.${tsx ? 'tsx' : 'ts'}`),
|
|
55
|
-
tsConfig: './tsconfig.app.json',
|
|
56
|
-
assets: ['./src/favicon.ico', './src/assets'],
|
|
57
|
-
styles: options.styledModule || !options.hasStyles
|
|
58
|
-
? []
|
|
59
|
-
: [
|
|
60
|
-
`./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
16
|
async function createApplicationFiles(host, options) {
|
|
65
17
|
let styleSolutionSpecificAppFiles;
|
|
66
18
|
if (options.styledModule && options.style !== 'styled-jsx') {
|
|
@@ -81,11 +33,31 @@ async function createApplicationFiles(host, options) {
|
|
|
81
33
|
else {
|
|
82
34
|
styleSolutionSpecificAppFiles = '../files/style-css-module';
|
|
83
35
|
}
|
|
36
|
+
const hasStyleFile = ['scss', 'css', 'less'].includes(options.style);
|
|
84
37
|
const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(host, options.nxCloudToken);
|
|
85
38
|
const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
|
|
86
39
|
(await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
|
|
87
40
|
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot);
|
|
88
|
-
const
|
|
41
|
+
const appTests = (0, get_app_tests_1.getAppTests)(options);
|
|
42
|
+
const templateVariables = {
|
|
43
|
+
...options.names,
|
|
44
|
+
...options,
|
|
45
|
+
typesNodeVersion: versions_1.typesNodeVersion,
|
|
46
|
+
typesReactDomVersion: versions_1.typesReactDomVersion,
|
|
47
|
+
reactRouterVersion: versions_1.reactRouterVersion,
|
|
48
|
+
typesReactVersion: versions_1.typesReactVersion,
|
|
49
|
+
reactDomVersion: versions_1.reactDomVersion,
|
|
50
|
+
reactVersion: versions_1.reactVersion,
|
|
51
|
+
reactRouterIsBotVersion: versions_1.reactRouterIsBotVersion,
|
|
52
|
+
js: !!options.js, // Ensure this is defined in template
|
|
53
|
+
tmpl: '',
|
|
54
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
55
|
+
appTests,
|
|
56
|
+
inSourceVitestTests: (0, get_in_source_vitest_tests_template_1.getInSourceVitestTestsTemplate)(appTests),
|
|
57
|
+
style: options.style === 'tailwind' ? 'css' : options.style,
|
|
58
|
+
hasStyleFile,
|
|
59
|
+
isUsingTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
|
|
60
|
+
};
|
|
89
61
|
if (options.bundler === 'vite' && !options.useReactRouter) {
|
|
90
62
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-vite'), options.appProjectRoot, templateVariables);
|
|
91
63
|
}
|
|
@@ -213,6 +185,29 @@ function createNxWebpackPluginOptions(options, rootOffset) {
|
|
|
213
185
|
],
|
|
214
186
|
};
|
|
215
187
|
}
|
|
188
|
+
function createNxRspackPluginOptions(options, rootOffset) {
|
|
189
|
+
return {
|
|
190
|
+
target: 'web',
|
|
191
|
+
outputPath: options.isUsingTsSolutionConfig
|
|
192
|
+
? 'dist'
|
|
193
|
+
: (0, devkit_1.joinPathFragments)(rootOffset, 'dist', options.appProjectRoot != '.'
|
|
194
|
+
? options.appProjectRoot
|
|
195
|
+
: options.projectName),
|
|
196
|
+
index: './src/index.html',
|
|
197
|
+
baseHref: '/',
|
|
198
|
+
main: (0, maybe_js_1.maybeJs)({
|
|
199
|
+
js: options.js,
|
|
200
|
+
useJsx: true,
|
|
201
|
+
}, `./src/main.tsx`),
|
|
202
|
+
tsConfig: './tsconfig.app.json',
|
|
203
|
+
assets: ['./src/favicon.ico', './src/assets'],
|
|
204
|
+
styles: options.styledModule || !options.hasStyles
|
|
205
|
+
? []
|
|
206
|
+
: [
|
|
207
|
+
`./src/styles.${options.style !== 'tailwind' ? options.style : 'css'}`,
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
216
211
|
function generateReactRouterFiles(tree, options, templateVariables) {
|
|
217
212
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/react-router-ssr/common'), options.appProjectRoot, templateVariables);
|
|
218
213
|
if (options.rootProject) {
|
|
@@ -31,10 +31,7 @@ async function normalizeOptions(host, options) {
|
|
|
31
31
|
? null
|
|
32
32
|
: options.style;
|
|
33
33
|
(0, assertion_1.assertValidStyle)(options.style);
|
|
34
|
-
|
|
35
|
-
if (options.useReactRouter && !options.bundler) {
|
|
36
|
-
options.bundler = 'vite';
|
|
37
|
-
}
|
|
34
|
+
options.bundler = options.useReactRouter ? 'vite' : options.bundler;
|
|
38
35
|
options.useReactRouter = options.routing ? options.useReactRouter : false;
|
|
39
36
|
const normalized = {
|
|
40
37
|
...options,
|
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } = require('@nx/module-federation/rspack');
|
|
4
|
-
const { join } = require('path');
|
|
1
|
+
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
2
|
+
const { withModuleFederation } = require('@nx/module-federation/rspack');
|
|
5
3
|
|
|
6
|
-
const
|
|
4
|
+
const baseConfig = require('./module-federation.config');
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
path: join(__dirname, '<%= rspackPluginOptions.outputPath %>'),
|
|
11
|
-
publicPath: 'auto'
|
|
12
|
-
},
|
|
13
|
-
devServer: {
|
|
14
|
-
port: <%= devServerPort %>,
|
|
15
|
-
historyApiFallback: {
|
|
16
|
-
index: '/index.html',
|
|
17
|
-
disableDotRule: true,
|
|
18
|
-
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
plugins: [
|
|
22
|
-
new NxAppRspackPlugin({
|
|
23
|
-
tsConfig: '<%= rspackPluginOptions.tsConfig %>',
|
|
24
|
-
main: '<%= rspackPluginOptions.main %>',
|
|
25
|
-
index: '<%= rspackPluginOptions.index %>',
|
|
26
|
-
baseHref: '<%= rspackPluginOptions.baseHref %>',
|
|
27
|
-
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
|
|
28
|
-
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
|
|
29
|
-
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
30
|
-
optimization: process.env['NODE_ENV'] === 'production',
|
|
31
|
-
}),
|
|
32
|
-
new NxReactRspackPlugin({
|
|
33
|
-
// Uncomment this line if you don't want to use SVGR
|
|
34
|
-
// See: https://react-svgr.com/
|
|
35
|
-
// svgr: false
|
|
36
|
-
}),
|
|
37
|
-
new NxModuleFederationPlugin({ config }, { dts: false }),
|
|
38
|
-
new NxModuleFederationDevServerPlugin({ config }),
|
|
39
|
-
],
|
|
6
|
+
const config = {
|
|
7
|
+
...baseConfig,
|
|
40
8
|
};
|
|
9
|
+
|
|
10
|
+
// Nx plugins for rspack to build config object from Nx options and context.
|
|
11
|
+
/**
|
|
12
|
+
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
13
|
+
* The DTS Plugin can be enabled by setting dts: true
|
|
14
|
+
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
15
|
+
*/
|
|
16
|
+
module.exports = composePlugins(withNx(), withReact(), withModuleFederation(config, { dts: false }));
|
|
@@ -1,66 +1,38 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } = require('@nx/module-federation/rspack');
|
|
4
|
-
const { join } = require('path');
|
|
1
|
+
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
2
|
+
const { withModuleFederation } = require('@nx/module-federation/rspack');
|
|
5
3
|
|
|
6
4
|
const baseConfig = require('./module-federation.config');
|
|
7
5
|
|
|
8
6
|
const prodConfig = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
...baseConfig,
|
|
8
|
+
/*
|
|
9
|
+
* Remote overrides for production.
|
|
10
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
11
|
+
*
|
|
12
|
+
* e.g.
|
|
13
|
+
* remotes: [
|
|
14
|
+
* ['app1', 'http://app1.example.com'],
|
|
15
|
+
* ['app2', 'http://app2.example.com'],
|
|
16
|
+
* ]
|
|
17
|
+
*
|
|
18
|
+
* You can also use a full path to the remoteEntry.js file if desired.
|
|
19
|
+
*
|
|
20
|
+
* remotes: [
|
|
21
|
+
* ['app1', 'http://example.com/path/to/app1/remoteEntry.js'],
|
|
22
|
+
* ['app2', 'http://example.com/path/to/app2/remoteEntry.js'],
|
|
23
|
+
* ]
|
|
24
|
+
*/
|
|
25
|
+
remotes: [
|
|
26
|
+
<%_ remotes.forEach(function(r) { _%>
|
|
27
|
+
['<%= r.fileName %>', 'http://localhost:<%= r.port %>/'],
|
|
28
|
+
<%_ }); _%>
|
|
29
|
+
],
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
historyApiFallback: {
|
|
42
|
-
index: '/index.html',
|
|
43
|
-
disableDotRule: true,
|
|
44
|
-
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
plugins: [
|
|
48
|
-
new NxAppRspackPlugin({
|
|
49
|
-
tsConfig: '<%= rspackPluginOptions.tsConfig %>',
|
|
50
|
-
main: '<%= rspackPluginOptions.main %>',
|
|
51
|
-
index: '<%= rspackPluginOptions.index %>',
|
|
52
|
-
baseHref: '<%= rspackPluginOptions.baseHref %>',
|
|
53
|
-
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
|
|
54
|
-
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
|
|
55
|
-
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
56
|
-
optimization: process.env['NODE_ENV'] === 'production',
|
|
57
|
-
}),
|
|
58
|
-
new NxReactRspackPlugin({
|
|
59
|
-
// Uncomment this line if you don't want to use SVGR
|
|
60
|
-
// See: https://react-svgr.com/
|
|
61
|
-
// svgr: false
|
|
62
|
-
}),
|
|
63
|
-
new NxModuleFederationPlugin({ config: prodConfig }, { dts: false }),
|
|
64
|
-
new NxModuleFederationDevServerPlugin({ config: prodConfig }),
|
|
65
|
-
],
|
|
66
|
-
};
|
|
32
|
+
// Nx plugins for rspack to build config object from Nx options and context.
|
|
33
|
+
/**
|
|
34
|
+
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
35
|
+
* The DTS Plugin can be enabled by setting dts: true
|
|
36
|
+
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
37
|
+
*/
|
|
38
|
+
module.exports = composePlugins(withNx(), withReact(), withModuleFederation(prodConfig, { dts: false }));
|
package/src/generators/host/files/rspack-module-federation-ssr/rspack.server.config.js__tmpl__
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const {composePlugins, withNx, withReact} = require('@nx/rspack');
|
|
2
|
+
const {withModuleFederationForSSR} = require('@nx/module-federation/rspack');
|
|
3
|
+
|
|
4
|
+
const baseConfig = require('./module-federation.config');
|
|
5
|
+
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
...baseConfig
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Nx plugins for rspack to build config object from Nx options and context.
|
|
11
|
+
/**
|
|
12
|
+
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
13
|
+
* The DTS Plugin can be enabled by setting dts: true
|
|
14
|
+
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
15
|
+
*/
|
|
16
|
+
module.exports = composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false }));
|
|
@@ -7,7 +7,7 @@ import { handleRequest } from './src/main.server';
|
|
|
7
7
|
const port = process.env['PORT'] || <%= port %>;
|
|
8
8
|
const app = express();
|
|
9
9
|
|
|
10
|
-
const browserDist = path.join(process.cwd(), '<%=
|
|
10
|
+
const browserDist = path.join(process.cwd(), '<%= browserBuildOutputPath %>');
|
|
11
11
|
const indexPath = path.join(browserDist, 'index.html');
|
|
12
12
|
|
|
13
13
|
app.use(cors());
|
package/src/generators/host/files/rspack-module-federation-ssr-ts/rspack.server.config.ts__tmpl__
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {composePlugins, withNx, withReact} from '@nx/rspack';
|
|
2
|
+
import {withModuleFederationForSSR} from '@nx/module-federation/rspack';
|
|
3
|
+
|
|
4
|
+
import baseConfig from './module-federation.config';
|
|
5
|
+
|
|
6
|
+
const defaultConfig = {
|
|
7
|
+
...baseConfig
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Nx plugins for rspack to build config object from Nx options and context.
|
|
11
|
+
/**
|
|
12
|
+
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
13
|
+
* The DTS Plugin can be enabled by setting dts: true
|
|
14
|
+
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
15
|
+
*/
|
|
16
|
+
export default composePlugins(withNx(), withReact({ssr: true}), withModuleFederationForSSR(defaultConfig, { dts: false }));
|
|
@@ -7,7 +7,7 @@ import { handleRequest } from './src/main.server';
|
|
|
7
7
|
const port = process.env['PORT'] || <%= port %>;
|
|
8
8
|
const app = express();
|
|
9
9
|
|
|
10
|
-
const browserDist = path.join(process.cwd(), '<%=
|
|
10
|
+
const browserDist = path.join(process.cwd(), '<%= browserBuildOutputPath %>');
|
|
11
11
|
const indexPath = path.join(browserDist, 'index.html');
|
|
12
12
|
|
|
13
13
|
app.use(cors());
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/rspack';
|
|
1
|
+
import { composePlugins, withNx, withReact } from '@nx/rspack';
|
|
2
|
+
import { withModuleFederation } from '@nx/module-federation/rspack';
|
|
4
3
|
import { ModuleFederationConfig } from '@nx/module-federation';
|
|
5
|
-
import { join } from 'path';
|
|
6
4
|
|
|
7
5
|
import baseConfig from './module-federation.config';
|
|
8
6
|
|
|
@@ -32,36 +30,10 @@ const prodConfig: ModuleFederationConfig = {
|
|
|
32
30
|
],
|
|
33
31
|
};
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
historyApiFallback: {
|
|
43
|
-
index: '/index.html',
|
|
44
|
-
disableDotRule: true,
|
|
45
|
-
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
plugins: [
|
|
49
|
-
new NxAppRspackPlugin({
|
|
50
|
-
tsConfig: '<%= rspackPluginOptions.tsConfig %>',
|
|
51
|
-
main: '<%= rspackPluginOptions.main %>',
|
|
52
|
-
index: '<%= rspackPluginOptions.index %>',
|
|
53
|
-
baseHref: '<%= rspackPluginOptions.baseHref %>',
|
|
54
|
-
assets: <%- JSON.stringify(rspackPluginOptions.assets) %>,
|
|
55
|
-
styles: <%- JSON.stringify(rspackPluginOptions.styles) %>,
|
|
56
|
-
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
|
|
57
|
-
optimization: process.env['NODE_ENV'] === 'production',
|
|
58
|
-
}),
|
|
59
|
-
new NxReactRspackPlugin({
|
|
60
|
-
// Uncomment this line if you don't want to use SVGR
|
|
61
|
-
// See: https://react-svgr.com/
|
|
62
|
-
// svgr: false
|
|
63
|
-
}),
|
|
64
|
-
new NxModuleFederationPlugin({ config: prodConfig }, { dts: false }),
|
|
65
|
-
new NxModuleFederationDevServerPlugin({ config: prodConfig }),
|
|
66
|
-
],
|
|
67
|
-
};
|
|
33
|
+
// Nx plugins for rspack to build config object from Nx options and context.
|
|
34
|
+
/**
|
|
35
|
+
* DTS Plugin is disabled in Nx Workspaces as Nx already provides Typing support for Module Federation
|
|
36
|
+
* The DTS Plugin can be enabled by setting dts: true
|
|
37
|
+
* Learn more about the DTS Plugin here: https://module-federation.io/configure/dts.html
|
|
38
|
+
*/
|
|
39
|
+
export default composePlugins(withNx(), withReact(), withModuleFederation(prodConfig, { dts: false }));
|