@nx/react 16.4.0-beta.0 → 16.4.0-beta.2

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.
Files changed (222) hide show
  1. package/ast-utils.js +0 -1
  2. package/babel.js +0 -1
  3. package/index.js +0 -1
  4. package/module-federation.js +0 -1
  5. package/package.json +7 -7
  6. package/plugins/bundle-rollup.js +0 -1
  7. package/plugins/component-testing/index.js +0 -1
  8. package/plugins/component-testing/webpack-fallback.js +0 -1
  9. package/plugins/jest.js +0 -1
  10. package/plugins/storybook/index.js +65 -4
  11. package/plugins/storybook/merge-plugins.js +0 -1
  12. package/plugins/webpack.js +0 -1
  13. package/plugins/with-react.js +0 -1
  14. package/src/executors/module-federation-dev-server/compat.js +0 -1
  15. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js +0 -1
  16. package/src/executors/module-federation-ssr-dev-server/compat.js +0 -1
  17. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js +0 -1
  18. package/src/generators/application/application.js +4 -5
  19. package/src/generators/application/lib/add-cypress.js +0 -1
  20. package/src/generators/application/lib/add-jest.js +0 -1
  21. package/src/generators/application/lib/add-project.js +0 -1
  22. package/src/generators/application/lib/add-routing.js +0 -1
  23. package/src/generators/application/lib/create-application-files.js +0 -1
  24. package/src/generators/application/lib/find-free-port.js +0 -1
  25. package/src/generators/application/lib/get-app-tests.js +0 -1
  26. package/src/generators/application/lib/install-common-dependencies.js +15 -9
  27. package/src/generators/application/lib/normalize-options.js +0 -1
  28. package/src/generators/application/lib/set-defaults.js +1 -2
  29. package/src/generators/application/lib/show-possible-warnings.d.ts +3 -0
  30. package/src/generators/application/lib/show-possible-warnings.js +11 -0
  31. package/src/generators/application/lib/update-jest-config.js +0 -1
  32. package/src/generators/application/schema.d.ts +1 -1
  33. package/src/generators/application/schema.json +2 -2
  34. package/src/generators/component/component.js +0 -1
  35. package/src/generators/component/get-component-tests.js +0 -1
  36. package/src/generators/component/noramlized-schema.js +0 -1
  37. package/src/generators/component-cypress-spec/component-cypress-spec.js +0 -1
  38. package/src/generators/component-story/component-story.js +0 -1
  39. package/src/generators/component-test/component-test.js +0 -1
  40. package/src/generators/component-test/schema.js +0 -1
  41. package/src/generators/cypress-component-configuration/cypress-component-configuration.js +0 -1
  42. package/src/generators/cypress-component-configuration/lib/add-files.js +0 -1
  43. package/src/generators/hook/hook.js +0 -1
  44. package/src/generators/host/host.js +0 -1
  45. package/src/generators/host/lib/add-module-federation-files.js +0 -1
  46. package/src/generators/host/lib/setup-ssr-for-host.js +0 -1
  47. package/src/generators/host/lib/update-module-federation-e2e-project.js +0 -1
  48. package/src/generators/host/schema.d.ts +1 -1
  49. package/src/generators/host/schema.json +1 -1
  50. package/src/generators/init/init.js +0 -26
  51. package/src/generators/init/schema.d.ts +0 -1
  52. package/src/generators/init/schema.json +0 -5
  53. package/src/generators/library/lib/add-linting.js +0 -1
  54. package/src/generators/library/lib/add-rollup-build-target.js +0 -1
  55. package/src/generators/library/lib/create-files.js +25 -4
  56. package/src/generators/library/lib/install-common-dependencies.js +3 -1
  57. package/src/generators/library/lib/maybe-js.js +0 -1
  58. package/src/generators/library/lib/normalize-options.js +0 -1
  59. package/src/generators/library/lib/set-defaults.js +0 -1
  60. package/src/generators/library/lib/update-app-routes.js +0 -1
  61. package/src/generators/library/library.js +1 -2
  62. package/src/generators/redux/redux.js +0 -1
  63. package/src/generators/remote/lib/setup-ssr-for-remote.js +0 -1
  64. package/src/generators/remote/lib/update-host-with-remote.js +0 -1
  65. package/src/generators/remote/remote.js +0 -1
  66. package/src/generators/remote/schema.d.ts +1 -1
  67. package/src/generators/remote/schema.json +1 -1
  68. package/src/generators/setup-ssr/setup-ssr.js +0 -1
  69. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +0 -1
  70. package/src/generators/setup-tailwind/lib/update-project.js +0 -1
  71. package/src/generators/setup-tailwind/schema.js +0 -1
  72. package/src/generators/setup-tailwind/setup-tailwind.js +0 -1
  73. package/src/generators/stories/stories.js +0 -1
  74. package/src/generators/storybook-configuration/configuration.js +0 -1
  75. package/src/migrations/update-12-0-0/remove-react-redux-types-package.js +0 -1
  76. package/src/migrations/update-12-0-0/update-emotion-setup.js +0 -1
  77. package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js +0 -1
  78. package/src/migrations/update-12-8-0/update-12-8-0.js +0 -1
  79. package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js +0 -1
  80. package/src/migrations/update-13-0-0/update-emotion-setup.js +0 -1
  81. package/src/migrations/update-13-0-0/webpack5-changes-utils.js +0 -1
  82. package/src/migrations/update-13-10-0/update-13-10-0.js +0 -1
  83. package/src/migrations/update-14-0-0/add-default-development-configurations.js +0 -1
  84. package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js +0 -1
  85. package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js +0 -1
  86. package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js +0 -1
  87. package/src/migrations/update-14-6-0/add-preset-jest-config.js +0 -1
  88. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js +0 -1
  89. package/src/migrations/update-15-3-0/update-rollup-executor.js +0 -1
  90. package/src/migrations/update-15-6-3/webpack-config-setup.js +0 -1
  91. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -1
  92. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js +0 -1
  93. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js +0 -1
  94. package/src/module-federation/ast-utils.js +0 -1
  95. package/src/module-federation/load-config.js +0 -1
  96. package/src/module-federation/models.js +0 -1
  97. package/src/module-federation/package-json.js +0 -1
  98. package/src/module-federation/utils.js +0 -1
  99. package/src/module-federation/with-module-federation-ssr.js +0 -1
  100. package/src/module-federation/with-module-federation.js +0 -1
  101. package/src/rules/add-styled-dependencies.js +0 -1
  102. package/src/rules/update-module-federation-project.js +0 -1
  103. package/src/utils/assertion.js +0 -1
  104. package/src/utils/ast-utils.js +0 -1
  105. package/src/utils/component-props.js +0 -1
  106. package/src/utils/create-ts-config.js +0 -1
  107. package/src/utils/ct-utils.js +0 -1
  108. package/src/utils/dependencies.js +0 -1
  109. package/src/utils/format-file.js +0 -1
  110. package/src/utils/get-in-source-vitest-tests-template.js +0 -1
  111. package/src/utils/jest-utils.js +0 -1
  112. package/src/utils/lint.js +0 -1
  113. package/src/utils/styled.js +0 -1
  114. package/src/utils/testing-generators.js +0 -1
  115. package/src/utils/versions.js +0 -1
  116. package/tailwind.js +0 -1
  117. package/ast-utils.js.map +0 -1
  118. package/babel.js.map +0 -1
  119. package/index.js.map +0 -1
  120. package/module-federation.js.map +0 -1
  121. package/plugins/bundle-rollup.js.map +0 -1
  122. package/plugins/component-testing/index.js.map +0 -1
  123. package/plugins/component-testing/webpack-fallback.js.map +0 -1
  124. package/plugins/jest.js.map +0 -1
  125. package/plugins/storybook/index.js.map +0 -1
  126. package/plugins/storybook/merge-plugins.js.map +0 -1
  127. package/plugins/webpack.js.map +0 -1
  128. package/plugins/with-react.js.map +0 -1
  129. package/src/executors/module-federation-dev-server/compat.js.map +0 -1
  130. package/src/executors/module-federation-dev-server/module-federation-dev-server.impl.js.map +0 -1
  131. package/src/executors/module-federation-ssr-dev-server/compat.js.map +0 -1
  132. package/src/executors/module-federation-ssr-dev-server/module-federation-ssr-dev-server.impl.js.map +0 -1
  133. package/src/generators/application/application.js.map +0 -1
  134. package/src/generators/application/lib/add-cypress.js.map +0 -1
  135. package/src/generators/application/lib/add-jest.js.map +0 -1
  136. package/src/generators/application/lib/add-project.js.map +0 -1
  137. package/src/generators/application/lib/add-routing.js.map +0 -1
  138. package/src/generators/application/lib/create-application-files.js.map +0 -1
  139. package/src/generators/application/lib/find-free-port.js.map +0 -1
  140. package/src/generators/application/lib/get-app-tests.js.map +0 -1
  141. package/src/generators/application/lib/install-common-dependencies.js.map +0 -1
  142. package/src/generators/application/lib/normalize-options.js.map +0 -1
  143. package/src/generators/application/lib/set-defaults.js.map +0 -1
  144. package/src/generators/application/lib/update-jest-config.js.map +0 -1
  145. package/src/generators/component/component.js.map +0 -1
  146. package/src/generators/component/get-component-tests.js.map +0 -1
  147. package/src/generators/component/noramlized-schema.js.map +0 -1
  148. package/src/generators/component-cypress-spec/component-cypress-spec.js.map +0 -1
  149. package/src/generators/component-story/component-story.js.map +0 -1
  150. package/src/generators/component-test/component-test.js.map +0 -1
  151. package/src/generators/component-test/schema.js.map +0 -1
  152. package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +0 -1
  153. package/src/generators/cypress-component-configuration/lib/add-files.js.map +0 -1
  154. package/src/generators/hook/hook.js.map +0 -1
  155. package/src/generators/host/host.js.map +0 -1
  156. package/src/generators/host/lib/add-module-federation-files.js.map +0 -1
  157. package/src/generators/host/lib/setup-ssr-for-host.js.map +0 -1
  158. package/src/generators/host/lib/update-module-federation-e2e-project.js.map +0 -1
  159. package/src/generators/init/init.js.map +0 -1
  160. package/src/generators/library/files/common/.babelrc__tmpl__ +0 -16
  161. package/src/generators/library/lib/add-linting.js.map +0 -1
  162. package/src/generators/library/lib/add-rollup-build-target.js.map +0 -1
  163. package/src/generators/library/lib/create-files.js.map +0 -1
  164. package/src/generators/library/lib/install-common-dependencies.js.map +0 -1
  165. package/src/generators/library/lib/maybe-js.js.map +0 -1
  166. package/src/generators/library/lib/normalize-options.js.map +0 -1
  167. package/src/generators/library/lib/set-defaults.js.map +0 -1
  168. package/src/generators/library/lib/update-app-routes.js.map +0 -1
  169. package/src/generators/library/library.js.map +0 -1
  170. package/src/generators/redux/redux.js.map +0 -1
  171. package/src/generators/remote/lib/setup-ssr-for-remote.js.map +0 -1
  172. package/src/generators/remote/lib/update-host-with-remote.js.map +0 -1
  173. package/src/generators/remote/remote.js.map +0 -1
  174. package/src/generators/setup-ssr/setup-ssr.js.map +0 -1
  175. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js.map +0 -1
  176. package/src/generators/setup-tailwind/lib/update-project.js.map +0 -1
  177. package/src/generators/setup-tailwind/schema.js.map +0 -1
  178. package/src/generators/setup-tailwind/setup-tailwind.js.map +0 -1
  179. package/src/generators/stories/stories.js.map +0 -1
  180. package/src/generators/storybook-configuration/configuration.js.map +0 -1
  181. package/src/migrations/update-12-0-0/remove-react-redux-types-package.js.map +0 -1
  182. package/src/migrations/update-12-0-0/update-emotion-setup.js.map +0 -1
  183. package/src/migrations/update-12-0-0/use-react-jsx-in-tsconfig.js.map +0 -1
  184. package/src/migrations/update-12-8-0/update-12-8-0.js.map +0 -1
  185. package/src/migrations/update-13-0-0/migrate-storybook-to-webpack-5.js.map +0 -1
  186. package/src/migrations/update-13-0-0/update-emotion-setup.js.map +0 -1
  187. package/src/migrations/update-13-0-0/webpack5-changes-utils.js.map +0 -1
  188. package/src/migrations/update-13-10-0/update-13-10-0.js.map +0 -1
  189. package/src/migrations/update-14-0-0/add-default-development-configurations.js.map +0 -1
  190. package/src/migrations/update-14-0-0/replace-testing-library-react-hook.js.map +0 -1
  191. package/src/migrations/update-14-0-0/update-react-dom-render-for-v18.js.map +0 -1
  192. package/src/migrations/update-14-1-0/update-external-emotion-jsx-runtime.js.map +0 -1
  193. package/src/migrations/update-14-6-0/add-preset-jest-config.js.map +0 -1
  194. package/src/migrations/update-15-3-0/install-webpack-rollup-dependencies.js.map +0 -1
  195. package/src/migrations/update-15-3-0/update-rollup-executor.js.map +0 -1
  196. package/src/migrations/update-15-6-3/webpack-config-setup.js.map +0 -1
  197. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
  198. package/src/migrations/update-16-2-0-remove-package/update-16-2-0-remove-package.js.map +0 -1
  199. package/src/migrations/update-16-3-0/remove-types-react-router-dom-package.js.map +0 -1
  200. package/src/module-federation/ast-utils.js.map +0 -1
  201. package/src/module-federation/load-config.js.map +0 -1
  202. package/src/module-federation/models.js.map +0 -1
  203. package/src/module-federation/package-json.js.map +0 -1
  204. package/src/module-federation/utils.js.map +0 -1
  205. package/src/module-federation/with-module-federation-ssr.js.map +0 -1
  206. package/src/module-federation/with-module-federation.js.map +0 -1
  207. package/src/rules/add-styled-dependencies.js.map +0 -1
  208. package/src/rules/update-module-federation-project.js.map +0 -1
  209. package/src/utils/assertion.js.map +0 -1
  210. package/src/utils/ast-utils.js.map +0 -1
  211. package/src/utils/component-props.js.map +0 -1
  212. package/src/utils/create-ts-config.js.map +0 -1
  213. package/src/utils/ct-utils.js.map +0 -1
  214. package/src/utils/dependencies.js.map +0 -1
  215. package/src/utils/format-file.js.map +0 -1
  216. package/src/utils/get-in-source-vitest-tests-template.js.map +0 -1
  217. package/src/utils/jest-utils.js.map +0 -1
  218. package/src/utils/lint.js.map +0 -1
  219. package/src/utils/styled.js.map +0 -1
  220. package/src/utils/testing-generators.js.map +0 -1
  221. package/src/utils/versions.js.map +0 -1
  222. package/tailwind.js.map +0 -1
