@nx/react 16.8.0-beta.3 → 16.8.0-beta.5
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/babel.js +2 -3
- package/package.json +7 -7
- package/plugins/bundle-rollup.js +9 -3
- package/plugins/component-testing/index.js +57 -37
- package/plugins/jest.js +4 -6
- package/plugins/storybook/index.js +46 -17
- package/plugins/with-react.js +5 -9
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +101 -103
- package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +67 -72
- package/src/generators/application/application.js +124 -124
- package/src/generators/application/lib/add-e2e.js +41 -37
- package/src/generators/application/lib/add-jest.js +13 -8
- package/src/generators/application/lib/add-project.js +4 -3
- package/src/generators/application/lib/create-application-files.js +8 -1
- package/src/generators/application/lib/find-free-port.js +1 -2
- package/src/generators/application/lib/normalize-options.js +49 -47
- package/src/generators/application/lib/set-defaults.js +25 -5
- package/src/generators/component/component.js +68 -64
- package/src/generators/component-cypress-spec/component-cypress-spec.js +6 -9
- package/src/generators/component-story/component-story.js +8 -9
- package/src/generators/component-test/component-test.js +15 -18
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +23 -26
- package/src/generators/cypress-component-configuration/lib/add-files.js +38 -42
- package/src/generators/hook/hook.js +59 -58
- package/src/generators/host/host.js +54 -53
- package/src/generators/host/lib/add-module-federation-files.js +11 -3
- package/src/generators/host/lib/normalize-remote.js +8 -11
- package/src/generators/host/lib/setup-ssr-for-host.js +21 -15
- package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -2
- package/src/generators/init/init.js +30 -20
- package/src/generators/library/lib/add-linting.js +24 -27
- package/src/generators/library/lib/add-rollup-build-target.js +42 -46
- package/src/generators/library/lib/create-files.js +7 -1
- package/src/generators/library/lib/normalize-options.js +53 -50
- package/src/generators/library/lib/set-defaults.js +12 -4
- package/src/generators/library/library.js +122 -111
- package/src/generators/redux/redux.js +25 -16
- package/src/generators/remote/lib/setup-ssr-for-remote.js +25 -23
- package/src/generators/remote/remote.js +44 -39
- package/src/generators/setup-ssr/setup-ssr.js +134 -132
- package/src/generators/setup-tailwind/lib/update-project.js +3 -5
- package/src/generators/setup-tailwind/setup-tailwind.js +23 -26
- package/src/generators/stories/stories.js +79 -88
- package/src/generators/storybook-configuration/configuration.js +40 -47
- package/src/migrations/update-12-0-0/remove-react-redux-types-package.js +2 -5
- package/src/migrations/update-12-0-0/update-emotion-setup.js +50 -55
- package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js +14 -18
- package/src/migrations/update-12-8-0/update-12-8-0.js +3 -6
- package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js +23 -26
- package/src/migrations/update-13-0-0/update-emotion-setup.js +24 -27
- package/src/migrations/update-13-0-0/webpack5-changes-utils.js +30 -34
- package/src/migrations/update-13-10-0/update-13-10-0.js +15 -18
- package/src/migrations/update-14-0-0/add-default-development-configurations.js +26 -31
- package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js +12 -16
- package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +13 -17
- package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +24 -27
- package/src/migrations/update-14-6-0/add-preset-jest-config.js +1 -2
- package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +3 -4
- package/src/migrations/update-15-3-0/update-rollup-executor.js +1 -2
- package/src/migrations/update-15-6-3/webpack-config-setup.js +56 -60
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +3 -6
- package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +3 -6
- package/src/migrations/update-16-7-0/add-babel-core.js +8 -11
- package/src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings.js +36 -41
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/load-config.js +1 -1
- package/src/module-federation/utils.js +36 -37
- package/src/module-federation/with-module-federation-ssr.js +24 -25
- package/src/module-federation/with-module-federation.js +23 -22
- package/src/rules/update-module-federation-project.js +9 -2
- package/src/utils/ast-utils.js +12 -15
- package/src/utils/create-ts-config.js +6 -4
- package/src/utils/ct-utils.js +31 -33
- package/src/utils/lint.js +5 -3
- package/src/utils/testing-generators.js +18 -22
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
if (shouldUpdate)
|
|
33
|
-
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
34
|
-
});
|
|
35
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
projects.forEach((config, name) => {
|
|
8
|
+
let shouldUpdate = false;
|
|
9
|
+
if (config.targets?.build?.executor === '@nrwl/web:webpack') {
|
|
10
|
+
shouldUpdate = true;
|
|
11
|
+
config.targets.build.defaultConfiguration ??= 'production';
|
|
12
|
+
config.targets.build.configurations ??= {};
|
|
13
|
+
config.targets.build.configurations.development ??= {
|
|
14
|
+
extractLicenses: false,
|
|
15
|
+
optimization: false,
|
|
16
|
+
sourceMap: true,
|
|
17
|
+
vendorChunk: true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (config.targets?.serve?.executor === '@nrwl/web:dev-server') {
|
|
21
|
+
shouldUpdate = true;
|
|
22
|
+
config.targets.serve.defaultConfiguration ??= 'development';
|
|
23
|
+
config.targets.serve.configurations ??= {};
|
|
24
|
+
config.targets.serve.configurations.development ??= {
|
|
25
|
+
buildTarget: `${name}:build:development`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (shouldUpdate)
|
|
29
|
+
(0, devkit_1.updateProjectConfiguration)(tree, name, config);
|
|
36
30
|
});
|
|
31
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
37
32
|
}
|
|
38
33
|
exports.update = update;
|
|
39
34
|
exports.default = update;
|
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
function update(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
async function update(tree) {
|
|
6
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
7
|
+
projects.forEach((config) => {
|
|
8
|
+
if (config.targets?.test?.executor !== '@nrwl/jest:jest')
|
|
9
|
+
return;
|
|
10
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, config.sourceRoot, (file) => {
|
|
11
|
+
if (!file.endsWith('.spec.ts'))
|
|
12
12
|
return;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (content.includes('@testing-library/react-hooks')) {
|
|
18
|
-
tree.write(file, content.replace(/@testing-library\/react-hooks/g, '@testing-library/react'));
|
|
19
|
-
}
|
|
20
|
-
});
|
|
13
|
+
const content = tree.read(file).toString();
|
|
14
|
+
if (content.includes('@testing-library/react-hooks')) {
|
|
15
|
+
tree.write(file, content.replace(/@testing-library\/react-hooks/g, '@testing-library/react'));
|
|
16
|
+
}
|
|
21
17
|
});
|
|
22
|
-
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@testing-library/react-hooks'], ['@testing-library/react-hooks']);
|
|
23
18
|
});
|
|
19
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@testing-library/react-hooks'], ['@testing-library/react-hooks']);
|
|
24
20
|
}
|
|
25
21
|
exports.update = update;
|
|
26
22
|
exports.default = update;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateReactDomRender = exports.update = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const ts = require("typescript");
|
|
8
|
-
function update(tree) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
tree.write(sourcePath, result);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
7
|
+
async function update(tree) {
|
|
8
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
|
+
projects.forEach((config, name) => {
|
|
10
|
+
const isReactProject = config.targets?.build?.executor === '@nrwl/web:webpack' &&
|
|
11
|
+
/main\.(t|j)sx?$/.test(config.targets.build.options.main);
|
|
12
|
+
if (isReactProject) {
|
|
13
|
+
const sourcePath = config.targets.build.options.main;
|
|
14
|
+
const sourceCode = tree.read(sourcePath).toString();
|
|
15
|
+
const source = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true);
|
|
16
|
+
const result = (0, devkit_1.applyChangesToString)(sourceCode, migrateReactDomRender(sourcePath, source));
|
|
17
|
+
tree.write(sourcePath, result);
|
|
18
|
+
}
|
|
24
19
|
});
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
25
21
|
}
|
|
26
22
|
exports.update = update;
|
|
27
23
|
function migrateReactDomRender(sourcePath, source) {
|
|
@@ -1,36 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateExternalEmotionJsxRuntime = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
7
|
-
function updateExternalEmotionJsxRuntime(tree) {
|
|
8
|
-
|
|
9
|
-
(0,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
6
|
+
async function updateExternalEmotionJsxRuntime(tree) {
|
|
7
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/web:rollup', (options, projectName, targetName, configurationName) => {
|
|
8
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
9
|
+
const config = configurationName
|
|
10
|
+
? projectConfiguration.targets[targetName].configurations[configurationName]
|
|
11
|
+
: projectConfiguration.targets[targetName].options;
|
|
12
|
+
if (config.external && config.external.length > 0) {
|
|
13
|
+
const hasEmotionStyledBase = config.external.includes('@emotion/styled/base');
|
|
14
|
+
const hasReactJsxRuntime = config.external.includes('react/jsx-runtime');
|
|
15
|
+
if (hasEmotionStyledBase && hasReactJsxRuntime) {
|
|
16
|
+
// Replace 'react/jsx-runtime' with '@emotion/react/jsx-runtime'
|
|
17
|
+
config.external.forEach((value, index) => {
|
|
18
|
+
if (value === 'react/jsx-runtime') {
|
|
19
|
+
config.external.splice(index, 1, '@emotion/react/jsx-runtime');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// Remove '@emotion/styled/base'
|
|
23
|
+
config.external.forEach((value, index) => {
|
|
24
|
+
if (value === '@emotion/styled/base') {
|
|
25
|
+
config.external.splice(index, 1);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
32
28
|
}
|
|
33
|
-
|
|
29
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
30
|
+
}
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
exports.updateExternalEmotionJsxRuntime = updateExternalEmotionJsxRuntime;
|
|
@@ -19,7 +19,6 @@ function addBabelJestPresetTransformerOption(tree) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.addBabelJestPresetTransformerOption = addBabelJestPresetTransformerOption;
|
|
21
21
|
function isReactProject(tree, projectConfig) {
|
|
22
|
-
var _a, _b;
|
|
23
22
|
const knownInvalidExecutors = [
|
|
24
23
|
'@nrwl/next:build',
|
|
25
24
|
'@nrwl/angular',
|
|
@@ -30,7 +29,7 @@ function isReactProject(tree, projectConfig) {
|
|
|
30
29
|
'nx:run-commands',
|
|
31
30
|
'@nrwl/node:webpack',
|
|
32
31
|
];
|
|
33
|
-
if (knownInvalidExecutors.includes(
|
|
32
|
+
if (knownInvalidExecutors.includes(projectConfig?.targets?.build?.executor) ||
|
|
34
33
|
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'next.config.js'))) {
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
@@ -4,13 +4,12 @@ exports.installWebpackRollupDependencies = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const versions_1 = require("../../utils/versions");
|
|
6
6
|
function installWebpackRollupDependencies(tree) {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8
7
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
9
8
|
let shouldInstall = false;
|
|
10
9
|
for (const [, project] of projects) {
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
if (project.targets?.build?.executor === '@nrwl/webpack:webpack' ||
|
|
11
|
+
project.targets?.build?.executor === '@nrwl/rollup:rollup' ||
|
|
12
|
+
project.targets?.build?.executor === '@nrwl/web:rollup') {
|
|
14
13
|
shouldInstall = true;
|
|
15
14
|
break;
|
|
16
15
|
}
|
|
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateRollupExecutor = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function updateRollupExecutor(tree) {
|
|
6
|
-
var _a, _b;
|
|
7
6
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
8
7
|
for (const [name, project] of projects) {
|
|
9
|
-
if (
|
|
8
|
+
if (project.targets?.build?.executor === '@nrwl/web:rollup') {
|
|
10
9
|
project.targets.build.executor = '@nrwl/rollup:rollup';
|
|
11
10
|
(0, devkit_1.updateProjectConfiguration)(tree, name, project);
|
|
12
11
|
}
|
|
@@ -1,50 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
5
|
const path_1 = require("path");
|
|
7
|
-
function default_1(tree) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(0,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
6
|
+
async function default_1(tree) {
|
|
7
|
+
// Since projects can have multiple configurations, we need to know if the default options
|
|
8
|
+
// need to be migrated or not. If so then the subsequent configurations with `webpackConfig` also need to be.
|
|
9
|
+
const defaultOptionsUpdated = new Set();
|
|
10
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/webpack:webpack', (options, projectName, targetName, configurationName) => {
|
|
11
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
12
|
+
const defaultOptions = projectConfiguration.targets[targetName].options;
|
|
13
|
+
const defaultWasUpdated = defaultOptionsUpdated.has(projectName);
|
|
14
|
+
// If default was not updated (for different configurations), we don't do anything
|
|
15
|
+
// If isolatedConfig is set, we don't need to do anything
|
|
16
|
+
// If it is NOT React, we don't need to do anything
|
|
17
|
+
if (!defaultWasUpdated &&
|
|
18
|
+
(defaultOptions?.['isolatedConfig'] ||
|
|
19
|
+
!(defaultOptions?.['main']?.match(/main\.(t|j)sx$/) ||
|
|
20
|
+
defaultOptions?.['webpackConfig'] === '@nrwl/react/plugins/webpack'))) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
defaultOptionsUpdated.add(projectName);
|
|
24
|
+
// If this is not the default options (e.g. for development, production, or something custom),
|
|
25
|
+
// then skip it unless it specifically configures a webpackConfig file
|
|
26
|
+
if (configurationName && !options?.webpackConfig) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// If webpackConfig is set, update it with the new options
|
|
30
|
+
// If webpackConfig is not set, we need to create a new
|
|
31
|
+
// webpack.config.js file and set the path to it in the
|
|
32
|
+
// executor options
|
|
33
|
+
if (options?.['webpackConfig'] &&
|
|
34
|
+
options['webpackConfig'] !== '@nrwl/react/plugins/webpack') {
|
|
35
|
+
let oldName = options['webpackConfig'];
|
|
36
|
+
if (options['webpackConfig'].endsWith('.js')) {
|
|
37
|
+
oldName = options['webpackConfig'].replace('.js', '.old.js');
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// then skip it unless it specifically configures a webpackConfig file
|
|
29
|
-
if (configurationName && !(options === null || options === void 0 ? void 0 : options.webpackConfig)) {
|
|
30
|
-
return;
|
|
39
|
+
if (options['webpackConfig'].endsWith('.ts')) {
|
|
40
|
+
oldName = options['webpackConfig'].replace('.ts', '.old.ts');
|
|
31
41
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// executor options
|
|
36
|
-
if ((options === null || options === void 0 ? void 0 : options['webpackConfig']) &&
|
|
37
|
-
options['webpackConfig'] !== '@nrwl/react/plugins/webpack') {
|
|
38
|
-
let oldName = options['webpackConfig'];
|
|
39
|
-
if (options['webpackConfig'].endsWith('.js')) {
|
|
40
|
-
oldName = options['webpackConfig'].replace('.js', '.old.js');
|
|
41
|
-
}
|
|
42
|
-
if (options['webpackConfig'].endsWith('.ts')) {
|
|
43
|
-
oldName = options['webpackConfig'].replace('.ts', '.old.ts');
|
|
44
|
-
}
|
|
45
|
-
renameFile(tree, options['webpackConfig'], oldName);
|
|
46
|
-
const justTheFileName = (0, path_1.basename)(oldName);
|
|
47
|
-
tree.write(options['webpackConfig'], `
|
|
42
|
+
renameFile(tree, options['webpackConfig'], oldName);
|
|
43
|
+
const justTheFileName = (0, path_1.basename)(oldName);
|
|
44
|
+
tree.write(options['webpackConfig'], `
|
|
48
45
|
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
49
46
|
const { withReact } = require('@nrwl/react');
|
|
50
47
|
|
|
@@ -53,30 +50,30 @@ function default_1(tree) {
|
|
|
53
50
|
// Note: This was added by an Nx migration.
|
|
54
51
|
// You should consider inlining the logic into this file.
|
|
55
52
|
// For more information on webpack config and Nx see:
|
|
56
|
-
// https://nx.dev/
|
|
53
|
+
// https://nx.dev/recipes/webpack/webpack-config-setup
|
|
57
54
|
return require('./${justTheFileName}')(config, context);
|
|
58
55
|
});
|
|
59
56
|
`);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
options['isolatedConfig'] = true;
|
|
58
|
+
projectConfiguration.targets[targetName][configurationName ?? 'options'] = options;
|
|
59
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
60
|
+
devkit_1.logger.info(`
|
|
64
61
|
${options['webpackConfig']} has been renamed to ${oldName} and a new ${options['webpackConfig']}
|
|
65
62
|
has been created for your project ${projectName}.
|
|
66
63
|
You should consider inlining the logic from ${oldName} into ${options['webpackConfig']}.
|
|
67
64
|
You can read our guide on how to do this here:
|
|
68
65
|
|
|
69
|
-
https://nx.dev/
|
|
66
|
+
https://nx.dev/recipes/webpack/webpack-config-setup
|
|
70
67
|
`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
|
71
|
+
if (!options) {
|
|
72
|
+
options = {};
|
|
71
73
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
options = {};
|
|
76
|
-
}
|
|
77
|
-
options['webpackConfig'] = `${projectConfiguration.root}/webpack.config.js`;
|
|
78
|
-
options['isolatedConfig'] = true;
|
|
79
|
-
tree.write(options['webpackConfig'], `
|
|
74
|
+
options['webpackConfig'] = `${projectConfiguration.root}/webpack.config.js`;
|
|
75
|
+
options['isolatedConfig'] = true;
|
|
76
|
+
tree.write(options['webpackConfig'], `
|
|
80
77
|
const { composePlugins, withNx } = require('@nrwl/webpack');
|
|
81
78
|
const { withReact } = require('@nrwl/react');
|
|
82
79
|
|
|
@@ -85,16 +82,15 @@ function default_1(tree) {
|
|
|
85
82
|
// Update the webpack config as needed here.
|
|
86
83
|
// e.g. config.plugins.push(new MyPlugin())
|
|
87
84
|
// For more information on webpack config and Nx see:
|
|
88
|
-
// https://nx.dev/
|
|
85
|
+
// https://nx.dev/recipes/webpack/webpack-config-setup
|
|
89
86
|
return config;
|
|
90
87
|
});
|
|
91
88
|
`);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
89
|
+
projectConfiguration.targets[targetName].options = options;
|
|
90
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
91
|
+
}
|
|
97
92
|
});
|
|
93
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
98
94
|
}
|
|
99
95
|
exports.default = default_1;
|
|
100
96
|
function renameFile(tree, from, to) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
6
|
-
function replacePackage(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
10
|
-
});
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react', '@nx/react');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
8
|
}
|
|
12
9
|
exports.default = replacePackage;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function removePackage(tree) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
});
|
|
4
|
+
async function removePackage(tree) {
|
|
5
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
|
|
6
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
10
7
|
}
|
|
11
8
|
exports.default = removePackage;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function removePackage(tree) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
yield (0, devkit_1.formatFiles)(tree);
|
|
9
|
-
});
|
|
4
|
+
async function removePackage(tree) {
|
|
5
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['react-test-renderer']);
|
|
6
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
10
7
|
}
|
|
11
8
|
exports.default = removePackage;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
4
|
const versions_1 = require("../../utils/versions");
|
|
6
|
-
function addBabelCore(tree) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
});
|
|
5
|
+
async function addBabelCore(tree) {
|
|
6
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
7
|
+
if (packageJson?.devDependencies['@babel/preset-react']) {
|
|
8
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
9
|
+
'@babel/core': versions_1.babelCoreVersion,
|
|
10
|
+
});
|
|
11
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
12
|
+
}
|
|
16
13
|
}
|
|
17
14
|
exports.default = addBabelCore;
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function addTypings(tree) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
4
|
+
async function addTypings(tree) {
|
|
5
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
6
|
+
const buildExecutors = [
|
|
7
|
+
'@nx/webpack:webpack',
|
|
8
|
+
'@nx/vite:build',
|
|
9
|
+
'@nx/rspack:rspack',
|
|
10
|
+
];
|
|
11
|
+
const relatedTsConfigs = [
|
|
12
|
+
'tsconfig.app.json',
|
|
13
|
+
'tsconfig.lib.json',
|
|
14
|
+
'tsconfig.spec.json',
|
|
15
|
+
];
|
|
16
|
+
const typesToAdd = [
|
|
17
|
+
'@nx/react/typings/cssmodule.d.ts',
|
|
18
|
+
'@nx/react/typings/image.d.ts',
|
|
19
|
+
];
|
|
20
|
+
for (const [, config] of projects) {
|
|
21
|
+
if (buildExecutors.includes(config?.targets?.build?.executor)) {
|
|
22
|
+
const rootPath = config.root;
|
|
23
|
+
relatedTsConfigs.forEach((tsConfig) => {
|
|
24
|
+
const tsConfigPath = (0, devkit_1.joinPathFragments)(rootPath, tsConfig);
|
|
25
|
+
if (tree.exists(tsConfigPath)) {
|
|
26
|
+
(0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
|
|
27
|
+
const compilerOptions = json.compilerOptions || {};
|
|
28
|
+
compilerOptions.types = [
|
|
29
|
+
...new Set([...(compilerOptions.types || []), ...typesToAdd]),
|
|
30
|
+
];
|
|
31
|
+
if (json.files?.length > 0) {
|
|
32
|
+
json.files = json.files.filter((file) => !['cssmodule.d.ts', 'image.d.ts'].includes(file));
|
|
33
|
+
}
|
|
34
|
+
return { ...json, compilerOptions };
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
}
|
|
40
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
46
41
|
}
|
|
47
42
|
exports.default = addTypings;
|
|
@@ -40,7 +40,7 @@ function addRemoteToConfig(source, app) {
|
|
|
40
40
|
pae.name.getText() === 'exports');
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
if (
|
|
43
|
+
if (exportExpression?.right.kind === tsModule.SyntaxKind.ObjectLiteralExpression) {
|
|
44
44
|
const ole = exportExpression.right;
|
|
45
45
|
return [
|
|
46
46
|
{
|
|
@@ -8,7 +8,7 @@ function loadModuleFederationConfigFromContext(context) {
|
|
|
8
8
|
try {
|
|
9
9
|
return require(moduleFederationConfigPath);
|
|
10
10
|
}
|
|
11
|
-
catch
|
|
11
|
+
catch {
|
|
12
12
|
// TODO(jack): Add a link to guide
|
|
13
13
|
throw new Error(`Could not load ${moduleFederationConfigPath}. Was this project generated with "@nx/react:host"?`);
|
|
14
14
|
}
|