@nx/react 0.0.0-pr-28808-bceb02f → 0.0.0-pr-28808-ae8ea8d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "0.0.0-pr-28808-bceb02f",
3
+ "version": "0.0.0-pr-28808-ae8ea8d",
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, Vitest, Playwright, 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": {
@@ -39,10 +39,10 @@
39
39
  "picocolors": "^1.1.0",
40
40
  "tslib": "^2.3.0",
41
41
  "@module-federation/enhanced": "0.6.9",
42
- "@nx/devkit": "0.0.0-pr-28808-bceb02f",
43
- "@nx/js": "0.0.0-pr-28808-bceb02f",
44
- "@nx/eslint": "0.0.0-pr-28808-bceb02f",
45
- "@nx/web": "0.0.0-pr-28808-bceb02f",
42
+ "@nx/devkit": "0.0.0-pr-28808-ae8ea8d",
43
+ "@nx/js": "0.0.0-pr-28808-ae8ea8d",
44
+ "@nx/eslint": "0.0.0-pr-28808-ae8ea8d",
45
+ "@nx/web": "0.0.0-pr-28808-ae8ea8d",
46
46
  "express": "^4.19.2",
47
47
  "http-proxy-middleware": "^3.0.3"
48
48
  },
@@ -257,7 +257,6 @@ async function applicationGeneratorInternal(host, schema) {
257
257
  jsx: 'react-jsx',
258
258
  module: 'esnext',
259
259
  moduleResolution: 'bundler',
260
- // outDir: 'dist/app',
261
260
  });