package/ast-utils.js CHANGED
@@ -9,4 +9,3 @@ Object.defineProperty(exports, "findElements", { enumerable: true, get: function
9
9
  Object.defineProperty(exports, "findDefaultExport", { enumerable: true, get: function () { return ast_utils_1.findDefaultExport; } });
10
10
  Object.defineProperty(exports, "findClosestOpening", { enumerable: true, get: function () { return ast_utils_1.findClosestOpening; } });
11
11
  Object.defineProperty(exports, "isTag", { enumerable: true, get: function () { return ast_utils_1.isTag; } });
12
- //# sourceMappingURL=ast-utils.js.map
package/babel.js CHANGED
@@ -49,4 +49,3 @@ function getReactPresetOptions({ presetOptions, env }) {
49
49
  }
50
50
  return reactPresetOptions;
51
51
  }
52
- //# sourceMappingURL=babel.js.map
package/index.js CHANGED
@@ -43,4 +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
- //# sourceMappingURL=index.js.map
@@ -10,4 +10,3 @@ module.exports = with_module_federation_1.withModuleFederation;
10
10
  // Allow newer generated code to work: `const { withModuleFederation } = require(...)`;
11
11
  module.exports.withModuleFederation = with_module_federation_1.withModuleFederation;
12
12
  module.exports.withModuleFederationForSSR = with_module_federation_ssr_1.withModuleFederationForSSR;
13
- //# sourceMappingURL=module-federation.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react",
3
- "version": "16.4.0-beta.0",
3
+ "version": "16.4.0-beta.2",
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": {
@@ -31,11 +31,11 @@
31
31
  "migrations": "./migrations.json"
32
32
  },
