@nx/react 17.0.2 → 17.0.4
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 +9 -4
- package/generators.json +1 -1
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/mf/dynamic-federation.d.ts +4 -0
- package/mf/dynamic-federation.js +75 -0
- package/mf/index.d.ts +1 -0
- package/mf/index.js +7 -0
- package/migrations.json +21 -0
- package/package.json +7 -7
- package/plugins/component-testing/index.js +52 -24
- package/plugins/component-testing/webpack-fallback.js +1 -1
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.d.ts +4 -0
- package/plugins/nx-react-webpack-plugin/lib/apply-react-config.js +86 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.d.ts +8 -0
- package/plugins/nx-react-webpack-plugin/nx-react-webpack-plugin.js +13 -0
- package/plugins/storybook/index.js +6 -2
- package/plugins/storybook/merge-plugins.d.ts +1 -1
- package/plugins/webpack.d.ts +1 -3
- package/plugins/webpack.js +3 -11
- package/plugins/with-react.d.ts +2 -4
- package/plugins/with-react.js +2 -58
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.d.ts +12 -0
- package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +149 -51
- package/src/executors/module-federation-dev-server/schema.json +9 -1
- package/src/generators/application/application.js +41 -18
- package/src/generators/application/files/base-vite/index.html__tmpl__ +1 -1
- package/src/generators/application/files/base-webpack/src/index.html +0 -2
- package/src/generators/application/files/base-webpack/webpack.config.js__tmpl__ +46 -5
- package/src/generators/application/files/nx-welcome/src/app/nx-welcome.tsx +54 -13
- package/src/generators/application/files/style-tailwind/src/app/__fileName__.tsx__tmpl__ +33 -0
- package/src/generators/application/files/style-tailwind/src/styles.css +1 -0
- package/src/generators/application/lib/add-e2e.js +27 -7
- 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 +12 -15
- package/src/generators/application/lib/add-routing.d.ts +1 -1
- package/src/generators/application/lib/add-routing.js +4 -8
- package/src/generators/application/lib/create-application-files.js +30 -1
- package/src/generators/application/lib/install-common-dependencies.js +15 -1
- package/src/generators/application/lib/normalize-options.js +35 -1
- package/src/generators/application/lib/set-defaults.js +1 -0
- package/src/generators/application/lib/update-jest-config.js +8 -8
- package/src/generators/application/schema.d.ts +5 -0
- package/src/generators/application/schema.json +7 -3
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +39 -22
- package/src/generators/component/lib/normalize-options.js +4 -2
- package/src/generators/component/schema.d.ts +6 -4
- 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 +2 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +18 -7
- package/src/generators/cypress-component-configuration/lib/add-files.js +1 -6
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- 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 +11 -10
- 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/common/src/main.js__tmpl__ +10 -0
- package/src/generators/host/files/common/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +41 -0
- package/src/generators/host/files/common-ts/src/main.ts__tmpl__ +10 -0
- package/src/generators/host/files/module-federation/module-federation.config.js__tmpl__ +17 -2
- package/src/generators/host/files/module-federation-ssr/module-federation.server.config.js__tmpl__ +5 -2
- package/src/generators/host/files/module-federation-ssr-ts/module-federation.server.config.ts__tmpl__ +5 -2
- package/src/generators/host/files/module-federation-ts/module-federation.config.ts__tmpl__ +17 -2
- package/src/generators/host/files/module-federation-ts/webpack.config.prod.ts__tmpl__ +2 -1
- package/src/generators/host/files/module-federation-ts/webpack.config.ts__tmpl__ +2 -2
- package/src/generators/host/host.js +15 -1
- package/src/generators/host/lib/add-module-federation-files.d.ts +2 -1
- package/src/generators/host/lib/add-module-federation-files.js +24 -11
- package/src/generators/host/lib/setup-ssr-for-host.js +1 -0
- package/src/generators/host/lib/update-module-federation-e2e-project.js +7 -5
- package/src/generators/host/schema.d.ts +5 -2
- package/src/generators/host/schema.json +16 -6
- package/src/generators/init/init.d.ts +1 -1
- package/src/generators/init/init.js +10 -49
- package/src/generators/init/schema.d.ts +1 -6
- package/src/generators/init/schema.json +5 -22
- package/src/generators/library/lib/add-linting.js +2 -2
- package/src/generators/library/lib/add-rollup-build-target.d.ts +2 -1
- package/src/generators/library/lib/add-rollup-build-target.js +16 -8
- package/src/generators/library/lib/install-common-dependencies.js +13 -5
- package/src/generators/library/lib/normalize-options.js +34 -5
- package/src/generators/library/lib/update-app-routes.js +1 -1
- package/src/generators/library/library.js +17 -6
- package/src/generators/library/schema.d.ts +1 -0
- 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__ +4 -1
- 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-ssr-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/files/module-federation-ts/module-federation.config.ts__tmpl__ +4 -1
- package/src/generators/remote/files/module-federation-ts/tsconfig.lint.json__tmpl__ +19 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.d.ts +2 -0
- package/src/generators/remote/lib/add-remote-to-dynamic-host.js +11 -0
- package/src/generators/remote/lib/setup-ssr-for-remote.js +5 -1
- package/src/generators/remote/lib/setup-tspath-for-remote.js +2 -1
- package/src/generators/remote/lib/update-host-with-remote.js +10 -1
- package/src/generators/remote/remote.js +22 -2
- package/src/generators/remote/schema.d.ts +3 -2
- package/src/generators/remote/schema.json +17 -6
- package/src/generators/setup-ssr/schema.json +1 -1
- package/src/generators/setup-ssr/setup-ssr.js +23 -7
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +3 -0
- package/src/generators/setup-tailwind/schema.json +1 -1
- package/src/generators/stories/schema.json +1 -1
- package/src/generators/stories/stories.js +17 -5
- package/src/generators/storybook-configuration/configuration.d.ts +2 -0
- package/src/generators/storybook-configuration/configuration.js +37 -15
- package/src/generators/storybook-configuration/schema.d.ts +2 -1
- package/src/generators/storybook-configuration/schema.json +7 -7
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-18-0-0/add-mf-env-var-to-target-defaults.js +26 -0
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
- package/src/module-federation/ast-utils.js +1 -1
- package/src/module-federation/utils.js +8 -1
- package/src/module-federation/with-module-federation-ssr.js +3 -0
- package/src/module-federation/with-module-federation.d.ts +3 -3
- package/src/module-federation/with-module-federation.js +14 -4
- package/src/rules/update-module-federation-project.d.ts +2 -0
- package/src/rules/update-module-federation-project.js +12 -3
- package/src/utils/add-mf-env-to-inputs.d.ts +2 -0
- package/src/utils/add-mf-env-to-inputs.js +27 -0
- package/src/utils/assertion.js +1 -0
- package/src/utils/ct-utils.d.ts +6 -1
- package/src/utils/ct-utils.js +39 -9
- package/src/utils/get-in-source-vitest-tests-template.js +1 -1
- package/src/utils/has-vite-plugin.d.ts +2 -0
- package/src/utils/has-vite-plugin.js +11 -0
- package/src/utils/has-webpack-plugin.d.ts +2 -0
- package/src/utils/has-webpack-plugin.js +11 -0
- package/src/utils/maybe-js.d.ts +3 -0
- package/src/utils/versions.d.ts +3 -3
- package/src/utils/versions.js +3 -3
- package/typings/style.d.ts +1 -0
- package/src/generators/application/files/base-webpack/src/environments/environment.prod.ts__tmpl__ +0 -3
- package/src/generators/application/files/base-webpack/src/environments/environment.ts__tmpl__ +0 -6
- package/src/generators/host/files/module-federation/src/main.ts__tmpl__ +0 -1
- package/src/generators/host/files/module-federation-ts/src/main.ts__tmpl__ +0 -1
- package/src/generators/library/lib/maybe-js.d.ts +0 -2
- /package/src/generators/host/files/common/src/app/{__fileName__.tsx__tmpl__ → __fileName__.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation/src/main.ts__tmpl__ → common/src/main.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation/src/remote-entry.ts__tmpl__ → common/src/remote-entry.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/main.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/{module-federation-ts → common-ts}/src/remote-entry.ts__tmpl__ +0 -0
- /package/src/{generators/library/lib → utils}/maybe-js.js +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<p style="text-align: center;"
|
|
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>
|
|
2
7
|
|
|
3
8
|
<div style="text-align: center;">
|
|
4
9
|
|
|
@@ -15,9 +20,9 @@
|
|
|
15
20
|
|
|
16
21
|
<hr>
|
|
17
22
|
|
|
18
|
-
# Nx: Smart
|
|
23
|
+
# Nx: Smart Monorepos · Fast CI
|
|
19
24
|
|
|
20
|
-
Nx is a
|
|
25
|
+
Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
|
|
21
26
|
|
|
22
27
|
This package is a [React plugin for Nx](https://nx.dev/packages/react).
|
|
23
28
|
|
|
@@ -59,5 +64,5 @@ npx nx@latest init
|
|
|
59
64
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
60
65
|
|
|
61
66
|
<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"
|
|
62
|
-
width="100%" alt="Nx - Smart
|
|
67
|
+
width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
|
|
63
68
|
|
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#storybookConfigurationGeneratorInternal",
|
|
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,3 +19,4 @@ 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.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;
|
|
3
|
+
exports.NxReactWebpackPlugin = 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,3 +43,5 @@ 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; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ResolveRemoteUrlFunction = (remoteName: string) => string | Promise<string>;
|
|
2
|
+
export declare function setRemoteUrlResolver(_resolveRemoteUrl: ResolveRemoteUrlFunction): void;
|
|
3
|
+
export declare function setRemoteDefinitions(definitions: Record<string, string>): void;
|
|
4
|
+
export declare function loadRemoteModule(remoteName: string, moduleName: string): Promise<any>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadRemoteModule = exports.setRemoteDefinitions = exports.setRemoteUrlResolver = void 0;
|
|
4
|
+
let remoteUrlDefinitions;
|
|
5
|
+
let resolveRemoteUrl;
|
|
6
|
+
const remoteModuleMap = new Map();
|
|
7
|
+
const remoteContainerMap = new Map();
|
|
8
|
+
let initialSharingScopeCreated = false;
|
|
9
|
+
function setRemoteUrlResolver(_resolveRemoteUrl) {
|
|
10
|
+
resolveRemoteUrl = _resolveRemoteUrl;
|
|
11
|
+
}
|
|
12
|
+
exports.setRemoteUrlResolver = setRemoteUrlResolver;
|
|
13
|
+
function setRemoteDefinitions(definitions) {
|
|
14
|
+
remoteUrlDefinitions = definitions;
|
|
15
|
+
}
|
|
16
|
+
exports.setRemoteDefinitions = setRemoteDefinitions;
|
|
17
|
+
async function loadRemoteModule(remoteName, moduleName) {
|
|
18
|
+
const remoteModuleKey = `${remoteName}:${moduleName}`;
|
|
19
|
+
if (remoteModuleMap.has(remoteModuleKey)) {
|
|
20
|
+
return remoteModuleMap.get(remoteModuleKey);
|
|
21
|
+
}
|
|
22
|
+
const container = remoteContainerMap.has(remoteName)
|
|
23
|
+
? remoteContainerMap.get(remoteName)
|
|
24
|
+
: await loadRemoteContainer(remoteName);
|
|
25
|
+
const factory = await container.get(moduleName);
|
|
26
|
+
const Module = factory();
|
|
27
|
+
remoteModuleMap.set(remoteModuleKey, Module);
|
|
28
|
+
return Module;
|
|
29
|
+
}
|
|
30
|
+
exports.loadRemoteModule = loadRemoteModule;
|
|
31
|
+
const fetchRemoteModule = (url, remoteName) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const script = document.createElement('script');
|
|
34
|
+
script.src = url;
|
|
35
|
+
script.type = 'text/javascript';
|
|
36
|
+
script.async = true;
|
|
37
|
+
script.onload = () => {
|
|
38
|
+
const proxy = {
|
|
39
|
+
get: (request) => window[remoteName].get(request),
|
|
40
|
+
init: (arg) => {
|
|
41
|
+
try {
|
|
42
|
+
window[remoteName].init(arg);
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
console.error(`Failed to initialize remote ${remoteName}`, e);
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
resolve(proxy);
|
|
51
|
+
};
|
|
52
|
+
script.onerror = () => reject(new Error(`Remote ${remoteName} not found`));
|
|
53
|
+
document.head.appendChild(script);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
async function loadRemoteContainer(remoteName) {
|
|
57
|
+
if (!resolveRemoteUrl && !remoteUrlDefinitions) {
|
|
58
|
+
throw new Error('Call setRemoteDefinitions or setRemoteUrlResolver to allow Dynamic Federation to find the remote apps correctly.');
|
|
59
|
+
}
|
|
60
|
+
if (!initialSharingScopeCreated) {
|
|
61
|
+
initialSharingScopeCreated = true;
|
|
62
|
+
await __webpack_init_sharing__('default');
|
|
63
|
+
}
|
|
64
|
+
const remoteUrl = remoteUrlDefinitions
|
|
65
|
+
? remoteUrlDefinitions[remoteName]
|
|
66
|
+
: await resolveRemoteUrl(remoteName);
|
|
67
|
+
let containerUrl = remoteUrl;
|
|
68
|
+
if (!remoteUrl.endsWith('.mjs') && !remoteUrl.endsWith('.js')) {
|
|
69
|
+
containerUrl = `${remoteUrl}${remoteUrl.endsWith('/') ? '' : '/'}remoteEntry.js`;
|
|
70
|
+
}
|
|
71
|
+
const container = await fetchRemoteModule(containerUrl, remoteName);
|
|
72
|
+
await container.init(__webpack_share_scopes__.default);
|
|
73
|
+
remoteContainerMap.set(remoteName, container);
|
|
74
|
+
return container;
|
|
75
|
+
}
|
package/mf/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadRemoteModule, setRemoteDefinitions, setRemoteUrlResolver, } from './dynamic-federation';
|
package/mf/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setRemoteUrlResolver = exports.setRemoteDefinitions = exports.loadRemoteModule = void 0;
|
|
4
|
+
var dynamic_federation_1 = require("./dynamic-federation");
|
|
5
|
+
Object.defineProperty(exports, "loadRemoteModule", { enumerable: true, get: function () { return dynamic_federation_1.loadRemoteModule; } });
|
|
6
|
+
Object.defineProperty(exports, "setRemoteDefinitions", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteDefinitions; } });
|
|
7
|
+
Object.defineProperty(exports, "setRemoteUrlResolver", { enumerable: true, get: function () { return dynamic_federation_1.setRemoteUrlResolver; } });
|
package/migrations.json
CHANGED
|
@@ -47,6 +47,18 @@
|
|
|
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"
|
|
50
62
|
}
|
|
51
63
|
},
|
|
52
64
|
"packageJsonUpdates": {
|
|
@@ -290,6 +302,15 @@
|
|
|
290
302
|
"alwaysAddToPackageJson": false
|
|
291
303
|
}
|
|
292
304
|
}
|
|
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
|
+
}
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.4",
|
|
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": "9.0.3",
|
|
39
39
|
"tslib": "^2.3.0",
|
|
40
|
-
"@nx/devkit": "17.0.
|
|
41
|
-
"@nx/js": "17.0.
|
|
42
|
-
"@nx/eslint": "17.0.
|
|
43
|
-
"@nx/web": "17.0.
|
|
44
|
-
"@nrwl/react": "17.0.
|
|
40
|
+
"@nx/devkit": "17.0.4",
|
|
41
|
+
"@nx/js": "17.0.4",
|
|
42
|
+
"@nx/eslint": "17.0.4",
|
|
43
|
+
"@nx/web": "17.0.4",
|
|
44
|
+
"@nrwl/react": "17.0.4"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -25,12 +25,17 @@ const path_1 = require("path");
|
|
|
25
25
|
* @param options override options
|
|
26
26
|
*/
|
|
27
27
|
function nxComponentTestingPreset(pathToConfig, options) {
|
|
28
|
-
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
29
|
-
? pathToConfig
|
|
30
|
-
: (0, path_1.dirname)(pathToConfig);
|
|
31
28
|
const basePresetSettings = (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, {
|
|
32
29
|
testingType: 'component',
|
|
33
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
|
+
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
37
|
+
? pathToConfig
|
|
38
|
+
: (0, path_1.dirname)(pathToConfig);
|
|
34
39
|
if (options?.bundler === 'vite') {
|
|
35
40
|
return {
|
|
36
41
|
...basePresetSettings,
|
|
@@ -66,25 +71,31 @@ function nxComponentTestingPreset(pathToConfig, options) {
|
|
|
66
71
|
const ctTargetName = options?.ctTargetName || 'component-test';
|
|
67
72
|
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
|
|
68
73
|
const ctExecutorContext = (0, ct_helpers_1.createExecutorContext)(graph, ctTargets, ctProjectName, ctTargetName, ctConfigurationName);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
let buildTarget = options?.buildTarget;
|
|
75
|
+
if (!buildTarget) {
|
|
76
|
+
const ctExecutorOptions = (0, devkit_1.readTargetOptions)({
|
|
77
|
+
project: ctProjectName,
|
|
78
|
+
target: ctTargetName,
|
|
79
|
+
configuration: ctConfigurationName,
|
|
80
|
+
}, ctExecutorContext);
|
|
81
|
+
buildTarget = ctExecutorOptions.devServerTarget;
|
|
82
|
+
}
|
|
75
83
|
if (!buildTarget) {
|
|
76
84
|
throw new Error(`Unable to find the 'devServerTarget' executor option in the '${ctTargetName}' target of the '${ctProjectName}' project`);
|
|
77
85
|
}
|
|
78
86
|
webpackConfig = buildTargetWebpack(ctExecutorContext, buildTarget, ctProjectName);
|
|
79
87
|
}
|
|
80
88
|
catch (e) {
|
|
89
|
+
if (e instanceof InvalidExecutorError) {
|
|
90
|
+
throw e;
|
|
91
|
+
}
|
|
81
92
|
devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to build a webpack config with the project graph.
|
|
82
93
|
Falling back to default webpack config.`);
|
|
83
94
|
devkit_1.logger.warn(e);
|
|
84
95
|
const { buildBaseWebpackConfig } = require('./webpack-fallback');
|
|
85
96
|
webpackConfig = buildBaseWebpackConfig({
|
|
86
97
|
tsConfigPath: findTsConfig(normalizedProjectRootPath),
|
|
87
|
-
compiler: 'babel',
|
|
98
|
+
compiler: options?.compiler || 'babel',
|
|
88
99
|
});
|
|
89
100
|
}
|
|
90
101
|
return {
|
|
@@ -123,7 +134,6 @@ function withSchemaDefaults(target, context) {
|
|
|
123
134
|
options.maxWorkers ??= 2;
|
|
124
135
|
options.fileReplacements ??= [];
|
|
125
136
|
options.buildLibsFromSource ??= true;
|
|
126
|
-
options.generateIndexHtml ??= true;
|
|
127
137
|
return options;
|
|
128
138
|
}
|
|
129
139
|
function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
@@ -138,29 +148,40 @@ function buildTargetWebpack(ctx, buildTarget, componentTestingProjectName) {
|
|
|
138
148
|
Has component config? ${!!ctProjectConfig}
|
|
139
149
|
`);
|
|
140
150
|
}
|
|
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
|
+
}
|
|
141
156
|
const context = (0, ct_helpers_1.createExecutorContext)(graph, buildableProjectConfig.targets, parsed.project, parsed.target, parsed.target);
|
|
142
157
|
const { normalizeOptions, } = require('@nx/webpack/src/executors/webpack/lib/normalize-options');
|
|
143
|
-
const {
|
|
144
|
-
const {
|
|
158
|
+
const { resolveUserDefinedWebpackConfig, } = require('@nx/webpack/src/utils/webpack/resolve-user-defined-webpack-config');
|
|
159
|
+
const { composePluginsSync } = require('@nx/webpack/src/utils/config');
|
|
160
|
+
const { withNx } = require('@nx/webpack/src/utils/with-nx');
|
|
161
|
+
const { withWeb } = require('@nx/webpack/src/utils/with-web');
|
|
145
162
|
const options = normalizeOptions(withSchemaDefaults(parsed, context), devkit_1.workspaceRoot, buildableProjectConfig.root, buildableProjectConfig.sourceRoot);
|
|
146
163
|
let customWebpack;
|
|
147
164
|
if (options.webpackConfig) {
|
|
148
|
-
customWebpack =
|
|
165
|
+
customWebpack = resolveUserDefinedWebpackConfig(options.webpackConfig, options.tsConfig.startsWith(context.root)
|
|
149
166
|
? options.tsConfig
|
|
150
167
|
: (0, path_1.join)(context.root, options.tsConfig));
|
|
151
168
|
}
|
|
152
169
|
return async () => {
|
|
153
170
|
customWebpack = await customWebpack;
|
|
154
|
-
// TODO(
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
171
|
+
// TODO(v19): Once webpackConfig is always set in @nx/webpack:webpack and isolatedConfig is removed, we no longer need this default.
|
|
172
|
+
const configure = composePluginsSync(withNx(), withWeb());
|
|
173
|
+
const defaultWebpack = configure({}, {
|
|
174
|
+
options: {
|
|
175
|
+
...options,
|
|
176
|
+
// cypress will generate its own index.html from component-index.html
|
|
177
|
+
generateIndexHtml: false,
|
|
178
|
+
// causes issues with buildable libraries with ENOENT: no such file or directory, scandir error
|
|
179
|
+
extractLicenses: false,
|
|
180
|
+
root: devkit_1.workspaceRoot,
|
|
181
|
+
projectRoot: ctProjectConfig.root,
|
|
182
|
+
sourceRoot: ctProjectConfig.sourceRoot,
|
|
183
|
+
},
|
|
184
|
+
context,
|
|
164
185
|
});
|
|
165
186
|
if (customWebpack) {
|
|
166
187
|
return await customWebpack(defaultWebpack, {
|
|
@@ -192,3 +213,10 @@ function findTsConfig(projectRoot) {
|
|
|
192
213
|
}
|
|
193
214
|
}
|
|
194
215
|
}
|
|
216
|
+
class InvalidExecutorError extends Error {
|
|
217
|
+
constructor(message) {
|
|
218
|
+
super(message);
|
|
219
|
+
this.message = message;
|
|
220
|
+
this.name = 'InvalidExecutorError';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyReactConfig = void 0;
|
|
4
|
+
function applyReactConfig(options, config = {}) {
|
|
5
|
+
if (!process.env['NX_TASK_TARGET_PROJECT'])
|
|
6
|
+
return;
|
|
7
|
+
addHotReload(config);
|
|
8
|
+
if (options.svgr !== false) {
|
|
9
|
+
removeSvgLoaderIfPresent(config);
|
|
10
|
+
// TODO(v20): Remove file-loader and use `?react` querystring to differentiate between asset and SVGR.
|
|
11
|
+
// It should be:
|
|
12
|
+
// use: [{
|
|
13
|
+
// test: /\.svg$/i,
|
|
14
|
+
// type: 'asset',
|
|
15
|
+
// resourceQuery: /react/, // *.svg?react
|
|
16
|
+
// },
|
|
17
|
+
// {
|
|
18
|
+
// test: /\.svg$/i,
|
|
19
|
+
// issuer: /\.[jt]sx?$/,
|
|
20
|
+
// resourceQuery: { not: [/react/] }, // exclude react component if *.svg?react
|
|
21
|
+
// use: ['@svgr/webpack'],
|
|
22
|
+
// }],
|
|
23
|
+
// See:
|
|
24
|
+
// - SVGR: https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project
|
|
25
|
+
// - Vite: https://www.npmjs.com/package/vite-plugin-svgr
|
|
26
|
+
// - Rsbuild: https://github.com/web-infra-dev/rsbuild/pull/1783
|
|
27
|
+
// Note: We also need a migration for any projects that are using SVGR to convert
|
|
28
|
+
// `import { ReactComponent as X } from './x.svg` to
|
|
29
|
+
// `import X from './x.svg?react';
|
|
30
|
+
config.module.rules.push({
|
|
31
|
+
test: /\.svg$/,
|
|
32
|
+
issuer: /\.(js|ts|md)x?$/,
|
|
33
|
+
use: [
|
|
34
|
+
{
|
|
35
|
+
loader: require.resolve('@svgr/webpack'),
|
|
36
|
+
options: {
|
|
37
|
+
svgo: false,
|
|
38
|
+
titleProp: true,
|
|
39
|
+
ref: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
loader: require.resolve('file-loader'),
|
|
44
|
+
options: {
|
|
45
|
+
name: '[name].[hash].[ext]',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// enable webpack node api
|
|
52
|
+
config.node = {
|
|
53
|
+
__dirname: true,
|
|
54
|
+
__filename: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.applyReactConfig = applyReactConfig;
|
|
58
|
+
function addHotReload(config) {
|
|
59
|
+
if (config.mode === 'development' && config['devServer']?.hot) {
|
|
60
|
+
// add `react-refresh/babel` to babel loader plugin
|
|
61
|
+
const babelLoader = config.module.rules.find((rule) => rule &&
|
|
62
|
+
typeof rule !== 'string' &&
|
|
63
|
+
rule.loader?.toString().includes('babel-loader'));
|
|
64
|
+
if (babelLoader && typeof babelLoader !== 'string') {
|
|
65
|
+
babelLoader.options['plugins'] = [
|
|
66
|
+
...(babelLoader.options['plugins'] || []),
|
|
67
|
+
[
|
|
68
|
+
require.resolve('react-refresh/babel'),
|
|
69
|
+
{
|
|
70
|
+
skipEnvCheck: true,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
|
76
|
+
config.plugins.push(new ReactRefreshPlugin());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// We remove potentially conflicting rules that target SVGs because we use @svgr/webpack loader
|
|
80
|
+
// See https://github.com/nrwl/nx/issues/14383
|
|
81
|
+
function removeSvgLoaderIfPresent(config) {
|
|
82
|
+
const svgLoaderIdx = config.module.rules.findIndex((rule) => typeof rule === 'object' && rule.test.toString().includes('svg'));
|
|
83
|
+
if (svgLoaderIdx === -1)
|
|
84
|
+
return;
|
|
85
|
+
config.module.rules.splice(svgLoaderIdx, 1);
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NxReactWebpackPlugin = void 0;
|
|
4
|
+
const apply_react_config_1 = require("./lib/apply-react-config");
|
|
5
|
+
class NxReactWebpackPlugin {
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
apply(compiler) {
|
|
10
|
+
(0, apply_react_config_1.applyReactConfig)(this.options, compiler.options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NxReactWebpackPlugin = NxReactWebpackPlugin;
|
|
@@ -8,6 +8,9 @@ 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'];
|
|
11
14
|
// This is shamelessly taken from CRA and modified for NX use
|
|
12
15
|
// https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
|
|
13
16
|
function getClientEnvironment(mode) {
|
|
@@ -16,7 +19,8 @@ function getClientEnvironment(mode) {
|
|
|
16
19
|
const NX_PREFIX = /^NX_/i;
|
|
17
20
|
const STORYBOOK_PREFIX = /^STORYBOOK_/i;
|
|
18
21
|
const raw = Object.keys(process.env)
|
|
19
|
-
.filter((key) =>
|
|
22
|
+
.filter((key) => !excludedKeys.includes(key) &&
|
|
23
|
+
(NX_PREFIX.test(key) || STORYBOOK_PREFIX.test(key)))
|
|
20
24
|
.reduce((env, key) => {
|
|
21
25
|
env[key] = process.env[key];
|
|
22
26
|
return env;
|
|
@@ -140,7 +144,7 @@ const webpack = async (storybookWebpackConfig = {}, options) => {
|
|
|
140
144
|
};
|
|
141
145
|
// ESM build for modern browsers.
|
|
142
146
|
let baseWebpackConfig = {};
|
|
143
|
-
const configure = (0, config_1.composePluginsSync)(withNx({ skipTypeChecking: true }),
|
|
147
|
+
const configure = (0, config_1.composePluginsSync)(withNx({ target: 'web', skipTypeChecking: true }), (0, with_react_1.withReact)());
|
|
144
148
|
const finalConfig = configure(baseWebpackConfig, {
|
|
145
149
|
options: builderOptions,
|
|
146
150
|
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[]) => (WebpackPluginInstance | RuleSetRule)[];
|
|
3
3
|
export declare const mergePlugins: (...args: (WebpackPluginInstance | ResolvePluginInstance)[]) => (WebpackPluginInstance | ResolvePluginInstance)[];
|
package/plugins/webpack.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
declare const getWebpackConfig: (config: import("webpack").Configuration, context: import("../../../build/packages/webpack").NxWebpackExecutionContext) => import("webpack").Configuration;
|
|
3
|
-
export { getWebpackConfig };
|
|
1
|
+
export {};
|
package/plugins/webpack.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const webpack_1 = require("@nx/webpack");
|
|
4
4
|
const with_react_1 = require("./with-react");
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
5
|
+
const plugin = (0, webpack_1.composePlugins)((0, webpack_1.withNx)(), (0, with_react_1.withReact)());
|
|
6
|
+
module.exports = plugin;
|
package/plugins/with-react.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Configuration } from 'webpack';
|
|
2
|
-
import type { WithWebOptions } from '@nx/webpack';
|
|
3
|
-
|
|
4
|
-
interface WithReactOptions extends WithWebOptions {
|
|
2
|
+
import type { NxWebpackExecutionContext, WithWebOptions } from '@nx/webpack';
|
|
3
|
+
export interface WithReactOptions extends WithWebOptions {
|
|
5
4
|
svgr?: false;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
@@ -9,4 +8,3 @@ interface WithReactOptions extends WithWebOptions {
|
|
|
9
8
|
* @returns {NxWebpackPlugin}
|
|
10
9
|
*/
|
|
11
10
|
export declare function withReact(pluginOptions?: WithReactOptions): (config: Configuration, context: NxWebpackExecutionContext) => Configuration;
|
|
12
|
-
export {};
|
package/plugins/with-react.js
CHANGED
|
@@ -1,36 +1,8 @@
|
|
|
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");
|
|
4
5
|
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
|
-
}
|
|
34
6
|
/**
|
|
35
7
|
* @param {WithReactOptions} pluginOptions
|
|
36
8
|
* @returns {NxWebpackPlugin}
|
|
@@ -42,35 +14,7 @@ function withReact(pluginOptions = {}) {
|
|
|
42
14
|
return config;
|
|
43
15
|
// Apply web config for CSS, JSX, index.html handling, etc.
|
|
44
16
|
config = withWeb(pluginOptions)(config, context);
|
|
45
|
-
|
|
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
|
-
};
|
|
17
|
+
(0, apply_react_config_1.applyReactConfig)(pluginOptions, config);
|
|
74
18
|
processed.add(config);
|
|
75
19
|
return config;
|
|
76
20
|
};
|