262
261
  if (!options.skipFormat) {
263
262
  await (0, devkit_1.formatFiles)(host);
@@ -36,14 +36,26 @@ async function addE2e(tree, options) {
36
36
  switch (options.e2eTestRunner) {
37
37
  case 'cypress': {
38
38
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
39
- (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
40
- projectType: 'application',
41
- root: options.e2eProjectRoot,
42
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
43
- targets: {},
44
- implicitDependencies: [options.projectName],
45
- tags: [],
46
- });
39
+ if (options.isUsingTsSolutionConfig) {
40
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
41
+ name: options.e2eProjectName,
42
+ version: '0.0.1',
43
+ private: true,
44
+ nx: {
45
+ name: options.e2eProjectName,
46
+ },
47
+ });
48
+ }
49
+ else {
50
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
51
+ projectType: 'application',
52
+ root: options.e2eProjectRoot,
53
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
54
+ targets: {},
55
+ implicitDependencies: [options.projectName],
56
+ tags: [],
57
+ });
58
+ }
47
59
  const e2eTask = await configurationGenerator(tree, {
48
60
  ...options,
49
61
  project: options.e2eProjectName,
@@ -88,13 +100,25 @@ async function addE2e(tree, options) {
88
100
  }
89
101
  case 'playwright': {
90
102
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
91
- (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
92
- projectType: 'application',
93
- root: options.e2eProjectRoot,
94
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
95
- targets: {},
96
- implicitDependencies: [options.projectName],
97
- });
103
+ if (options.isUsingTsSolutionConfig) {
104
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
105
+ name: options.e2eProjectName,
106
+ version: '0.0.1',
107
+ private: true,
108
+ nx: {
109
+ name: options.e2eProjectName,
110
+ },
111
+ });
112
+ }
113
+ else {
114
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
115
+ projectType: 'application',
116
+ root: options.e2eProjectRoot,
117
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
118
+ targets: {},
119
+ implicitDependencies: [options.projectName],
120
+ });
121
+ }
98
122
  const e2eTask = await configurationGenerator(tree, {
99
123
  project: options.e2eProjectName,
100
124
  skipFormat: true,
@@ -67,7 +67,10 @@ function addExportsToBarrel(host, options) {
67
67
  const workspace = (0, devkit_1.getProjects)(host);
68
68
  const isApp = workspace.get(options.projectName).projectType === 'application';
69
69
  if (options.export && !isApp) {
70
- const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
70
+ let indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
71
+ if (!host.exists(indexFilePath)) {
72
+ indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, 'src', options.js ? 'index.js' : 'index.ts');
73
+ }
71
74
  const indexSource = host.read(indexFilePath, 'utf-8');
72
75
  if (indexSource !== null) {
73
76
  const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
@@ -8,15 +8,10 @@ function updateModuleFederationTsconfig(host, options) {
8
8
  const tsconfigRuntimePath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json');
9
9
  if (!host.exists(tsconfigPath) || !host.exists(tsconfigRuntimePath))
10
10
  return;
11
- // Using `composite: true` and not setting `baseUrl` currently does not work with MF.
12
- // In integrated setup, `baseUrl` was set in `tsconfig.base.json` and we did not set `composite: true`.
11
+ // Not setting `baseUrl` does not work with MF.
13
12
  if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
14
- (0, devkit_1.updateJson)(host, tsconfigRuntimePath, (json) => {
15
- json.compilerOptions = {
16
- ...json.compilerOptions,
17
- composite: false,
18
- baseUrl: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
19
- };
13
+ (0, devkit_1.updateJson)(host, 'tsconfig.base.json', (json) => {
14
+ json.compilerOptions.baseUrl = '.';
20
15
  return json;
21
16
  });
22
17
  // Update references to match what `nx sync` does.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "<%= name %>",
3
3
  "version": "0.0.1",
4
- "main": "./index.js",
5
- "types": "./index.d.ts",
4
+ "main": "./<%= isUsingTsSolutionConfig ? 'dist/' : '' %>index.js",
5
+ "types": "./<%= isUsingTsSolutionConfig ? 'dist/' : '' %>index.d.ts",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./index.mjs",
9
- "require": "./index.js"
8
+ "import": "./<%= isUsingTsSolutionConfig ? 'dist/' : '' %>index.mjs",
9
+ "require": "./<%= isUsingTsSolutionConfig ? 'dist/' : '' %>index.js"
10
10
  }
11
11
  }
12
12
  }
@@ -5,7 +5,27 @@ const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const assertion_1 = require("../../../utils/assertion");
7
7
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
+ const prompt_1 = require("@nx/devkit/src/generators/prompt");
8
9
  async function normalizeOptions(host, options) {
10
+ const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
11
+ if (isUsingTsSolutionConfig) {
12
+ options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
13
+ type: 'autocomplete',
14
+ name: 'bundler',
15
+ message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
16
+ choices: [{ name: 'vite' }, { name: 'rollup' }, { name: 'none' }],
17
+ initial: 0,
18
+ }, { bundler: 'none' }).then(({ bundler }) => bundler);
19
+ }
20
+ else {
21
+ options.bundler ??= await (0, prompt_1.promptWhenInteractive)({
22
+ type: 'autocomplete',
23
+ name: 'bundler',
24
+ message: `Which bundler would you like to use to build the library? Choose 'none' to skip build setup.`,
25
+ choices: [{ name: 'none' }, { name: 'vite' }, { name: 'rollup' }],
26
+ initial: 0,
27
+ }, { bundler: undefined }).then(({ bundler }) => bundler);
28
+ }
9
29
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
10
30
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
11
31
  name: options.name,
@@ -63,7 +83,7 @@ async function normalizeOptions(host, options) {
63
83
  }
64
84
  }
65
85
  (0, assertion_1.assertValidStyle)(normalized.style);
66
- normalized.isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
86
+ normalized.isUsingTsSolutionConfig = isUsingTsSolutionConfig;
67
87
  return normalized;
68
88
  }
69
89
  function findMainEntry(tree, projectRoot) {
@@ -160,10 +160,7 @@
160
160
  "bundler": {
161
161
  "type": "string",
162
162
  "description": "The bundler to use. Choosing 'none' means this library is not buildable.",
163
- "enum": ["none", "vite", "rollup"],
164
- "default": "none",
165
- "x-prompt": "Which bundler would you like to use to build the library? Choose 'none' to skip build setup.",
166
- "x-priority": "important"
163
+ "enum": ["none", "vite", "rollup"]
167
164
  },
168
165
  "compiler": {
169
166
  "type": "string",
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateModuleFederationProject = updateModuleFederationProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const maybe_js_1 = require("../utils/maybe-js");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  function updateModuleFederationProject(host, options) {
7
8
  const projectConfig = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
8
9
  if (options.bundler === 'rspack') {
@@ -76,5 +77,10 @@ function updateModuleFederationProject(host, options) {
76
77
  },
77
78
  },
78
79
  };
80
+ // Typechecks must be performed first before build and serve to generate remote d.ts files.
81
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
82
+ projectConfig.targets.build.dependsOn = ['^build', 'typecheck'];
83
+ projectConfig.targets.serve.dependsOn = ['typecheck'];
84
+ }
79
85
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfig);
80
86
  }