33
33
  "dependencies": {
34
- "@nrwl/react": "16.4.0-beta.0",
35
- "@nx/devkit": "16.4.0-beta.0",
36
- "@nx/js": "16.4.0-beta.0",
37
- "@nx/linter": "16.4.0-beta.0",
38
- "@nx/web": "16.4.0-beta.0",
34
+ "@nrwl/react": "16.4.0-beta.2",
35
+ "@nx/devkit": "16.4.0-beta.2",
36
+ "@nx/js": "16.4.0-beta.2",
37
+ "@nx/linter": "16.4.0-beta.2",
38
+ "@nx/web": "16.4.0-beta.2",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1",
40
40
  "@svgr/webpack": "^8.0.1",
41
41
  "chalk": "^4.1.0",
@@ -46,5 +46,5 @@
46
46
  "access": "public"
47
47
  },
48
48
  "types": "./index.d.ts",
49
- "gitHead": "c2112a07278e9c78cd6f6c194eb4a75115a7d179"
49
+ "gitHead": "abb2678056668cc8beaaf9c5ebc2a2e6ad487173"
50
50
  }
@@ -39,4 +39,3 @@ function getRollupOptions(options) {
39
39
  return options;
40
40
  }
41
41
  module.exports = getRollupOptions;
42
- //# sourceMappingURL=bundle-rollup.js.map
@@ -162,4 +162,3 @@ function findTsConfig(projectRoot) {
162
162
  }
