@nx/react 0.0.0-pr-29314-e664f92 → 0.0.0-pr-29286-735af1e
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 +1 -1
- package/migrations.json +15 -0
- package/package.json +8 -7
- package/plugins/jest.js +6 -11
- package/src/generators/application/application.d.ts +3 -3
- package/src/generators/application/application.js +59 -194
- package/src/generators/application/files/base-rsbuild/src/app/__fileName__.spec.tsx__tmpl__ +10 -0
- package/src/generators/application/files/base-rsbuild/src/assets/.gitkeep +0 -0
- package/src/generators/application/files/base-rsbuild/src/favicon.ico +0 -0
- package/src/generators/application/files/base-rsbuild/src/index.html +14 -0
- package/src/generators/application/files/base-rsbuild/src/main.tsx__tmpl__ +32 -0
- package/src/generators/application/files/base-rsbuild/tsconfig.app.json__tmpl__ +31 -0
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/application/lib/add-e2e.js +13 -1
- package/src/generators/application/lib/add-linting.d.ts +3 -0
- package/src/generators/application/lib/add-linting.js +48 -0
- package/src/generators/application/lib/bundlers/add-rsbuild.d.ts +4 -0
- package/src/generators/application/lib/bundlers/add-rsbuild.js +63 -0
- package/src/generators/application/lib/bundlers/add-rspack.d.ts +5 -0
- package/src/generators/application/lib/bundlers/add-rspack.js +55 -0
- package/src/generators/application/lib/bundlers/add-vite.d.ts +4 -0
- package/src/generators/application/lib/bundlers/add-vite.js +67 -0
- package/src/generators/application/lib/bundlers/add-webpack.d.ts +3 -0
- package/src/generators/application/lib/bundlers/add-webpack.js +18 -0
- package/src/generators/application/lib/create-application-files.js +5 -0
- package/src/generators/application/lib/install-common-dependencies.d.ts +1 -1
- package/src/generators/application/lib/install-common-dependencies.js +6 -3
- package/src/generators/application/schema.d.ts +1 -1
- package/src/generators/application/schema.json +1 -1
- package/src/generators/component/files/__fileName__.__ext__ +3 -3
- package/src/generators/component/schema.json +4 -0
- package/src/generators/host/host.js +1 -0
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +8 -6
- package/src/generators/library/library.js +4 -7
- package/src/generators/library/schema.json +4 -0
- package/src/generators/remote/remote.js +1 -0
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +6 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.d.ts +2 -0
- package/src/migrations/update-20-3-0/ensure-nx-module-federation-package.js +18 -0
- package/src/utils/has-rsbuild-plugin.d.ts +2 -0
- package/src/utils/has-rsbuild-plugin.js +10 -0
- package/src/utils/version-utils.d.ts +14 -0
- package/src/utils/version-utils.js +56 -0
- package/src/utils/versions.d.ts +14 -7
- package/src/utils/versions.js +16 -8
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRsbuild = initRsbuild;
|
|
4
|
+
exports.setupRsbuildConfiguration = setupRsbuildConfiguration;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("../../../../utils/versions");
|
|
7
|
+
const maybe_js_1 = require("../../../../utils/maybe-js");
|
|
8
|
+
async function initRsbuild(tree, options, tasks) {
|
|
9
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
10
|
+
const { initGenerator } = await Promise.resolve().then(() => require('@nx/rsbuild/generators'));
|
|
11
|
+
const initTask = await initGenerator(tree, {
|
|
12
|
+
skipPackageJson: options.skipPackageJson,
|
|
13
|
+
addPlugin: true,
|
|
14
|
+
skipFormat: true,
|
|
15
|
+
});
|
|
16
|
+
tasks.push(initTask);
|
|
17
|
+
}
|
|
18
|
+
async function setupRsbuildConfiguration(tree, options, tasks) {
|
|
19
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
20
|
+
const { configurationGenerator } = await Promise.resolve().then(() => require('@nx/rsbuild/generators'));
|
|
21
|
+
const { addBuildPlugin, addCopyAssets, addHtmlTemplatePath, addExperimentalSwcPlugin, versions, } = await Promise.resolve().then(() => require('@nx/rsbuild/config-utils'));
|
|
22
|
+
const rsbuildTask = await configurationGenerator(tree, {
|
|
23
|
+
project: options.projectName,
|
|
24
|
+
entry: (0, maybe_js_1.maybeJs)({
|
|
25
|
+
js: options.js,
|
|
26
|
+
useJsx: true,
|
|
27
|
+
}, `./src/main.tsx`),
|
|
28
|
+
tsConfig: './tsconfig.app.json',
|
|
29
|
+
target: 'web',
|
|
30
|
+
devServerPort: options.devServerPort ?? 4200,
|
|
31
|
+
});
|
|
32
|
+
tasks.push(rsbuildTask);
|
|
33
|
+
const pathToConfigFile = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rsbuild.config.ts');
|
|
34
|
+
const deps = { '@rsbuild/plugin-react': versions.rsbuildPluginReactVersion };
|
|
35
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-react', 'pluginReact', options.style === '@emotion/styled'
|
|
36
|
+
? `swcReactOptions: {\n\timportSource: '@emotion/react',\n}`
|
|
37
|
+
: undefined);
|
|
38
|
+
if (options.style === 'scss') {
|
|
39
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-sass', 'pluginSass');
|
|
40
|
+
deps['@rsbuild/plugin-sass'] = versions.rsbuildPluginSassVersion;
|
|
41
|
+
}
|
|
42
|
+
else if (options.style === 'less') {
|
|
43
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-less', 'pluginLess');
|
|
44
|
+
deps['@rsbuild/plugin-less'] = versions.rsbuildPluginLessVersion;
|
|
45
|
+
}
|
|
46
|
+
else if (options.style === '@emotion/styled') {
|
|
47
|
+
deps['@swc/plugin-emotion'] = versions.rsbuildSwcPluginEmotionVersion;
|
|
48
|
+
addExperimentalSwcPlugin(tree, pathToConfigFile, '@swc/plugin-emotion');
|
|
49
|
+
}
|
|
50
|
+
else if (options.style === 'styled-jsx') {
|
|
51
|
+
deps['@swc/plugin-styled-jsx'] = versions.rsbuildSwcPluginStyledJsxVersion;
|
|
52
|
+
addExperimentalSwcPlugin(tree, pathToConfigFile, '@swc/plugin-styled-jsx');
|
|
53
|
+
}
|
|
54
|
+
else if (options.style === 'styled-components') {
|
|
55
|
+
deps['@rsbuild/plugin-styled-components'] =
|
|
56
|
+
versions.rsbuildPluginStyledComponentsVersion;
|
|
57
|
+
addBuildPlugin(tree, pathToConfigFile, '@rsbuild/plugin-styled-components', 'pluginStyledComponents');
|
|
58
|
+
}
|
|
59
|
+
addHtmlTemplatePath(tree, pathToConfigFile, './src/index.html');
|
|
60
|
+
addCopyAssets(tree, pathToConfigFile, './src/assets');
|
|
61
|
+
addCopyAssets(tree, pathToConfigFile, './src/favicon.ico');
|
|
62
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, deps));
|
|
63
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../../schema';
|
|
3
|
+
export declare function initRspack(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
4
|
+
export declare function setupRspackConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
5
|
+
export declare function handleStyledJsxForRspack(tasks: any[], tree: Tree, options: NormalizedSchema<Schema>): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initRspack = initRspack;
|
|
4
|
+
exports.setupRspackConfiguration = setupRspackConfiguration;
|
|
5
|
+
exports.handleStyledJsxForRspack = handleStyledJsxForRspack;
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const pc = require("picocolors");
|
|
8
|
+
const versions_1 = require("../../../../utils/versions");
|
|
9
|
+
const maybe_js_1 = require("../../../../utils/maybe-js");
|
|
10
|
+
async function initRspack(tree, options, tasks) {
|
|
11
|
+
const { rspackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
|
12
|
+
const rspackInitTask = await rspackInitGenerator(tree, {
|
|
13
|
+
...options,
|
|
14
|
+
addPlugin: false,
|
|
15
|
+
skipFormat: true,
|
|
16
|
+
});
|
|
17
|
+
tasks.push(rspackInitTask);
|
|
18
|
+
}
|
|
19
|
+
async function setupRspackConfiguration(tree, options, tasks) {
|
|
20
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rspack', versions_1.nxVersion);
|
|
21
|
+
const rspackTask = await configurationGenerator(tree, {
|
|
22
|
+
project: options.projectName,
|
|
23
|
+
main: (0, devkit_1.joinPathFragments)(options.appProjectRoot, (0, maybe_js_1.maybeJs)({
|
|
24
|
+
js: options.js,
|
|
25
|
+
useJsx: true,
|
|
26
|
+
}, `src/main.tsx`)),
|
|
27
|
+
tsConfig: (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
|
|
28
|
+
target: 'web',
|
|
29
|
+
newProject: true,
|
|
30
|
+
framework: 'react',
|
|
31
|
+
});
|
|
32
|
+
tasks.push(rspackTask);
|
|
33
|
+
}
|
|
34
|
+
function handleStyledJsxForRspack(tasks, tree, options) {
|
|
35
|
+
devkit_1.logger.warn(`${pc.bold('styled-jsx')} is not supported by ${pc.bold('Rspack')}. We've added ${pc.bold('babel-loader')} to your project, but using babel will slow down your build.`);
|
|
36
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'babel-loader': versions_1.babelLoaderVersion }));
|
|
37
|
+
tree.write((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'rspack.config.js'), (0, devkit_1.stripIndents) `
|
|
38
|
+
const { composePlugins, withNx, withReact } = require('@nx/rspack');
|
|
39
|
+
module.exports = composePlugins(withNx(), withReact(), (config) => {
|
|
40
|
+
config.module.rules.push({
|
|
41
|
+
test: /\\.[jt]sx$/i,
|
|
42
|
+
use: [
|
|
43
|
+
{
|
|
44
|
+
loader: 'babel-loader',
|
|
45
|
+
options: {
|
|
46
|
+
presets: ['@babel/preset-typescript'],
|
|
47
|
+
plugins: ['styled-jsx/babel'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
return config;
|
|
53
|
+
});
|
|
54
|
+
`);
|
|
55
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import { NormalizedSchema, Schema } from '../../schema';
|
|
3
|
+
export declare function setupViteConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
4
|
+
export declare function setupVitestConfiguration(tree: Tree, options: NormalizedSchema<Schema>, tasks: any[]): Promise<void>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupViteConfiguration = setupViteConfiguration;
|
|
4
|
+
exports.setupVitestConfiguration = setupVitestConfiguration;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("../../../../utils/versions");
|
|
7
|
+
async function setupViteConfiguration(tree, options, tasks) {
|
|
8
|
+
const { createOrEditViteConfig, viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
9
|
+
// We recommend users use `import.meta.env.MODE` and other variables in their code to differentiate between production and development.
|
|
10
|
+
// See: https://vitejs.dev/guide/env-and-mode.html
|
|
11
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'))) {
|
|
12
|
+
tree.delete((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src/environments'));
|
|
13
|
+
}
|
|
14
|
+
const viteTask = await viteConfigurationGenerator(tree, {
|
|
15
|
+
uiFramework: 'react',
|
|
16
|
+
project: options.projectName,
|
|
17
|
+
newProject: true,
|
|
18
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
19
|
+
inSourceTests: options.inSourceTests,
|
|
20
|
+
compiler: options.compiler,
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
addPlugin: options.addPlugin,
|
|
23
|
+
projectType: 'application',
|
|
24
|
+
});
|
|
25
|
+
tasks.push(viteTask);
|
|
26
|
+
createOrEditViteConfig(tree, {
|
|
27
|
+
project: options.projectName,
|
|
28
|
+
includeLib: false,
|
|
29
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
30
|
+
inSourceTests: options.inSourceTests,
|
|
31
|
+
rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
|
|
32
|
+
imports: [
|
|
33
|
+
options.compiler === 'swc'
|
|
34
|
+
? `import react from '@vitejs/plugin-react-swc'`
|
|
35
|
+
: `import react from '@vitejs/plugin-react'`,
|
|
36
|
+
],
|
|
37
|
+
plugins: ['react()'],
|
|
38
|
+
}, false);
|
|
39
|
+
}
|
|
40
|
+
async function setupVitestConfiguration(tree, options, tasks) {
|
|
41
|
+
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
42
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
43
|
+
uiFramework: 'react',
|
|
44
|
+
coverageProvider: 'v8',
|
|
45
|
+
project: options.projectName,
|
|
46
|
+
inSourceTests: options.inSourceTests,
|
|
47
|
+
skipFormat: true,
|
|
48
|
+
addPlugin: options.addPlugin,
|
|
49
|
+
});
|
|
50
|
+
tasks.push(vitestTask);
|
|
51
|
+
createOrEditViteConfig(tree, {
|
|
52
|
+
project: options.projectName,
|
|
53
|
+
includeLib: false,
|
|
54
|
+
includeVitest: true,
|
|
55
|
+
inSourceTests: options.inSourceTests,
|
|
56
|
+
rollupOptionsExternal: ["'react'", "'react-dom'", "'react/jsx-runtime'"],
|
|
57
|
+
imports: [
|
|
58
|
+
options.compiler === 'swc'
|
|
59
|
+
? `import react from '@vitejs/plugin-react-swc'`
|
|
60
|
+
: `import react from '@vitejs/plugin-react'`,
|
|
61
|
+
],
|
|
62
|
+
plugins: ['react()'],
|
|
63
|
+
}, true);
|
|
64
|
+
if (options.bundler === 'rsbuild') {
|
|
65
|
+
tree.rename((0, devkit_1.joinPathFragments)(options.appProjectRoot, 'vite.config.ts'), (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'vitest.config.ts'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initWebpack = initWebpack;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../../utils/versions");
|
|
6
|
+
async function initWebpack(tree, options, tasks) {
|
|
7
|
+
const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
|
|
8
|
+
const webpackInitTask = await webpackInitGenerator(tree, {
|
|
9
|
+
skipPackageJson: options.skipPackageJson,
|
|
10
|
+
skipFormat: true,
|
|
11
|
+
addPlugin: options.addPlugin,
|
|
12
|
+
});
|
|
13
|
+
tasks.push(webpackInitTask);
|
|
14
|
+
if (!options.skipPackageJson) {
|
|
15
|
+
const { ensureDependencies } = await Promise.resolve().then(() => require('@nx/webpack/src/utils/ensure-dependencies'));
|
|
16
|
+
tasks.push(ensureDependencies(tree, { uiFramework: 'react' }));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -124,6 +124,11 @@ async function createApplicationFiles(host, options) {
|
|
|
124
124
|
: null,
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
+
else if (options.bundler === 'rsbuild') {
|
|
128
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/base-rsbuild'), options.appProjectRoot, {
|
|
129
|
+
...templateVariables,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
127
132
|
if (options.unitTestRunner === 'none' ||
|
|
128
133
|
(options.unitTestRunner === 'vitest' && options.inSourceTests == true)) {
|
|
129
134
|
host.delete(`${options.appProjectRoot}/src/app/${options.fileName}.spec.tsx`);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema } from '../schema';
|
|
3
|
-
export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): import("@nx/devkit").GeneratorCallback
|
|
3
|
+
export declare function installCommonDependencies(host: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.installCommonDependencies = installCommonDependencies;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../../utils/versions");
|
|
6
|
-
|
|
6
|
+
const version_utils_1 = require("../../../utils/version-utils");
|
|
7
|
+
async function installCommonDependencies(host, options) {
|
|
7
8
|
if (options.skipPackageJson) {
|
|
8
9
|
return () => { };
|
|
9
10
|
}
|
|
11
|
+
const reactDeps = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(host);
|
|
10
12
|
const dependencies = {};
|
|
11
13
|
const devDependencies = {
|
|
12
14
|
'@types/node': versions_1.typesNodeVersion,
|
|
13
|
-
'@types/react':
|
|
14
|
-
'@types/react-dom':
|
|
15
|
+
'@types/react': reactDeps['@types/react'],
|
|
16
|
+
'@types/react-dom': reactDeps['@types/react-dom'],
|
|
15
17
|
};
|
|
16
18
|
if (options.bundler !== 'vite') {
|
|
17
19
|
dependencies['tslib'] = versions_1.tsLibVersion;
|
|
@@ -41,6 +43,7 @@ function installCommonDependencies(host, options) {
|
|
|
41
43
|
}
|
|
42
44
|
if (options.unitTestRunner && options.unitTestRunner !== 'none') {
|
|
43
45
|
devDependencies['@testing-library/react'] = versions_1.testingLibraryReactVersion;
|
|
46
|
+
devDependencies['@testing-library/dom'] = versions_1.testingLibraryDomVersion;
|
|
44
47
|
}
|
|
45
48
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
|
|
46
49
|
}
|
|
@@ -23,7 +23,7 @@ export interface Schema {
|
|
|
23
23
|
devServerPort?: number;
|
|
24
24
|
skipPackageJson?: boolean;
|
|
25
25
|
rootProject?: boolean;
|
|
26
|
-
bundler?: 'webpack' | 'vite' | 'rspack';
|
|
26
|
+
bundler?: 'webpack' | 'vite' | 'rspack' | 'rsbuild';
|
|
27
27
|
minimal?: boolean;
|
|
28
28
|
// Internal options
|
|
29
29
|
addPlugin?: boolean;
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"bundler": {
|
|
102
102
|
"description": "The bundler to use.",
|
|
103
103
|
"type": "string",
|
|
104
|
-
"enum": ["vite", "webpack", "rspack"],
|
|
104
|
+
"enum": ["vite", "webpack", "rspack", "rsbuild"],
|
|
105
105
|
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
106
106
|
"default": "vite",
|
|
107
107
|
"x-priority": "important"
|
|
@@ -6,7 +6,7 @@ import { Route, Link } from 'react-router-dom';
|
|
|
6
6
|
<%_ } _%>
|
|
7
7
|
|
|
8
8
|
<%_ if (hasStyles) {
|
|
9
|
-
if (styledModule && styledModule !== 'styled-jsx') {
|
|
9
|
+
if (styledModule && styledModule !== 'styled-jsx' && styledModule !== 'tailwind') {
|
|
10
10
|
var wrapper = 'Styled' + className;
|
|
11
11
|
var extras = '';
|
|
12
12
|
_%>
|
|
@@ -15,14 +15,14 @@ import styled from '<%= styledModule %>';
|
|
|
15
15
|
var wrapper = 'div';
|
|
16
16
|
var extras = globalCss || styledModule === 'styled-jsx' ? '' : " className={styles['container']}";
|
|
17
17
|
_%>
|
|
18
|
-
<%- style !== 'styled-jsx' ? globalCss ? `import './${fileName}.${style}';` : `import styles from './${fileName}.module.${style}';`: '' %>
|
|
18
|
+
<%- style !== 'styled-jsx' && style!== 'tailwind' ? globalCss ? `import './${fileName}.${style}';` : `import styles from './${fileName}.module.${style}';`: '' %>
|
|
19
19
|
<%_ }
|
|
20
20
|
} else {
|
|
21
21
|
var wrapper = 'div';
|
|
22
22
|
var extras = '';
|
|
23
23
|
} _%>
|
|
24
24
|
|
|
25
|
-
<%_ if (styledModule && styledModule !== 'styled-jsx') { _%>
|
|
25
|
+
<%_ if (styledModule && styledModule !== 'styled-jsx' && styledModule !== 'tailwind') { _%>
|
|
26
26
|
const Styled<%= className %> = styled.div`
|
|
27
27
|
color: pink;
|
|
28
28
|
`;
|
|
@@ -41,6 +41,10 @@
|
|
|
41
41
|
"value": "less",
|
|
42
42
|
"label": "LESS [ https://lesscss.org ]"
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
"value": "tailwind",
|
|
46
|
+
"label": "tailwind [ https://tailwindcss.com/ ]"
|
|
47
|
+
},
|
|
44
48
|
{
|
|
45
49
|
"value": "styled-components",
|
|
46
50
|
"label": "styled-components [ https://styled-components.com ]"
|
|
@@ -107,6 +107,7 @@ async function hostGenerator(host, schema) {
|
|
|
107
107
|
(0, add_mf_env_to_inputs_1.addMfEnvToTargetDefaultInputs)(host);
|
|
108
108
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, { '@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion }, {
|
|
109
109
|
'@nx/web': versions_1.nxVersion,
|
|
110
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
110
111
|
});
|
|
111
112
|
tasks.push(installTask);
|
|
112
113
|
if (!options.skipFormat) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
2
|
import { InitSchema } from './schema';
|
|
3
|
-
export declare function reactInitGenerator(
|
|
3
|
+
export declare function reactInitGenerator(tree: Tree, schema: InitSchema): Promise<GeneratorCallback>;
|
|
4
4
|
export default reactInitGenerator;
|
|
@@ -3,19 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.reactInitGenerator = reactInitGenerator;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../utils/versions");
|
|
6
|
-
|
|
6
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
7
|
+
async function reactInitGenerator(tree, schema) {
|
|
7
8
|
const tasks = [];
|
|
8
9
|
if (!schema.skipPackageJson) {
|
|
9
|
-
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/react'], []));
|
|
11
|
+
const reactDeps = await (0, version_utils_1.getReactDependenciesVersionsToInstall)(tree);
|
|
12
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
13
|
+
react: reactDeps.react,
|
|
14
|
+
'react-dom': reactDeps['react-dom'],
|
|
13
15
|
}, {
|
|
14
16
|
'@nx/react': versions_1.nxVersion,
|
|
15
17
|
}, undefined, schema.keepExistingVersions));
|
|
16
18
|
}
|
|
17
19
|
if (!schema.skipFormat) {
|
|
18
|
-
await (0, devkit_1.formatFiles)(
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
19
21
|
}
|
|
20
22
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
21
23
|
}
|
|
@@ -21,7 +21,6 @@ const create_ts_config_1 = require("../../utils/create-ts-config");
|
|
|
21
21
|
const install_common_dependencies_1 = require("./lib/install-common-dependencies");
|
|
22
22
|
const set_defaults_1 = require("./lib/set-defaults");
|
|
23
23
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
24
|
-
const plugin_1 = require("@nx/js/src/utils/typescript/plugin");
|
|
25
24
|
async function libraryGenerator(host, schema) {
|
|
26
25
|
return await libraryGeneratorInternal(host, {
|
|
27
26
|
addPlugin: false,
|
|
@@ -117,11 +116,6 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
117
116
|
const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, options);
|
|
118
117
|
tasks.push(rollupTask);
|
|
119
118
|
}
|
|
120
|
-
else if (options.bundler === 'none' && options.addPlugin) {
|
|
121
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
122
|
-
(0, plugin_1.ensureProjectIsExcludedFromPluginRegistrations)(nxJson, options.projectRoot);
|
|
123
|
-
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
124
|
-
}
|
|
125
119
|
// Set up test target
|
|
126
120
|
if (options.unitTestRunner === 'jest') {
|
|
127
121
|
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
@@ -217,12 +211,15 @@ async function libraryGeneratorInternal(host, schema) {
|
|
|
217
211
|
}, options.linter === 'eslint'
|
|
218
212
|
? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
|
|
219
213
|
: undefined);
|
|
214
|
+
if (options.isUsingTsSolutionConfig) {
|
|
215
|
+
(0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
|
|
216
|
+
}
|
|
220
217
|
if (!options.skipFormat) {
|
|
221
218
|
await (0, devkit_1.formatFiles)(host);
|
|
222
219
|
}
|
|
223
220
|
// Always run install to link packages.
|
|
224
221
|
if (options.isUsingTsSolutionConfig) {
|
|
225
|
-
tasks.push(() => (0, devkit_1.installPackagesTask)(host));
|
|
222
|
+
tasks.push(() => (0, devkit_1.installPackagesTask)(host, true));
|
|
226
223
|
}
|
|
227
224
|
tasks.push(() => {
|
|
228
225
|
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"value": "less",
|
|
53
53
|
"label": "LESS [ https://lesscss.org ]"
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
"value": "tailwind",
|
|
57
|
+
"label": "tailwind [ https://tailwindcss.com/ ]"
|
|
58
|
+
},
|
|
55
59
|
{
|
|
56
60
|
"value": "styled-components",
|
|
57
61
|
"label": "styled-components [ https://styled-components.com ]"
|
|
@@ -126,6 +126,7 @@ async function remoteGenerator(host, schema) {
|
|
|
126
126
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
127
127
|
'@module-federation/enhanced': versions_1.moduleFederationEnhancedVersion,
|
|
128
128
|
'@nx/web': versions_1.nxVersion,
|
|
129
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
129
130
|
});
|
|
130
131
|
tasks.push(installTask);
|
|
131
132
|
if (!options.skipFormat) {
|
|
@@ -4,6 +4,7 @@ exports.default = migrateWithMfImport;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const versions_1 = require("../../utils/versions");
|
|
7
8
|
const NX_RSPACK_MODULE_FEDERATION_IMPORT_SELECTOR = 'ImportDeclaration > StringLiteral[value=@nx/react/module-federation], VariableStatement CallExpression:has(Identifier[name=require]) > StringLiteral[value=@nx/react/module-federation]';
|
|
8
9
|
const NEW_IMPORT_PATH = `'@nx/module-federation/webpack'`;
|
|
9
10
|
async function migrateWithMfImport(tree) {
|
|
@@ -31,5 +32,10 @@ async function migrateWithMfImport(tree) {
|
|
|
31
32
|
tree.write(filePath, contents);
|
|
32
33
|
});
|
|
33
34
|
}
|
|
35
|
+
if (projects.size !== 0) {
|
|
36
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
37
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
34
40
|
await (0, devkit_1.formatFiles)(tree);
|
|
35
41
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ensureMfPackage;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
async function ensureMfPackage(tree) {
|
|
8
|
+
const projects = new Set();
|
|
9
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/react:module-federation-dev-server', (options, project, target) => {
|
|
10
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
|
+
projects.add(projectConfig.root);
|
|
12
|
+
});
|
|
13
|
+
if (projects.size !== 0) {
|
|
14
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
15
|
+
'@nx/module-federation': versions_1.nxVersion,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasRsbuildPlugin = hasRsbuildPlugin;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("./versions");
|
|
6
|
+
async function hasRsbuildPlugin(tree, projectPath) {
|
|
7
|
+
(0, devkit_1.ensurePackage)('@nx/rsbuild', versions_1.nxVersion);
|
|
8
|
+
const { hasRsbuildPlugin } = await Promise.resolve().then(() => require('@nx/rsbuild/config-utils'));
|
|
9
|
+
return hasRsbuildPlugin(tree, projectPath);
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
type ReactDependenciesVersions = {
|
|
3
|
+
react: string;
|
|
4
|
+
'react-dom': string;
|
|
5
|
+
'react-is': string;
|
|
6
|
+
'@types/react': string;
|
|
7
|
+
'@types/react-dom': string;
|
|
8
|
+
'@types/react-is': string;
|
|
9
|
+
};
|
|
10
|
+
export declare function getReactDependenciesVersionsToInstall(tree: Tree): Promise<ReactDependenciesVersions>;
|
|
11
|
+
export declare function isReact18(tree: Tree): Promise<boolean>;
|
|
12
|
+
export declare function getInstalledReactVersion(tree: Tree): string;
|
|
13
|
+
export declare function getInstalledReactVersionFromGraph(): Promise<string>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReactDependenciesVersionsToInstall = getReactDependenciesVersionsToInstall;
|
|
4
|
+
exports.isReact18 = isReact18;
|
|
5
|
+
exports.getInstalledReactVersion = getInstalledReactVersion;
|
|
6
|
+
exports.getInstalledReactVersionFromGraph = getInstalledReactVersionFromGraph;
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const semver_1 = require("semver");
|
|
9
|
+
const versions_1 = require("./versions");
|
|
10
|
+
async function getReactDependenciesVersionsToInstall(tree) {
|
|
11
|
+
if (await isReact18(tree)) {
|
|
12
|
+
return {
|
|
13
|
+
react: versions_1.reactV18Version,
|
|
14
|
+
'react-dom': versions_1.reactDomV18Version,
|
|
15
|
+
'react-is': versions_1.reactIsV18Version,
|
|
16
|
+
'@types/react': versions_1.typesReactV18Version,
|
|
17
|
+
'@types/react-dom': versions_1.typesReactDomV18Version,
|
|
18
|
+
'@types/react-is': versions_1.typesReactIsV18Version,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return {
|
|
23
|
+
react: versions_1.reactVersion,
|
|
24
|
+
'react-dom': versions_1.reactDomVersion,
|
|
25
|
+
'react-is': versions_1.reactIsVersion,
|
|
26
|
+
'@types/react': versions_1.typesReactVersion,
|
|
27
|
+
'@types/react-dom': versions_1.typesReactDomVersion,
|
|
28
|
+
'@types/react-is': versions_1.typesReactIsVersion,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function isReact18(tree) {
|
|
33
|
+
let installedReactVersion = await getInstalledReactVersionFromGraph();
|
|
34
|
+
if (!installedReactVersion) {
|
|
35
|
+
installedReactVersion = getInstalledReactVersion(tree);
|
|
36
|
+
}
|
|
37
|
+
return (0, semver_1.major)(installedReactVersion) === 18;
|
|
38
|
+
}
|
|
39
|
+
function getInstalledReactVersion(tree) {
|
|
40
|
+
const pkgJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
41
|
+
const installedReactVersion = pkgJson.dependencies && pkgJson.dependencies['react'];
|
|
42
|
+
if (!installedReactVersion ||
|
|
43
|
+
installedReactVersion === 'latest' ||
|
|
44
|
+
installedReactVersion === 'next') {
|
|
45
|
+
return (0, semver_1.clean)(versions_1.reactVersion) ?? (0, semver_1.coerce)(versions_1.reactVersion).version;
|
|
46
|
+
}
|
|
47
|
+
return (0, semver_1.clean)(installedReactVersion) ?? (0, semver_1.coerce)(installedReactVersion).version;
|
|
48
|
+
}
|
|
49
|
+
async function getInstalledReactVersionFromGraph() {
|
|
50
|
+
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
51
|
+
const reactDep = graph.externalNodes?.['npm:react'];
|
|
52
|
+
if (!reactDep) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return (0, semver_1.clean)(reactDep.data.version) ?? (0, semver_1.coerce)(reactDep.data.version).version;
|
|
56
|
+
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const reactVersion = "
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
2
|
+
export declare const reactVersion = "19.0.0";
|
|
3
|
+
export declare const reactV18Version = "18.3.1";
|
|
4
|
+
export declare const reactDomVersion = "19.0.0";
|
|
5
|
+
export declare const reactDomV18Version = "18.3.1";
|
|
6
|
+
export declare const reactIsVersion = "19.0.0";
|
|
7
|
+
export declare const reactIsV18Version = "18.3.1";
|
|
5
8
|
export declare const swcLoaderVersion = "0.1.15";
|
|
6
9
|
export declare const babelLoaderVersion = "^9.1.2";
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const typesReactV18Version = "18.3.1";
|
|
11
|
+
export declare const typesReactVersion = "19.0.0";
|
|
12
|
+
export declare const typesReactDomV18Version = "18.3.0";
|
|
13
|
+
export declare const typesReactDomVersion = "19.0.0";
|
|
14
|
+
export declare const typesReactIsV18Version = "18.3.0";
|
|
15
|
+
export declare const typesReactIsVersion = "19.0.0";
|
|
10
16
|
export declare const reactViteVersion = "^4.2.0";
|
|
11
17
|
export declare const typesNodeVersion = "18.16.9";
|
|
12
18
|
export declare const babelPresetReactVersion = "^7.14.5";
|
|
@@ -18,7 +24,8 @@ export declare const emotionReactVersion = "11.11.1";
|
|
|
18
24
|
export declare const emotionBabelPlugin = "11.11.0";
|
|
19
25
|
export declare const styledJsxVersion = "5.1.2";
|
|
20
26
|
export declare const reactRouterDomVersion = "6.11.2";
|
|
21
|
-
export declare const testingLibraryReactVersion = "
|
|
27
|
+
export declare const testingLibraryReactVersion = "16.1.0";
|
|
28
|
+
export declare const testingLibraryDomVersion = "10.4.0";
|
|
22
29
|
export declare const reduxjsToolkitVersion = "1.9.3";
|
|
23
30
|
export declare const reactReduxVersion = "8.0.5";
|
|
24
31
|
export declare const eslintPluginImportVersion = "2.31.0";
|