@nx/react 16.8.0-beta.4 → 16.8.0-beta.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/babel.js +2 -3
- package/package.json +7 -7
- package/plugins/bundle-rollup.js +9 -3
- package/plugins/component-testing/index.d.ts +0 -1
- 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/files/common/tsconfig.lib.json__tmpl__ +6 -6
- package/src/generators/library/files/vite/tsconfig.lib.json__tmpl__ +7 -7
- 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 +53 -57
- 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 +10 -3
- 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 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hostGeneratorInternal = exports.hostGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const update_module_federation_project_1 = require("../../rules/update-module-federation-project");
|
|
7
6
|
const application_1 = require("../application/application");
|
|
@@ -12,64 +11,66 @@ const add_module_federation_files_1 = require("./lib/add-module-federation-files
|
|
|
12
11
|
const normalize_remote_1 = require("./lib/normalize-remote");
|
|
13
12
|
const setup_ssr_for_host_1 = require("./lib/setup-ssr-for-host");
|
|
14
13
|
const update_module_federation_e2e_project_1 = require("./lib/update-module-federation-e2e-project");
|
|
15
|
-
function hostGenerator(host, schema) {
|
|
16
|
-
return
|
|
17
|
-
|
|
14
|
+
async function hostGenerator(host, schema) {
|
|
15
|
+
return hostGeneratorInternal(host, {
|
|
16
|
+
projectNameAndRootFormat: 'derived',
|
|
17
|
+
...schema,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
exports.hostGenerator = hostGenerator;
|
|
21
|
-
function hostGeneratorInternal(host, schema) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
remotePort++;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
53
|
-
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
54
|
-
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
55
|
-
if (options.ssr) {
|
|
56
|
-
const setupSsrTask = yield (0, setup_ssr_1.default)(host, {
|
|
57
|
-
project: options.projectName,
|
|
58
|
-
serverPort: options.devServerPort,
|
|
21
|
+
async function hostGeneratorInternal(host, schema) {
|
|
22
|
+
const tasks = [];
|
|
23
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema, '@nx/react:host');
|
|
24
|
+
const initTask = await (0, application_1.default)(host, {
|
|
25
|
+
...options,
|
|
26
|
+
// The target use-case is loading remotes as child routes, thus always enable routing.
|
|
27
|
+
routing: true,
|
|
28
|
+
// Only webpack works with module federation for now.
|
|
29
|
+
bundler: 'webpack',
|
|
30
|
+
skipFormat: true,
|
|
31
|
+
});
|
|
32
|
+
tasks.push(initTask);
|
|
33
|
+
const remotesWithPorts = [];
|
|
34
|
+
if (schema.remotes) {
|
|
35
|
+
let remotePort = options.devServerPort + 1;
|
|
36
|
+
for (const remote of schema.remotes) {
|
|
37
|
+
const remoteName = await (0, normalize_remote_1.normalizeRemoteName)(host, remote, options);
|
|
38
|
+
remotesWithPorts.push({ name: remoteName, port: remotePort });
|
|
39
|
+
await (0, remote_1.default)(host, {
|
|
40
|
+
name: remote,
|
|
41
|
+
directory: (0, normalize_remote_1.normalizeRemoteDirectory)(remote, options),
|
|
42
|
+
style: options.style,
|
|
43
|
+
unitTestRunner: options.unitTestRunner,
|
|
44
|
+
e2eTestRunner: options.e2eTestRunner,
|
|
45
|
+
linter: options.linter,
|
|
46
|
+
devServerPort: remotePort,
|
|
47
|
+
ssr: options.ssr,
|
|
59
48
|
skipFormat: true,
|
|
49
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
60
50
|
});
|
|
61
|
-
|
|
62
|
-
const setupSsrForHostTask = yield (0, setup_ssr_for_host_1.setupSsrForHost)(host, options, options.projectName, remotesWithPorts);
|
|
63
|
-
tasks.push(setupSsrForHostTask);
|
|
64
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
65
|
-
projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, 'webpack.server.config.js');
|
|
66
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
51
|
+
remotePort++;
|
|
67
52
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
}
|
|
54
|
+
(0, add_module_federation_files_1.addModuleFederationFiles)(host, options, remotesWithPorts);
|
|
55
|
+
(0, update_module_federation_project_1.updateModuleFederationProject)(host, options);
|
|
56
|
+
(0, update_module_federation_e2e_project_1.updateModuleFederationE2eProject)(host, options);
|
|
57
|
+
if (options.ssr) {
|
|
58
|
+
const setupSsrTask = await (0, setup_ssr_1.default)(host, {
|
|
59
|
+
project: options.projectName,
|
|
60
|
+
serverPort: options.devServerPort,
|
|
61
|
+
skipFormat: true,
|
|
62
|
+
});
|
|
63
|
+
tasks.push(setupSsrTask);
|
|
64
|
+
const setupSsrForHostTask = await (0, setup_ssr_for_host_1.setupSsrForHost)(host, options, options.projectName, remotesWithPorts);
|
|
65
|
+
tasks.push(setupSsrForHostTask);
|
|
66
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
67
|
+
projectConfig.targets.server.options.webpackConfig = (0, devkit_1.joinPathFragments)(projectConfig.root, 'webpack.server.config.js');
|
|
68
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
|
|
69
|
+
}
|
|
70
|
+
if (!options.skipFormat) {
|
|
71
|
+
await (0, devkit_1.formatFiles)(host);
|
|
72
|
+
}
|
|
73
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
73
74
|
}
|
|
74
75
|
exports.hostGeneratorInternal = hostGeneratorInternal;
|
|
75
76
|
exports.default = hostGenerator;
|
|
@@ -4,9 +4,17 @@ exports.addModuleFederationFiles = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
function addModuleFederationFiles(host, options, defaultRemoteManifest) {
|
|
7
|
-
const templateVariables =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const templateVariables = {
|
|
8
|
+
...(0, devkit_1.names)(options.name),
|
|
9
|
+
...options,
|
|
10
|
+
tmpl: '',
|
|
11
|
+
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
12
|
+
return {
|
|
13
|
+
...(0, devkit_1.names)(name),
|
|
14
|
+
port,
|
|
15
|
+
};
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
10
18
|
// Module federation requires bootstrap code to be dynamically imported.
|
|
11
19
|
// Renaming original entry file so we can use `import(./bootstrap)` in
|
|
12
20
|
// new entry file.
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeRemoteDirectory = exports.normalizeRemoteName = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
7
|
-
function normalizeRemoteName(tree, remote, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
callingGenerator: '@nx/react:host',
|
|
15
|
-
});
|
|
16
|
-
return remoteName;
|
|
6
|
+
async function normalizeRemoteName(tree, remote, options) {
|
|
7
|
+
const { projectName: remoteName } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
|
|
8
|
+
name: remote,
|
|
9
|
+
projectType: 'application',
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
|
+
callingGenerator: '@nx/react:host',
|
|
17
13
|
});
|
|
14
|
+
return remoteName;
|
|
18
15
|
}
|
|
19
16
|
exports.normalizeRemoteName = normalizeRemoteName;
|
|
20
17
|
function normalizeRemoteDirectory(remote, options) {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupSsrForHost = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
async function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
|
|
7
|
+
const tasks = [];
|
|
8
|
+
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
9
|
+
project.targets.serve.executor = '@nx/react:module-federation-ssr-dev-server';
|
|
10
|
+
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
11
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/module-federation-ssr'), project.root, {
|
|
12
|
+
...options,
|
|
13
|
+
remotes: defaultRemoteManifest.map(({ name, port }) => {
|
|
14
|
+
return {
|
|
15
|
+
...(0, devkit_1.names)(name),
|
|
16
|
+
port,
|
|
17
|
+
};
|
|
18
|
+
}),
|
|
19
|
+
appName,
|
|
20
|
+
tmpl: '',
|
|
21
|
+
browserBuildOutputPath: project.targets.build.options.outputPath,
|
|
21
22
|
});
|
|
23
|
+
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
24
|
+
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
25
|
+
}, {});
|
|
26
|
+
tasks.push(installTask);
|
|
27
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
22
28
|
}
|
|
23
29
|
exports.setupSsrForHost = setupSsrForHost;
|
|
@@ -5,10 +5,13 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function updateModuleFederationE2eProject(host, options) {
|
|
6
6
|
try {
|
|
7
7
|
let projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.e2eProjectName);
|
|
8
|
-
projectConfig.targets.e2e.options =
|
|
8
|
+
projectConfig.targets.e2e.options = {
|
|
9
|
+
...projectConfig.targets.e2e.options,
|
|
10
|
+
baseUrl: `http://localhost:${options.devServerPort}`,
|
|
11
|
+
};
|
|
9
12
|
(0, devkit_1.updateProjectConfiguration)(host, options.e2eProjectName, projectConfig);
|
|
10
13
|
}
|
|
11
|
-
catch
|
|
14
|
+
catch {
|
|
12
15
|
// nothing
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactInitSchematic = exports.reactInitGenerator = 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 versions_1 = require("../../utils/versions");
|
|
@@ -9,8 +8,17 @@ function setDefault(host) {
|
|
|
9
8
|
const workspace = (0, devkit_1.readNxJson)(host);
|
|
10
9
|
workspace.generators = workspace.generators || {};
|
|
11
10
|
const reactGenerators = workspace.generators['@nx/react'] || {};
|
|
12
|
-
const generators =
|
|
13
|
-
|
|
11
|
+
const generators = {
|
|
12
|
+
...workspace.generators,
|
|
13
|
+
'@nx/react': {
|
|
14
|
+
...reactGenerators,
|
|
15
|
+
application: {
|
|
16
|
+
...reactGenerators.application,
|
|
17
|
+
babel: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
(0, devkit_1.updateNxJson)(host, { ...workspace, generators });
|
|
14
22
|
}
|
|
15
23
|
function updateDependencies(host, schema) {
|
|
16
24
|
(0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react'], []);
|
|
@@ -29,24 +37,26 @@ function updateDependencies(host, schema) {
|
|
|
29
37
|
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
30
38
|
});
|
|
31
39
|
}
|
|
32
|
-
function reactInitGenerator(host, schema) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
|
|
39
|
-
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
40
|
-
const { cypressInitGenerator } = yield Promise.resolve().then(() => require('@nx/cypress/src/generators/init/init'));
|
|
41
|
-
const cypressTask = yield cypressInitGenerator(host, {});
|
|
42
|
-
tasks.push(cypressTask);
|
|
43
|
-
}
|
|
44
|
-
if (!schema.skipPackageJson) {
|
|
45
|
-
const installTask = updateDependencies(host, schema);
|
|
46
|
-
tasks.push(installTask);
|
|
47
|
-
}
|
|
48
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
40
|
+
async function reactInitGenerator(host, schema) {
|
|
41
|
+
const tasks = [];
|
|
42
|
+
const jsInitTask = await (0, js_1.initGenerator)(host, {
|
|
43
|
+
...schema,
|
|
44
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
45
|
+
skipFormat: true,
|
|
49
46
|
});
|
|
47
|
+
tasks.push(jsInitTask);
|
|
48
|
+
setDefault(host);
|
|
49
|
+
if (!schema.e2eTestRunner || schema.e2eTestRunner === 'cypress') {
|
|
50
|
+
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
51
|
+
const { cypressInitGenerator } = await Promise.resolve().then(() => require('@nx/cypress/src/generators/init/init'));
|
|
52
|
+
const cypressTask = await cypressInitGenerator(host, {});
|
|
53
|
+
tasks.push(cypressTask);
|
|
54
|
+
}
|
|
55
|
+
if (!schema.skipPackageJson) {
|
|
56
|
+
const installTask = updateDependencies(host, schema);
|
|
57
|
+
tasks.push(installTask);
|
|
58
|
+
}
|
|
59
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
50
60
|
}
|
|
51
61
|
exports.reactInitGenerator = reactInitGenerator;
|
|
52
62
|
exports.default = reactInitGenerator;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"extends": "./tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
|
-
"types": [
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
<% if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } %>
|
|
8
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
9
|
+
"@nx/react/typings/image.d.ts"
|
|
10
|
+
]
|
|
6
11
|
},
|
|
7
|
-
"files": [<% if (style === 'styled-jsx') { %>
|
|
8
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/styled-jsx.d.ts",<% } %>
|
|
9
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
-
],
|
|
12
12
|
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.tsx", "src/**/*.test.tsx", "src/**/*.spec.js", "src/**/*.test.js", "src/**/*.spec.jsx", "src/**/*.test.jsx"],
|
|
13
13
|
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
14
14
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"extends": "./tsconfig.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
|
-
"types": [
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
<% if (style === 'styled-jsx') { %>"@nx/react/typings/styled-jsx.d.ts",<% } %>
|
|
8
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
9
|
+
"@nx/react/typings/image.d.ts"
|
|
10
|
+
]
|
|
6
11
|
},
|
|
7
|
-
"files": [<% if (style === 'styled-jsx') { %>
|
|
8
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/styled-jsx.d.ts",<% } %>
|
|
9
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
-
"<%= offsetFromRoot %>node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
-
],
|
|
12
12
|
"exclude": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "**/*.spec.js", "**/*.test.js", "**/*.spec.jsx", "**/*.test.jsx"],
|
|
13
|
-
"include": ["
|
|
13
|
+
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
|
|
14
14
|
}
|
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addLinting = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const linter_1 = require("@nx/linter");
|
|
6
5
|
const path_1 = require("nx/src/utils/path");
|
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
|
8
7
|
const lint_1 = require("../../../utils/lint");
|
|
9
8
|
const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
|
|
10
|
-
function addLinting(host, options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
27
|
-
}
|
|
28
|
-
let installTask = () => { };
|
|
29
|
-
if (!options.skipPackageJson) {
|
|
30
|
-
installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
31
|
-
}
|
|
32
|
-
return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
|
|
9
|
+
async function addLinting(host, options) {
|
|
10
|
+
if (options.linter === linter_1.Linter.EsLint) {
|
|
11
|
+
const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
|
|
12
|
+
linter: options.linter,
|
|
13
|
+
project: options.name,
|
|
14
|
+
tsConfigPaths: [
|
|
15
|
+
(0, path_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
16
|
+
],
|
|
17
|
+
unitTestRunner: options.unitTestRunner,
|
|
18
|
+
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
|
|
19
|
+
skipFormat: true,
|
|
20
|
+
skipPackageJson: options.skipPackageJson,
|
|
21
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
22
|
+
});
|
|
23
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
24
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
let installTask = () => { };
|
|
27
|
+
if (!options.skipPackageJson) {
|
|
28
|
+
installTask = await (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return () => { };
|
|
34
|
+
}
|
|
38
35
|
}
|
|
39
36
|
exports.addLinting = addLinting;
|
|
@@ -1,55 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addRollupBuildTarget = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const maybe_js_1 = require("./maybe-js");
|
|
7
6
|
const versions_1 = require("../../../utils/versions");
|
|
8
|
-
function addRollupBuildTarget(host, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'@rollup/plugin-url': versions_1.rollupPluginUrlVersion,
|
|
15
|
-
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
16
|
-
});
|
|
17
|
-
const { targets } = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
18
|
-
const external = ['react', 'react-dom'];
|
|
19
|
-
if (options.style === '@emotion/styled') {
|
|
20
|
-
external.push('@emotion/react/jsx-runtime');
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
external.push('react/jsx-runtime');
|
|
24
|
-
}
|
|
25
|
-
targets.build = {
|
|
26
|
-
executor: '@nx/rollup:rollup',
|
|
27
|
-
outputs: ['{options.outputPath}'],
|
|
28
|
-
options: {
|
|
29
|
-
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
30
|
-
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
31
|
-
project: `${options.projectRoot}/package.json`,
|
|
32
|
-
entryFile: (0, maybe_js_1.maybeJs)(options, `${options.projectRoot}/src/index.ts`),
|
|
33
|
-
external,
|
|
34
|
-
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
35
|
-
compiler: (_a = options.compiler) !== null && _a !== void 0 ? _a : 'babel',
|
|
36
|
-
assets: [
|
|
37
|
-
{
|
|
38
|
-
glob: `${options.projectRoot}/README.md`,
|
|
39
|
-
input: '.',
|
|
40
|
-
output: '.',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.name, {
|
|
46
|
-
root: options.projectRoot,
|
|
47
|
-
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
48
|
-
projectType: 'library',
|
|
49
|
-
tags: options.parsedTags,
|
|
50
|
-
targets,
|
|
51
|
-
});
|
|
52
|
-
return rollupInitGenerator(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
|
|
7
|
+
async function addRollupBuildTarget(host, options) {
|
|
8
|
+
const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
9
|
+
// These are used in `@nx/react/plugins/bundle-rollup`
|
|
10
|
+
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
11
|
+
'@rollup/plugin-url': versions_1.rollupPluginUrlVersion,
|
|
12
|
+
'@svgr/rollup': versions_1.svgrRollupVersion,
|
|
53
13
|
});
|
|
14
|
+
const { targets } = (0, devkit_1.readProjectConfiguration)(host, options.name);
|
|
15
|
+
const external = ['react', 'react-dom'];
|
|
16
|
+
if (options.style === '@emotion/styled') {
|
|
17
|
+
external.push('@emotion/react/jsx-runtime');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
external.push('react/jsx-runtime');
|
|
21
|
+
}
|
|
22
|
+
targets.build = {
|
|
23
|
+
executor: '@nx/rollup:rollup',
|
|
24
|
+
outputs: ['{options.outputPath}'],
|
|
25
|
+
options: {
|
|
26
|
+
outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
|
|
27
|
+
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
28
|
+
project: `${options.projectRoot}/package.json`,
|
|
29
|
+
entryFile: (0, maybe_js_1.maybeJs)(options, `${options.projectRoot}/src/index.ts`),
|
|
30
|
+
external,
|
|
31
|
+
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
32
|
+
compiler: options.compiler ?? 'babel',
|
|
33
|
+
assets: [
|
|
34
|
+
{
|
|
35
|
+
glob: `${options.projectRoot}/README.md`,
|
|
36
|
+
input: '.',
|
|
37
|
+
output: '.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
(0, devkit_1.updateProjectConfiguration)(host, options.name, {
|
|
43
|
+
root: options.projectRoot,
|
|
44
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
45
|
+
projectType: 'library',
|
|
46
|
+
tags: options.parsedTags,
|
|
47
|
+
targets,
|
|
48
|
+
});
|
|
49
|
+
return rollupInitGenerator(host, { ...options, skipFormat: true });
|
|
54
50
|
}
|
|
55
51
|
exports.addRollupBuildTarget = addRollupBuildTarget;
|
|
@@ -6,7 +6,13 @@ const js_1 = require("@nx/js");
|
|
|
6
6
|
const create_ts_config_1 = require("../../../utils/create-ts-config");
|
|
7
7
|
function createFiles(host, options) {
|
|
8
8
|
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot);
|
|
9
|
-
const substitutions =
|
|
9
|
+
const substitutions = {
|
|
10
|
+
...options,
|
|
11
|
+
...(0, devkit_1.names)(options.name),
|
|
12
|
+
tmpl: '',
|
|
13
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
14
|
+
fileName: options.fileName,
|
|
15
|
+
};
|
|
10
16
|
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files/common'), options.projectRoot, substitutions);
|
|
11
17
|
if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
|
|
12
18
|
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files/vite'), options.projectRoot, substitutions);
|