163
163
  }
164
164
  }
165
- //# sourceMappingURL=index.js.map
@@ -132,4 +132,3 @@ const CSS_MODULES_LOADER = {
132
132
  },
133
133
  ],
134
134
  };
135
- //# sourceMappingURL=webpack-fallback.js.map
package/plugins/jest.js CHANGED
@@ -59,4 +59,3 @@ function getJsTransform(transformers) {
59
59
  // ignored
60
60
  }
61
61
  }
62
- //# sourceMappingURL=jest.js.map
@@ -8,6 +8,7 @@ const path_1 = require("path");
8
8
  const webpack_1 = require("webpack");
9
9
  const merge_plugins_1 = require("./merge-plugins");
10
10
  const with_react_1 = require("../with-react");
11
+ const fs_1 = require("fs");
11
12
  // This is shamelessly taken from CRA and modified for NX use
12
13
  // https://github.com/facebook/create-react-app/blob/4784997f0682e75eb32a897b4ffe34d735912e6c/packages/react-scripts/config/env.js#L71
13
14
  function getClientEnvironment(mode) {
@@ -44,6 +45,67 @@ function getClientEnvironment(mode) {
44
45
  }
45
46
  const core = (prev, options) => (Object.assign(Object.assign({}, prev), { disableWebpackDefaults: true }));
46
47
  exports.core = core;
48
+ const getProjectData = (storybookOptions) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
49
+ const fallbackData = {
50
+ workspaceRoot: storybookOptions.configDir,
51
+ projectRoot: '',
52
+ sourceRoot: '',
53
+ };
54
+ // Edge-case: not running from Nx
55
+ if (!process.env.NX_WORKSPACE_ROOT)
56
+ return fallbackData;
57
+ const projectGraph = yield (0, devkit_1.createProjectGraphAsync)();
58
+ const projectNode = projectGraph.nodes[process.env.NX_TASK_TARGET_PROJECT];
59
+ return projectNode
60
+ ? {
61
+ workspaceRoot: process.env.NX_WORKSPACE_ROOT,
62
+ projectRoot: projectNode.data.root,
63
+ sourceRoot: projectNode.data.sourceRoot,
64
+ projectNode,
65
+ }
66
+ : // Edge-case: missing project node
67
+ fallbackData;
68
+ });
69
+ const fixBabelConfigurationIfNeeded = (webpackConfig, projectData) => {
70
+ if (!projectData.projectNode)
71
+ return;
72
+ const isUsingBabelUpwardRootMode = Object.keys(projectData.projectNode.data.targets).find((k) => {
73
+ var _a;
74
+ const targetConfig = projectData.projectNode.data.targets[k];
75
+ return ((targetConfig.executor === '@nx/webpack:webpack' ||
76
+ targetConfig.executor === '@nrwl/webpack:webpack') &&
77
+ ((_a = targetConfig.options) === null || _a === void 0 ? void 0 : _a.babelUpwardRootMode));
78
+ });
79
+ if (isUsingBabelUpwardRootMode)
80
+ return;
81
+ let babelrcPath;
82
+ for (const ext of ['', '.json', '.js', '.cjs', '.mjs', '.cts']) {
83
+ const candidate = (0, path_1.join)(projectData.workspaceRoot, projectData.projectRoot, `.babelrc${ext}`);
84
+ if ((0, fs_1.existsSync)(candidate)) {
85
+ babelrcPath = candidate;
86
+ break;
87
+ }
88
+ }
89
+ // Unexpected setup, skip.
90
+ if (!babelrcPath)
91
+ return;
92
+ let babelRuleItem;
93
+ for (const rule of webpackConfig.module.rules) {
94
+ if (typeof rule === 'string')
95
+ continue;
96
+ if (!Array.isArray(rule.use))
97
+ continue;
98
+ for (const item of rule.use) {
99
+ if (typeof item !== 'string' && item['loader'].includes('babel-loader')) {
100
+ babelRuleItem = item;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ if (babelRuleItem) {
106
+ babelRuleItem.options.configFile = babelrcPath;
107
+ }
108
+ };
47
109
  const webpack = (storybookWebpackConfig = {}, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
48
110
  var _a, _b, _c, _d, _e, _f;
49
111
  devkit_1.logger.info('=> Loading Nx React Storybook Addon from "@nx/react/plugins/storybook"');
@@ -57,9 +119,9 @@ const webpack = (storybookWebpackConfig = {}, options) => tslib_1.__awaiter(void
57
119
  }
58
120
  const { withNx, withWeb } = require('@nx/webpack');
59
121
  const tsconfigPath = (0, path_1.join)(options.configDir, 'tsconfig.json');
60
- const builderOptions = Object.assign(Object.assign({}, options), { root: options.configDir,
61
- // These are blank because root is the absolute path to .storybook folder
62
- projectRoot: '', sourceRoot: '', fileReplacements: [], sourceMap: true, styles: (_a = options.styles) !== null && _a !== void 0 ? _a : [], optimization: {}, tsConfig: tsconfigPath, extractCss: storybookWebpackConfig.mode === 'production', target: 'web' });
122
+ const projectData = yield getProjectData(options);
123
+ fixBabelConfigurationIfNeeded(storybookWebpackConfig, projectData);
124
+ const builderOptions = Object.assign(Object.assign({}, options), { root: projectData.workspaceRoot, projectRoot: projectData.projectRoot, sourceRoot: projectData.sourceRoot, fileReplacements: [], sourceMap: true, styles: (_a = options.styles) !== null && _a !== void 0 ? _a : [], optimization: {}, tsConfig: tsconfigPath, extractCss: storybookWebpackConfig.mode === 'production', target: 'web' });
63
125
  // ESM build for modern browsers.
64
126
  let baseWebpackConfig = {};
65
127
  const configure = (0, config_1.composePluginsSync)(withNx({ skipTypeChecking: true }), withWeb(), (0, with_react_1.withReact)());
@@ -77,4 +139,3 @@ const webpack = (storybookWebpackConfig = {}, options) => tslib_1.__awaiter(void
77
139
  .plugins) !== null && _d !== void 0 ? _d : [])) }), plugins: (0, merge_plugins_1.mergePlugins)(new webpack_1.DefinePlugin(getClientEnvironment(storybookWebpackConfig.mode).stringified), ...((_e = storybookWebpackConfig.plugins) !== null && _e !== void 0 ? _e : []), ...((_f = finalConfig.plugins) !== null && _f !== void 0 ? _f : [])) });
