@nx/react 17.0.5 → 17.0.6
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/README.md +4 -9
- package/generators.json +1 -1
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/migrations.json +0 -21
- package/package.json +7 -7
- package/plugins/component-testing/index.js +24 -52
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/storybook/index.js +2 -6
- package/plugins/storybook/merge-plugins.d.ts +1 -1
- package/plugins/webpack.d.ts +3 -1
- package/plugins/webpack.js +11 -3
- package/plugins/with-react.d.ts +4 -2
- package/plugins/with-react.js +58 -2
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +0 -13
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +58 -173
- package/src/executors/module-federation-dev-server/schema.json +1 -13
- package/src/generators/application/application.js +18 -41
- package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +3 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +6 -0
- package/src/generators/application/files/base-webpack/src/index.html +2 -0
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +5 -46
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +13 -54
- package/src/generators/application/lib/add-e2e.js +7 -25
- package/src/generators/application/lib/add-jest.js +2 -2
- package/src/generators/application/lib/add-project.d.ts +2 -2
- package/src/generators/application/lib/add-project.js +15 -12
- package/src/generators/application/lib/add-routing.d.ts +1 -1
- package/src/generators/application/lib/add-routing.js +8 -4
- package/src/generators/application/lib/create-application-files.js +1 -30
- package/src/generators/application/lib/install-common-dependencies.js +1 -15
- package/src/generators/application/lib/normalize-options.js +1 -35
- package/src/generators/application/lib/set-defaults.js +0 -1
- package/src/generators/application/lib/update-jest-config.js +8 -8
- package/src/generators/application/schema.d.ts +0 -5
- package/src/generators/application/schema.json +3 -7
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +22 -39
- package/src/generators/component/lib/normalize-options.js +2 -4
- package/src/generators/component/schema.d.ts +4 -6
- package/src/generators/component/schema.json +7 -7
- package/src/generators/component-cypress-spec/schema.json +1 -1
- package/src/generators/component-story/schema.json +1 -1
- package/src/generators/component-test/schema.json +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +7 -18
- package/src/generators/cypress-component-configuration/lib/add-files.js +6 -1
- package/src/generators/cypress-component-configuration/schema.d.ts +0 -1
- package/src/generators/federate-module/federate-module.js +2 -2
- package/src/generators/federate-module/schema.d.ts +1 -1
- package/src/generators/federate-module/schema.json +3 -4
- package/src/generators/hook/files/__fileName__.ts__tmpl__ +15 -15
- package/src/generators/hook/schema.d.ts +4 -4
- package/src/generators/hook/schema.json +5 -5
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +2 -17
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +2 -5
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +2 -17
- package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +1 -0
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +1 -2
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +1 -15
- package/src/generators/host/lib/add-module-federation-files.d.ts +1 -2
- package/src/generators/host/lib/add-module-federation-files.js +11 -24
- package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
- package/src/generators/host/lib/update-module-federation-e2e-project.js +5 -7
- package/src/generators/host/schema.d.ts +2 -5
- package/src/generators/host/schema.json +6 -16
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +49 -10
- package/src/generators/init/schema.d.ts +6 -1
- package/src/generators/init/schema.json +22 -5
- package/src/generators/library/lib/add-linting.js +2 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +1 -2
- package/src/generators/library/lib/add-rollup-build-target.js +8 -16
- package/src/generators/library/lib/install-common-dependencies.js +5 -13
- package/src/generators/library/lib/maybe-js.d.ts +2 -0
- package/src/generators/library/lib/normalize-options.js +5 -34
- package/src/generators/library/lib/update-app-routes.js +1 -1
- package/src/generators/library/library.js +6 -17
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +3 -3
- package/src/generators/redux/schema.d.ts +1 -1
- package/src/generators/redux/schema.json +2 -2
- package/src/generators/remote/files/module-federation/module-federation.config.js__tmpl__ +1 -4
- package/src/generators/remote/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +1 -1
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +1 -4
- package/src/generators/remote/lib/setup-ssr-for-remote.js +1 -5
- package/src/generators/remote/lib/setup-tspath-for-remote.js +1 -2
- package/src/generators/remote/lib/update-host-with-remote.js +1 -10
- package/src/generators/remote/remote.js +2 -22
- package/src/generators/remote/schema.d.ts +2 -3
- package/src/generators/remote/schema.json +6 -17
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +7 -23
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +5 -17
- package/src/generators/storybook-configuration/configuration.d.ts +0 -2
- package/src/generators/storybook-configuration/configuration.js +15 -37
- package/src/generators/storybook-configuration/schema.d.ts +1 -2
- package/src/generators/storybook-configuration/schema.json +7 -7
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/utils.js +1 -8
- package/src/module-federation/with-module-federation-ssr.js +0 -3
- package/src/module-federation/with-module-federation.d.ts +3 -3
- package/src/module-federation/with-module-federation.js +4 -14
- package/src/rules/update-module-federation-project.d.ts +0 -2
- package/src/rules/update-module-federation-project.js +3 -12
- package/src/utils/assertion.js +0 -1
- package/src/utils/ct-utils.d.ts +1 -6
- package/src/utils/ct-utils.js +9 -39
- package/src/utils/get-in-source-vitest-tests-template.js +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/typings/style.d.ts +0 -1
- package/mf/dynamic-federation.d.ts +0 -4
- package/mf/dynamic-federation.js +0 -75
- package/mf/index.d.ts +0 -1
- package/mf/index.js +0 -7
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +0 -4
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +0 -86
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +0 -8
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +0 -13
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +0 -33
- package/src/generators/application/files/style-tailwind/src/styles.css +0 -1
- package/src/generators/host/files/common/src/main.js__tmpl__ +0 -10
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +0 -41
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +0 -10
- package/src/generators/remote/files/module-federation-ssr-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +0 -19
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +0 -2
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +0 -11
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +0 -2
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +0 -26
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +0 -2
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +0 -53
- package/src/utils/add-mf-env-to-inputs.d.ts +0 -2
- package/src/utils/add-mf-env-to-inputs.js +0 -27
- package/src/utils/has-vite-plugin.d.ts +0 -2
- package/src/utils/has-vite-plugin.js +0 -11
- package/src/utils/has-webpack-plugin.d.ts +0 -2
- package/src/utils/has-webpack-plugin.js +0 -11
- package/src/utils/maybe-js.d.ts +0 -3
- /package/src/generators/host/files/common/src/app/{__fileName__.js__tmpl__ → __fileName__.tsx__tmpl__} +0 -0
- /package/src/{utils → generators/library/lib}/maybe-js.js +0 -0
- /package/src/generators/remote/files/{common/src/main.js__tmpl__ → module-federation/src/main.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common/src/remote-entry.js__tmpl__ → module-federation/src/remote-entry.ts__tmpl__} +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/main.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/{common-ts → module-federation-ts}/src/remote-entry.ts__tmpl__ +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
<p style="text-align: center;">
|
|
2
|
-
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
-
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
-
</picture>
|
|
6
|
-
</p>
|
|
1
|
+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
7
2
|
|
|
8
3
|
<div style="text-align: center;">
|
|
9
4
|
|
|
@@ -20,9 +15,9 @@
|
|
|
20
15
|
|
|
21
16
|
<hr>
|
|
22
17
|
|
|
23
|
-
# Nx: Smart
|
|
18
|
+
# Nx: Smart, Fast and Extensible Build System
|
|
24
19
|
|
|
25
|
-
Nx is a build system with
|
|
20
|
+
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
26
21
|
|
|
27
22
|
This package is a [React plugin for Nx](https://nx.dev/packages/react).
|
|
28
23
|
|
|
@@ -64,5 +59,5 @@ npx nx@latest init
|
|
|
64
59
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
65
60
|
|
|
66
61
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
|
-
width="100%" alt="Nx - Smart
|
|
62
|
+
width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
|
|
68
63
|
|
package/generators.json
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"aliases": ["slice"]
|
|
38
38
|
},
|
|
39
39
|
"storybook-configuration": {
|
|
40
|
-
"factory": "./src/generators/storybook-configuration/configuration#
|
|
40
|
+
"factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGenerator",
|
|
41
41
|
"schema": "./src/generators/storybook-configuration/schema.json",
|
|
42
42
|
"description": "Set up storybook for a React app or library.",
|
|
43
43
|
"hidden": false
|
package/index.d.ts
CHANGED
|
@@ -19,4 +19,3 @@ export { componentTestGenerator } from './src/generators/component-test/componen
|
|
|
19
19
|
export { setupTailwindGenerator } from './src/generators/setup-tailwind/setup-tailwind';
|
|
20
20
|
export type { SupportedStyles } from './typings/style';
|
|
21
21
|
export * from './plugins/with-react';
|
|
22
|
-
export { NxReactWebpackPlugin } from './plugins/nx-react-webpack-plugin/nx-react-webpack-plugin';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.setupTailwindGenerator = exports.componentTestGenerator = exports.cypressComponentConfigGenerator = exports.remoteGenerator = exports.hostGenerator = exports.storybookConfigurationGenerator = exports.storiesGenerator = exports.reduxGenerator = exports.reactInitGenerator = exports.libraryGenerator = exports.componentStoryGenerator = exports.componentCypressGenerator = exports.hookGenerator = exports.componentGenerator = exports.applicationGenerator = exports.reactVersion = exports.reactDomVersion = exports.assertValidStyle = exports.cssInJsDependenciesBabel = exports.extendReactEslintJson = exports.extraEslintDependencies = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var lint_1 = require("./src/utils/lint");
|
|
6
6
|
Object.defineProperty(exports, "extraEslintDependencies", { enumerable: true, get: function () { return lint_1.extraEslintDependencies; } });
|
|
@@ -43,5 +43,3 @@ Object.defineProperty(exports, "componentTestGenerator", { enumerable: true, get
|
|
|
43
43
|
var setup_tailwind_1 = require("./src/generators/setup-tailwind/setup-tailwind");
|
|
44
44
|
Object.defineProperty(exports, "setupTailwindGenerator", { enumerable: true, get: function () { return setup_tailwind_1.setupTailwindGenerator; } });
|
|
45
45
|
tslib_1.__exportStar(require("./plugins/with-react"), exports);
|
|
46
|
-
var nx_react_webpack_plugin_1 = require("./plugins/nx-react-webpack-plugin/nx-react-webpack-plugin");
|
|
47
|
-
Object.defineProperty(exports, "NxReactWebpackPlugin", { enumerable: true, get: function () { return nx_react_webpack_plugin_1.NxReactWebpackPlugin; } });
|
package/migrations.json
CHANGED
|
@@ -47,18 +47,6 @@
|
|
|
47
47
|
"version": "16.7.0-beta.2",
|
|
48
48
|
"description": "Add @nx/react types to tsconfig types array",
|
|
49
49
|
"implementation": "./src/migrations/update-16-7-0-add-typings/update-16-7-0-add-typings"
|
|
50
|
-
},
|
|
51
|
-
"add-module-federation-env-var-to-target-defaults": {
|
|
52
|
-
"cli": "nx",
|
|
53
|
-
"version": "18.0.0-beta.0",
|
|
54
|
-
"description": "Add NX_MF_DEV_SERVER_STATIC_REMOTES to inputs for task hashing when '@nx/webpack:webpack' is used for Module Federation.",
|
|
55
|
-
"factory": "./src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults"
|
|
56
|
-
},
|
|
57
|
-
"fix-target-defaults-for-webpack": {
|
|
58
|
-
"cli": "nx",
|
|
59
|
-
"version": "18.1.1-beta.0",
|
|
60
|
-
"description": "Ensure targetDefaults inputs for task hashing when '@nx/webpack:webpack' is used are correct for Module Federation.",
|
|
61
|
-
"factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs"
|
|
62
50
|
}
|
|
63
51
|
},
|
|
64
52
|
"packageJsonUpdates": {
|
|
@@ -302,15 +290,6 @@
|
|
|
302
290
|
"alwaysAddToPackageJson": false
|
|
303
291
|
}
|
|
304
292
|
}
|
|
305
|
-
},
|
|
306
|
-
"17.3.0": {
|
|
307
|
-
"version": "17.3.0-beta.3",
|
|
308
|
-
"packages": {
|
|
309
|
-
"@types/node": {
|
|
310
|
-
"version": "18.16.9",
|
|
311
|
-
"alwaysAddToPackageJson": false
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
293
|
}
|
|
315
294
|
}
|
|
316
295
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v17.0.6",
|
|
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, 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": {
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"@svgr/webpack": "^8.0.1",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"file-loader": "^6.2.0",
|
|
38
|
-
"minimatch": "
|
|
38
|
+
"minimatch": "3.0.5",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/devkit": "
|
|
41
|
-
"@nx/js": "
|
|
42
|
-
"@nx/eslint": "
|
|
43
|
-
"@nx/web": "
|
|
44
|
-
"@nrwl/react": "
|
|
40
|
+
"@nx/devkit": "v17.0.6",
|
|
41
|
+
"@nx/js": "v17.0.6",
|
|
42
|
+
"@nx/eslint": "v17.0.6",
|
|
43
|
+
"@nx/web": "v17.0.6",
|
|
44
|
+
"@nrwl/react": "v17.0.6"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -25,17 +25,12 @@ const path_1 = require("path");
|
|
|
25
25
|
* @param options override options
|
|
26
26
|
*/
|
|
27
27
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
28
|
-
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
29
|
-
testingType: 'component',
|
|
30
|
-
});
|
|
31
|
-
if (global.NX_GRAPH_CREATION || global.NX_CYPRESS_INIT_GENERATOR_RUNNING) {
|
|
32
|
-
// this is only used by plugins, so we don't need the component testing
|
|
33
|
-
// options, cast to any to avoid type errors
|
|
34
|
-
return basePresetSettings;
|
|
35
|
-
}
|
|
36
28
|
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
37
29
|
? pathToConfig
|
|
38
30
|
: (0, path_1.dirname)(pathToConfig);
|
|
31
|
+
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
32
|
+
testingType: 'component',
|
|
33
|
+
});
|
|
39
34
|
if (options?.bundler === 'vite') {
|
|
40
35
|
return {
|
|
41
36
|
...basePresetSettings,
|
|
@@ -71,31 +66,25 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
71
66
|
const ctTargetName = options?.ctTargetName || 'component-test';
|
|
72
67
|
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
|
|
73
68
|
const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, ctExecutorContext);
|
|
81
|
-
buildTarget = ctExecutorOptions.devServerTarget;
|
|
82
|
-
}
|
|
69
|
+
const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
|
|
70
|
+
project: ctProjectName,
|
|
71
|
+
target: ctTargetName,
|
|
72
|
+
configuration: ctConfigurationName,
|
|
73
|
+
}, ctExecutorContext);
|
|
74
|
+
const buildTarget = ctExecutorOptions.devServerTarget;
|
|
83
75
|
if (!buildTarget) {
|
|
84
76
|
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
|
|
85
77
|
}
|
|
86
78
|
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
|
|
87
79
|
}
|
|
88
80
|
catch (e) {
|
|
89
|
-
if (e instanceof InvalidExecutorError) {
|
|
90
|
-
throw e;
|
|
91
|
-
}
|
|
92
81
|
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
|
|
93
82
|
Falling back to default webpack config.`);
|
|
94
83
|
devkit_1.logger.warn(e);
|
|
95
84
|
const { buildBaseWebpackConfig } = require('./webpack-fallback');
|
|
96
85
|
webpackConfig = buildBaseWebpackConfig({
|
|
97
86
|
tsConfigPath: findTsConfig(normalizedProjectRootPath),
|
|
98
|
-
compiler:
|
|
87
|
+
compiler: 'babel',
|
|
99
88
|
});
|
|
100
89
|
}
|
|
101
90
|
return {
|
|
@@ -134,6 +123,7 @@ function withSchemaDefaults(target, context) {
|
|
|
134
123
|
options.maxWorkers ??= 2;
|
|
135
124
|
options.fileReplacements ??= [];
|
|
136
125
|
options.buildLibsFromSource ??= true;
|
|
126
|
+
options.generateIndexHtml ??= true;
|
|
137
127
|
return options;
|
|
138
128
|
}
|
|
139
129
|
function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
@@ -148,40 +138,29 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
|
148
138
|
Has component config? ${!!ctProjectConfig}
|
|
149
139
|
`);
|
|
150
140
|
}
|
|
151
|
-
if (buildableProjectConfig.targets[parsed.target].executor !==
|
|
152
|
-
'@nx/webpack:webpack') {
|
|
153
|
-
throw new InvalidExecutorError(`The '${parsed.target}' target of the '${parsed.project}' project is not using the '@nx/webpack:webpack' executor. ` +
|
|
154
|
-
`Please make sure to use '@nx/webpack:webpack' executor in that target to use Cypress Component Testing.`);
|
|
155
|
-
}
|
|
156
141
|
const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
|
|
157
142
|
const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
|
|
158
|
-
const {
|
|
159
|
-
const {
|
|
160
|
-
const { withNx } = require('@nx/webpack/src/utils/with-nx');
|
|
161
|
-
const { withWeb } = require('@nx/webpack/src/utils/with-web');
|
|
143
|
+
const { resolveCustomWebpackConfig, } = require('@nx/webpack/src/utils/webpack/custom-webpack');
|
|
144
|
+
const { getWebpackConfig, } = require('@nx/webpack/src/executors/webpack/lib/get-webpack-config');
|
|
162
145
|
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, buildableProjectConfig.sourceRoot);
|
|
163
146
|
let customWebpack;
|
|
164
147
|
if (options.webpackConfig) {
|
|
165
|
-
customWebpack =
|
|
148
|
+
customWebpack = resolveCustomWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
|
|
166
149
|
? options.tsConfig
|
|
167
150
|
: (0, path_1.join)(context.root, options.tsConfig));
|
|
168
151
|
}
|
|
169
152
|
return async () => {
|
|
170
153
|
customWebpack = await customWebpack;
|
|
171
|
-
// TODO(
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
projectRoot: ctProjectConfig.root,
|
|
182
|
-
sourceRoot: ctProjectConfig.sourceRoot,
|
|
183
|
-
},
|
|
184
|
-
context,
|
|
154
|
+
// TODO(jack): Once webpackConfig is always set in @nx/webpack:webpack, we no longer need this default.
|
|
155
|
+
const defaultWebpack = getWebpackConfig(context, {
|
|
156
|
+
...options,
|
|
157
|
+
// cypress will generate its own index.html from component-index.html
|
|
158
|
+
generateIndexHtml: false,
|
|
159
|
+
// causes issues with buildable libraries with ENOENT: no such file or directory, scandir error
|
|
160
|
+
extractLicenses: false,
|
|
161
|
+
root: devkit_1.workspaceRoot,
|
|
162
|
+
projectRoot: ctProjectConfig.root,
|
|
163
|
+
sourceRoot: ctProjectConfig.sourceRoot,
|
|
185
164
|
});
|
|
186
165
|
if (customWebpack) {
|
|
187
166
|
return await customWebpack(defaultWebpack, {
|
|
@@ -213,10 +192,3 @@ function findTsConfig(projectRoot) {
|
|
|
213
192
|
}
|
|
214
193
|
}
|
|
215
194
|
}
|
|
216
|
-
class InvalidExecutorError extends Error {
|
|
217
|
-
constructor(message) {
|
|
218
|
-
super(message);
|
|
219
|
-
this.message = message;
|
|
220
|
-
this.name = 'InvalidExecutorError';
|
|
221
|
-
}
|
|
222
|
-
}
|
|
@@ -8,9 +8,6 @@ const webpack_1 = require("webpack");
|
|
|
8
8
|
const merge_plugins_1 = require("./merge-plugins");
|
|
9
9
|
const with_react_1 = require("../with-react");
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
|
-
// Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
|
|
12
|
-
// TODO(v19): BREAKING: Only env vars prefixed with NX_PUBLIC should be bundled. This is a breaking change so we won't do it in v18.
|
|
13
|
-
const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
|
|
14
11
|
// This is shamelessly taken from CRA and modified for NX use
|
|
15
12
|
// https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
|
|
16
13
|
function getClientEnvironment(mode) {
|
|
@@ -19,8 +16,7 @@ function getClientEnvironment(mode) {
|
|
|
19
16
|
const NX_PREFIX = /^NX_/i;
|
|
20
17
|
const STORYBOOK_PREFIX = /^STORYBOOK_/i;
|
|
21
18
|
const raw = Object.keys(process.env)
|
|
22
|
-
.filter((key) =>
|
|
23
|
-
(NX_PREFIX.test(key) || STORYBOOK_PREFIX.test(key)))
|
|
19
|
+
.filter((key) => NX_PREFIX.test(key) || STORYBOOK_PREFIX.test(key))
|
|
24
20
|
.reduce((env, key) => {
|
|
25
21
|
env[key] = process.env[key];
|
|
26
22
|
return env;
|
|
@@ -144,7 +140,7 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
|
|
|
144
140
|
};
|
|
145
141
|
// ESM build for modern browsers.
|
|
146
142
|
let baseWebpackConfig = {};
|
|
147
|
-
const configure = (0, config_1.composePluginsSync)(withNx({
|
|
143
|
+
const configure = (0, config_1.composePluginsSync)(withNx({ skipTypeChecking: true }), withWeb(), (0, with_react_1.withReact)());
|
|
148
144
|
const finalConfig = configure(baseWebpackConfig, {
|
|
149
145
|
options: builderOptions,
|
|
150
146
|
context: { root: devkit_1.workspaceRoot }, // The context is not used here.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ResolvePluginInstance, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
2
|
-
export declare const mergeRules: (...args: RuleSetRule[]) => (
|
|
2
|
+
export declare const mergeRules: (...args: RuleSetRule[]) => (RuleSetRule | WebpackPluginInstance)[];
|
|
3
3
|
export declare const mergePlugins: (...args: (WebpackPluginInstance | ResolvePluginInstance)[]) => (WebpackPluginInstance | ResolvePluginInstance)[];
|
package/plugins/webpack.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/** @deprecated use `import { withReact } from '@nx/react'` */
|
|
2
|
+
declare const getWebpackConfig: (config: import("webpack").Configuration, context: import("../../../build/packages/webpack").NxWebpackExecutionContext) => import("webpack").Configuration;
|
|
3
|
+
export { getWebpackConfig };
|
package/plugins/webpack.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.getWebpackConfig = void 0;
|
|
4
4
|
const with_react_1 = require("./with-react");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// Support existing default exports as well as new named export.
|
|
6
|
+
const legacyExport = (0, with_react_1.withReact)();
|
|
7
|
+
legacyExport.withReact = with_react_1.withReact;
|
|
8
|
+
/** @deprecated use `import { withReact } from '@nx/react'` */
|
|
9
|
+
// This is here for backward compatibility if anyone imports {getWebpackConfig} directly.
|
|
10
|
+
// TODO(jack): Remove in Nx 16
|
|
11
|
+
const getWebpackConfig = (0, with_react_1.withReact)();
|
|
12
|
+
exports.getWebpackConfig = getWebpackConfig;
|
|
13
|
+
legacyExport.getWebpackConfig = getWebpackConfig;
|
|
14
|
+
module.exports = legacyExport;
|
package/plugins/with-react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { WithWebOptions } from '@nx/webpack';
|
|
3
|
+
import type { NxWebpackExecutionContext } from '@nx/webpack';
|
|
4
|
+
interface WithReactOptions extends WithWebOptions {
|
|
4
5
|
svgr?: false;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
@@ -8,3 +9,4 @@ export interface WithReactOptions extends WithWebOptions {
|
|
|
8
9
|
* @returns {NxWebpackPlugin}
|
|
9
10
|
*/
|
|
10
11
|
export declare function withReact(pluginOptions?: WithReactOptions): (config: Configuration, context: NxWebpackExecutionContext) => Configuration;
|
|
12
|
+
export {};
|
package/plugins/with-react.js
CHANGED
|
@@ -1,8 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withReact = void 0;
|
|
4
|
-
const apply_react_config_1 = require("./nx-react-webpack-plugin/lib/apply-react-config");
|
|
5
4
|
const processed = new Set();
|
|
5
|
+
function addHotReload(config) {
|
|
6
|
+
if (config.mode === 'development' && config['devServer']?.hot) {
|
|
7
|
+
// add `react-refresh/babel` to babel loader plugin
|
|
8
|
+
const babelLoader = config.module.rules.find((rule) => rule &&
|
|
9
|
+
typeof rule !== 'string' &&
|
|
10
|
+
rule.loader?.toString().includes('babel-loader'));
|
|
11
|
+
if (babelLoader && typeof babelLoader !== 'string') {
|
|
12
|
+
babelLoader.options['plugins'] = [
|
|
13
|
+
...(babelLoader.options['plugins'] || []),
|
|
14
|
+
[
|
|
15
|
+
require.resolve('react-refresh/babel'),
|
|
16
|
+
{
|
|
17
|
+
skipEnvCheck: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
23
|
+
config.plugins.push(new ReactRefreshPlugin());
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// We remove potentially conflicting rules that target SVGs because we use @svgr/webpack loader
|
|
27
|
+
// See https://github.com/nrwl/nx/issues/14383
|
|
28
|
+
function removeSvgLoaderIfPresent(config) {
|
|
29
|
+
const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test.toString().includes('svg'));
|
|
30
|
+
if (svgLoaderIdx === -1)
|
|
31
|
+
return;
|
|
32
|
+
config.module.rules.splice(svgLoaderIdx, 1);
|
|
33
|
+
}
|
|
6
34
|
/**
|
|
7
35
|
* @param {WithReactOptions} pluginOptions
|
|
8
36
|
* @returns {NxWebpackPlugin}
|
|
@@ -14,7 +42,35 @@ function withReact(pluginOptions = {}) {
|
|
|
14
42
|
return config;
|
|
15
43
|
// Apply web config for CSS, JSX, index.html handling, etc.
|
|
16
44
|
config = withWeb(pluginOptions)(config, context);
|
|
17
|
-
(
|
|
45
|
+
addHotReload(config);
|
|
46
|
+
if (pluginOptions?.svgr !== false) {
|
|
47
|
+
removeSvgLoaderIfPresent(config);
|
|
48
|
+
config.module.rules.push({
|
|
49
|
+
test: /\.svg$/,
|
|
50
|
+
issuer: /\.(js|ts|md)x?$/,
|
|
51
|
+
use: [
|
|
52
|
+
{
|
|
53
|
+
loader: require.resolve('@svgr/webpack'),
|
|
54
|
+
options: {
|
|
55
|
+
svgo: false,
|
|
56
|
+
titleProp: true,
|
|
57
|
+
ref: true,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
loader: require.resolve('file-loader'),
|
|
62
|
+
options: {
|
|
63
|
+
name: '[name].[hash].[ext]',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// enable webpack node api
|
|
70
|
+
config.node = {
|
|
71
|
+
__dirname: true,
|
|
72
|
+
__filename: true,
|
|
73
|
+
};
|
|
18
74
|
processed.add(config);
|
|
19
75
|
return config;
|
|
20
76
|
};
|
|
@@ -5,20 +5,7 @@ type ModuleFederationDevServerOptions = WebDevServerOptions & {
|
|
|
5
5
|
skipRemotes?: string[];
|
|
6
6
|
static?: boolean;
|
|
7
7
|
isInitialHost?: boolean;
|
|
8
|
-
parallel?: number;
|
|
9
|
-
staticRemotesPort?: number;
|
|
10
|
-
pathToManifestFile?: string;
|
|
11
8
|
};
|
|
12
|
-
type StaticRemoteConfig = {
|
|
13
|
-
basePath: string;
|
|
14
|
-
outputPath: string;
|
|
15
|
-
urlSegment: string;
|
|
16
|
-
};
|
|
17
|
-
type StaticRemotesConfig = {
|
|
18
|
-
remotes: string[];
|
|
19
|
-
config: Record<string, StaticRemoteConfig> | undefined;
|
|
20
|
-
};
|
|
21
|
-
export declare function parseStaticRemotesConfig(staticRemotes: string[] | undefined, context: ExecutorContext): StaticRemotesConfig;
|
|
22
9
|
export default function moduleFederationDevServer(options: ModuleFederationDevServerOptions, context: ExecutorContext): AsyncIterableIterator<{
|
|
23
10
|
success: boolean;
|
|
24
11
|
baseUrl?: string;
|