78
140
  });
79
141
  exports.webpack = webpack;
80
- //# sourceMappingURL=index.js.map
@@ -15,4 +15,3 @@ const mergePlugins = (...args) => args.reduce((plugins, plugin) => {
15
15
  return [...plugins, plugin];
16
16
  }, []);
17
17
  exports.mergePlugins = mergePlugins;
18
- //# sourceMappingURL=merge-plugins.js.map
@@ -12,4 +12,3 @@ const getWebpackConfig = (0, with_react_1.withReact)();
12
12
  exports.getWebpackConfig = getWebpackConfig;
13
13
  legacyExport.getWebpackConfig = getWebpackConfig;
14
14
  module.exports = legacyExport;
15
- //# sourceMappingURL=webpack.js.map
@@ -79,4 +79,3 @@ function withReact(pluginOptions = {}) {
79
79
  };
80
80
  }
81
81
  exports.withReact = withReact;
82
- //# sourceMappingURL=with-react.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const module_federation_dev_server_impl_1 = require("./module-federation-dev-server.impl");
5
5
  exports.default = (0, devkit_1.convertNxExecutor)(module_federation_dev_server_impl_1.default);
6
- //# sourceMappingURL=compat.js.map
@@ -104,4 +104,3 @@ function moduleFederationDevServer(options, context) {
104
104
  });
105
105
  }
106
106
  exports.default = moduleFederationDevServer;
107
- //# sourceMappingURL=module-federation-dev-server.impl.js.map
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  const module_federation_ssr_dev_server_impl_1 = require("./module-federation-ssr-dev-server.impl");
5
5
  exports.default = (0, devkit_1.convertNxExecutor)(module_federation_ssr_dev_server_impl_1.default);
6
- //# sourceMappingURL=compat.js.map
@@ -68,4 +68,3 @@ function moduleFederationSsrDevServer(options, context) {
68
68
  });
69
69
  }
70
70
  exports.default = moduleFederationSsrDevServer;
71
- //# sourceMappingURL=module-federation-ssr-dev-server.impl.js.map
@@ -21,6 +21,7 @@ const install_common_dependencies_1 = require("./lib/install-common-dependencies
21
21
  const create_ts_config_1 = require("../../utils/create-ts-config");
22
22
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
23
23
  const chalk = require("chalk");
24
+ const show_possible_warnings_1 = require("./lib/show-possible-warnings");
24
25
  function addLinting(host, options) {
25
26
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
27
  const tasks = [];
@@ -42,9 +43,7 @@ function addLinting(host, options) {
42
43
  tasks.push(lintTask);
43
44
  (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, '.eslintrc.json'), lint_1.extendReactEslintJson);
44
45
  if (!options.skipPackageJson) {
45
- const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, Object.assign(Object.assign({}, lint_1.extraEslintDependencies.devDependencies), (options.compiler === 'swc'
46
- ? { 'swc-loader': versions_1.swcLoaderVersion }
47
- : {})));
46
+ const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
48
47
  const addSwcTask = (0, add_swc_dependencies_1.addSwcDependencies)(host);
49
48
  tasks.push(installTask, addSwcTask);
50
49
  }
@@ -56,7 +55,8 @@ function applicationGenerator(host, schema) {
56
55
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
57
56
  const tasks = [];
58
57
  const options = (0, normalize_options_1.normalizeOptions)(host, schema);
59
- const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipBabelConfig: options.bundler === 'vite', skipHelperLibs: options.bundler === 'vite' }));
58
+ (0, show_possible_warnings_1.showPossibleWarnings)(host, options);
59
+ const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true, skipHelperLibs: options.bundler === 'vite' }));
60
60
  tasks.push(initTask);
61
61
  if (!options.rootProject) {
62
62
  (0, create_ts_config_1.extractTsConfigBase)(host);
@@ -164,4 +164,3 @@ function applicationGenerator(host, schema) {
164
164
  exports.applicationGenerator = applicationGenerator;
165
165
  exports.default = applicationGenerator;
166
166
  exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
167
- //# sourceMappingURL=application.js.map
@@ -19,4 +19,3 @@ function addCypress(host, options) {
19
19
  });
20
20
  }
21
21
  exports.addCypress = addCypress;
22
- //# sourceMappingURL=add-cypress.js.map
@@ -14,4 +14,3 @@ function addJest(host, options) {
14
14
  });
15
15
  }
16
16
  exports.addJest = addJest;
17
- //# sourceMappingURL=add-jest.js.map
@@ -96,4 +96,3 @@ function createServeTarget(options) {
96
96
  },
97
97
  };
98
98
  }
99
- //# sourceMappingURL=add-project.js.map
@@ -29,4 +29,3 @@ function maybeJs(options, path) {
29
29
  ? path.replace(/\.tsx?$/, '.js')
30
30
  : path;
31
31
  }
32
- //# sourceMappingURL=add-routing.js.map
@@ -101,4 +101,3 @@ function createApplicationFiles(host, options) {
101
101
  (0, create_ts_config_1.createTsConfig)(host, options.appProjectRoot, 'app', options, relativePathToRootTsConfig);
102
102
  }
103
103
  exports.createApplicationFiles = createApplicationFiles;
104
- //# sourceMappingURL=create-application-files.js.map
@@ -15,4 +15,3 @@ function findFreePort(host) {
15
15
  return port > 0 ? port + 1 : 4200;
16
16
  }
17
17
  exports.findFreePort = findFreePort;
18
- //# sourceMappingURL=find-free-port.js.map
@@ -19,4 +19,3 @@ it('should have a greeting as the title', () => {
19
19
  `;
20
20
  }
21
21
  exports.getAppTests = getAppTests;
22
- //# sourceMappingURL=get-app-tests.js.map
@@ -4,26 +4,32 @@ exports.installCommonDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../../utils/versions");
6
6
  function installCommonDependencies(host, options) {
7
- let devDependencies = null;
7
+ const devDependencies = {};
8
8
  // Vite requires style preprocessors to be installed manually.
9
9
  // `@nx/webpack` installs them automatically for now.
10
- // TODO(jack): Once we clean up webpack we can remove this check
11
10
  if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
12
11
  switch (options.style) {
13
12
  case 'scss':
14
- devDependencies = { sass: versions_1.sassVersion };
13
+ devDependencies['sass'] = versions_1.sassVersion;
15
14
  break;
16
15
  case 'less':
17
- devDependencies = { less: versions_1.lessVersion };
16
+ devDependencies['less'] = versions_1.lessVersion;
18
17
  break;
19
18
  case 'styl': // @TODO(17): deprecated, going to be removed in Nx 17
20
- devDependencies = { stylus: versions_1.stylusVersion };
19
+ devDependencies['stylus'] = versions_1.stylusVersion;
21
20
  break;
22
21
  }
23
22
  }
24
- return devDependencies
25
- ? (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies)
26
- : function noop() { };
23
+ if (options.bundler === 'webpack') {
24
+ if (options.compiler === 'swc') {
25
+ devDependencies['swc-loader'] = versions_1.swcLoaderVersion;
26
+ }
27
+ else if (options.compiler === 'babel') {
28
+ // babel-loader is currently included in @nx/webpack
29
+ // TODO(jack): Install babel-loader and other babel packages only as needed
30
+ devDependencies['@babel/preset-react'] = versions_1.babelPresetReactVersion;
31
+ }
32
+ }
33
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
27
34
  }
28
35
  exports.installCommonDependencies = installCommonDependencies;
29
- //# sourceMappingURL=install-common-dependencies.js.map
@@ -59,4 +59,3 @@ function normalizeOptions(host, options) {
59
59
  return normalized;
60
60
  }
61
61
  exports.normalizeOptions = normalizeOptions;
62
- //# sourceMappingURL=normalize-options.js.map
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setDefaults = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function setDefaults(host, options) {
6
- if (options.skipWorkspaceJson) {
6
+ if (options.skipNxJson) {
7
7
  return;
8
8
  }
9
9
  const nxJson = (0, devkit_1.readNxJson)(host);
@@ -20,4 +20,3 @@ function setDefaults(host, options) {
20
20
  (0, devkit_1.updateNxJson)(host, nxJson);
21
21
  }
22
22
  exports.setDefaults = setDefaults;
23
- //# sourceMappingURL=set-defaults.js.map
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema, Schema } from '../schema';
3
+ export declare function showPossibleWarnings(tree: Tree, options: NormalizedSchema<Schema>): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.showPossibleWarnings = void 0;
4
+ const chalk = require("chalk");
5
+ const devkit_1 = require("@nx/devkit");
6
+ function showPossibleWarnings(tree, options) {
7
+ if (options.style === 'styled-jsx' && options.compiler === 'swc') {
8
+ devkit_1.logger.warn(`styled-jsx may not work with SWC. Try using ${chalk.bold('nx g @nx/react:app --compiler=babel')} instead.`);
9
+ }
10
+ }
11
+ exports.showPossibleWarnings = showPossibleWarnings;
@@ -27,4 +27,3 @@ function updateSpecConfig(host, options) {
27
27
  host.write(configPath, content);
28
28
  }
29
29
  exports.updateSpecConfig = updateSpecConfig;
30
- //# sourceMappingURL=update-jest-config.js.map
@@ -14,7 +14,7 @@ export interface Schema {
14
14
  pascalCaseFiles?: boolean;
15
15
  classComponent?: boolean;
16
16
  routing?: boolean;
17
- skipWorkspaceJson?: boolean;
17
+ skipNxJson?: boolean;
18
18
  js?: boolean;
19
19
  globalCss?: boolean;
20
20
  strict?: boolean;
@@ -98,8 +98,8 @@
98
98
  "default": false,
99
99
  "x-priority": "internal"
100
100
  },
101
- "skipWorkspaceJson": {
102
- "description": "Skip updating `workspace.json` with default options based on values provided to this app (e.g. babel, style).",
101
+ "skipNxJson": {
102
+ "description": "Skip updating `nx.json` with default options based on values provided to this app.",
103
103
  "type": "boolean",
104
104
  "default": false,
105
105
  "x-priority": "internal"
@@ -138,4 +138,3 @@ function assertValidOptions(options) {
138
138
  }
139
139
  exports.default = componentGenerator;
140
140
  exports.componentSchematic = (0, devkit_1.convertNxGenerator)(componentGenerator);
141
- //# sourceMappingURL=component.js.map
@@ -10,4 +10,3 @@ function getComponentTests(schema) {
10
10
  `;
11
11
  }
12
12
  exports.getComponentTests = getComponentTests;
13
- //# sourceMappingURL=get-component-tests.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=noramlized-schema.js.map
@@ -102,4 +102,3 @@ function findPropsAndGenerateFileForCypress(tree, sourceFile, cmpDeclaration, e2
102
102
  }
103
103
  exports.default = componentCypressGenerator;
104
104
  exports.componentCypressSchematic = (0, devkit_1.convertNxGenerator)(componentCypressGenerator);
105
- //# sourceMappingURL=component-cypress-spec.js.map
@@ -78,4 +78,3 @@ function componentStoryGenerator(host, schema) {
78
78
  exports.componentStoryGenerator = componentStoryGenerator;
79
79
  exports.default = componentStoryGenerator;
80
80
  exports.componentStorySchematic = (0, devkit_1.convertNxGenerator)(componentStoryGenerator);
81
- //# sourceMappingURL=component-story.js.map
@@ -77,4 +77,3 @@ function generateSpecsForComponents(tree, filePath) {
77
77
  }
78
78
  }
79
79
  exports.default = componentTestGenerator;
80
- //# sourceMappingURL=component-test.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=schema.js.map
@@ -40,4 +40,3 @@ function cypressComponentConfigGenerator(tree, options) {
40
40
  }
41
41
  exports.cypressComponentConfigGenerator = cypressComponentConfigGenerator;
42
42
  exports.default = cypressComponentConfigGenerator;
43
- //# sourceMappingURL=cypress-component-configuration.js.map
@@ -49,4 +49,3 @@ function addFiles(tree, projectConfig, options, found) {
49
49
  });
50
50
  }
51
51
  exports.addFiles = addFiles;
52
- //# sourceMappingURL=add-files.js.map
@@ -114,4 +114,3 @@ function assertValidOptions(options) {
114
114
  }
115
115
  exports.default = hookGenerator;
116
116
  exports.hookSchematic = (0, devkit_1.convertNxGenerator)(hookGenerator);
117
- //# sourceMappingURL=hook.js.map
@@ -64,4 +64,3 @@ function hostGenerator(host, schema) {
64
64
  }
65
65
  exports.hostGenerator = hostGenerator;
66
66
  exports.default = hostGenerator;
67
- //# sourceMappingURL=host.js.map
@@ -18,4 +18,3 @@ function addModuleFederationFiles(host, options, defaultRemoteManifest) {
18
18
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/module-federation`), options.appProjectRoot, templateVariables);
19
19
  }
20
20
  exports.addModuleFederationFiles = addModuleFederationFiles;
21
- //# sourceMappingURL=add-module-federation-files.js.map
@@ -23,4 +23,3 @@ function setupSsrForHost(tree, options, appName, defaultRemoteManifest) {
23
23
  });
24
24
  }
25
25
  exports.setupSsrForHost = setupSsrForHost;
26
- //# sourceMappingURL=setup-ssr-for-host.js.map
@@ -13,4 +13,3 @@ function updateModuleFederationE2eProject(host, options) {
13
13
  }
14
14
  }
15
15
  exports.updateModuleFederationE2eProject = updateModuleFederationE2eProject;
16
- //# sourceMappingURL=update-module-federation-e2e-project.js.map
@@ -15,7 +15,7 @@ export interface Schema {
15
15
  remotes?: string[];
16
16
  setParserOptionsProject?: boolean;
17
17
  skipFormat?: boolean;
18
- skipWorkspaceJson?: boolean;
18
+ skipNxJson?: boolean;
19
19
  ssr?: boolean;
20
20
  strict?: boolean;
21
21
  style: SupportedStyles;
@@ -79,7 +79,7 @@
79
79
  "default": false,
80
80
  "x-priority": "internal"
81
81
  },
82
- "skipWorkspaceJson": {
82
+ "skipNxJson": {
83
83
  "description": "Skip updating workspace.json with default options based on values provided to this app (e.g. babel, style).",
84
84
  "type": "boolean",
85
85
  "default": false,
@@ -29,22 +29,6 @@ function updateDependencies(host, schema) {
29
29
  '@testing-library/react': versions_1.testingLibraryReactVersion,
30
30
  });
31
31
  }
32
- function initRootBabelConfig(tree, schema) {
33
- var _a;
34
- if (tree.exists('/babel.config.json') || tree.exists('/babel.config.js')) {
35
- return;
36
- }
37
- if (!schema.skipBabelConfig) {
38
- (0, devkit_1.writeJson)(tree, '/babel.config.json', {
39
- babelrcRoots: ['*'], // Make sure .babelrc files other than root can be loaded in a monorepo
40
- });
41
- }
42
- const nxJson = (0, devkit_1.readNxJson)(tree);
43
- if ((_a = nxJson.namedInputs) === null || _a === void 0 ? void 0 : _a.sharedGlobals) {
44
- nxJson.namedInputs.sharedGlobals.push('{workspaceRoot}/babel.config.json');
45
- }
46
- (0, devkit_1.updateNxJson)(tree, nxJson);
47
- }
48
32
  function reactInitGenerator(host, schema) {
49
33
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
50
34
  const tasks = [];
@@ -57,15 +41,6 @@ function reactInitGenerator(host, schema) {
57
41
  const cypressTask = yield cypressInitGenerator(host, {});
58
42
  tasks.push(cypressTask);
59
43
  }
60
- if (!schema.skipPackageJson && !schema.skipBabelConfig) {
61
- const installBabelTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
62
- '@babel/preset-react': versions_1.babelPresetReactVersion,
63
- });
64
- tasks.push(installBabelTask);
65
- }
66
- if (!schema.skipBabelConfig) {
67
- initRootBabelConfig(host, schema);
68
- }
69
44
  if (!schema.skipPackageJson) {
70
45
  const installTask = updateDependencies(host, schema);
71
46
  tasks.push(installTask);
@@ -76,4 +51,3 @@ function reactInitGenerator(host, schema) {
76
51
  exports.reactInitGenerator = reactInitGenerator;
77
52
  exports.default = reactInitGenerator;
78
53
  exports.reactInitSchematic = (0, devkit_1.convertNxGenerator)(reactInitGenerator);
79
- //# sourceMappingURL=init.js.map
@@ -1,7 +1,6 @@
1
1
  export interface InitSchema {
2
2
  unitTestRunner?: 'jest' | 'vitest' | 'none';
3
3
  e2eTestRunner?: 'cypress' | 'none';
4
- skipBabelConfig?: boolean;
5
4
  skipFormat?: boolean;
6
5
  skipPackageJson?: boolean;
7
6
  skipHelperLibs?: boolean;
@@ -28,11 +28,6 @@
28
28
  "type": "boolean",
29
29
  "default": false
30
30
  },
31
- "skipBabelConfig": {
32
- "description": "Do not generate a root babel.config.json (if babel is not needed).",
33
- "type": "boolean",
34
- "default": false
35
- },
36
31
  "skipHelperLibs": {
37
32
  "description": "Do not install tslib.",
38
33
  "type": "boolean",
@@ -35,4 +35,3 @@ function addLinting(host, options) {
35
35
  });
36
36
  }
37
37
  exports.addLinting = addLinting;
38
- //# sourceMappingURL=add-linting.js.map
@@ -56,4 +56,3 @@ function addRollupBuildTarget(host, options) {
56
56
  });
57
57
  }
58
58
  exports.addRollupBuildTarget = addRollupBuildTarget;
59
- //# sourceMappingURL=add-rollup-build-target.js.map