@nx/webpack 17.0.4 → 17.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -9
  3. package/generators.json +2 -2
  4. package/index.d.ts +1 -3
  5. package/index.js +2 -7
  6. package/migrations.json +0 -6
  7. package/package.json +5 -6
  8. package/src/executors/dev-server/dev-server.impl.js +17 -31
  9. package/src/executors/dev-server/lib/get-dev-server-config.d.ts +3 -2
  10. package/src/executors/dev-server/lib/get-dev-server-config.js +26 -18
  11. package/src/executors/dev-server/schema.d.ts +8 -8
  12. package/src/executors/webpack/lib/get-webpack-config.d.ts +5 -0
  13. package/src/executors/webpack/lib/get-webpack-config.js +16 -0
  14. package/src/executors/webpack/lib/normalize-options.d.ts +2 -1
  15. package/src/executors/webpack/lib/normalize-options.js +53 -9
  16. package/src/executors/webpack/schema.d.ts +7 -10
  17. package/src/executors/webpack/schema.json +50 -30
  18. package/src/executors/webpack/webpack.impl.js +16 -36
  19. package/src/generators/configuration/configuration.d.ts +2 -3
  20. package/src/generators/configuration/configuration.js +23 -95
  21. package/src/generators/configuration/schema.d.ts +0 -1
  22. package/src/generators/configuration/schema.json +1 -1
  23. package/src/generators/init/init.d.ts +0 -1
  24. package/src/generators/init/init.js +23 -48
  25. package/src/generators/init/schema.d.ts +2 -4
  26. package/src/generators/init/schema.json +13 -18
  27. package/src/plugins/generate-package-json-plugin.d.ts +4 -6
  28. package/src/plugins/generate-package-json-plugin.js +14 -11
  29. package/src/utils/config.d.ts +6 -11
  30. package/src/utils/config.js +13 -48
  31. package/src/utils/get-client-environment.js +1 -4
  32. package/src/utils/module-federation/dependencies.js +3 -15
  33. package/src/utils/module-federation/get-remotes-for-host.js +1 -1
  34. package/src/utils/module-federation/remotes.js +1 -1
  35. package/src/utils/module-federation/secondary-entry-points.js +1 -1
  36. package/src/utils/module-federation/typescript.js +9 -14
  37. package/src/utils/versions.d.ts +0 -1
  38. package/src/utils/versions.js +1 -2
  39. package/src/utils/webpack/custom-webpack.d.ts +2 -0
  40. package/src/utils/webpack/{resolve-user-defined-webpack-config.js → custom-webpack.js} +8 -14
  41. package/src/utils/webpack/deprecated-stylus-loader.js +2 -2
  42. package/src/utils/webpack/interpolate-env-variables-to-index.js +1 -4
  43. package/src/utils/webpack/plugins/postcss-cli-resources.js +2 -2
  44. package/src/utils/with-nx.d.ts +58 -4
  45. package/src/utils/with-nx.js +362 -22
  46. package/src/utils/with-web.d.ts +2 -2
  47. package/src/utils/with-web.js +488 -9
  48. package/plugin.d.ts +0 -1
  49. package/plugin.js +0 -5
  50. package/src/migrations/update-17-2-1/webpack-config-setup.d.ts +0 -2
  51. package/src/migrations/update-17-2-1/webpack-config-setup.js +0 -31
  52. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.d.ts +0 -8
  53. package/src/plugins/nx-typescript-webpack-plugin/nx-tsconfig-paths-webpack-plugin.js +0 -31
  54. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.d.ts +0 -5
  55. package/src/plugins/nx-webpack-plugin/lib/apply-base-config.js +0 -318
  56. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.d.ts +0 -5
  57. package/src/plugins/nx-webpack-plugin/lib/apply-web-config.js +0 -372
  58. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.d.ts +0 -53
  59. package/src/plugins/nx-webpack-plugin/lib/compiler-loaders.js +0 -78
  60. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.d.ts +0 -1
  61. package/src/plugins/nx-webpack-plugin/lib/get-terser-ecma-version.js +0 -35
  62. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.d.ts +0 -3
  63. package/src/plugins/nx-webpack-plugin/lib/instantiate-script-plugins.js +0 -42
  64. package/src/plugins/nx-webpack-plugin/lib/normalize-options.d.ts +0 -4
  65. package/src/plugins/nx-webpack-plugin/lib/normalize-options.js +0 -148
  66. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.d.ts +0 -73
  67. package/src/plugins/nx-webpack-plugin/lib/stylesheet-loaders.js +0 -117
  68. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.d.ts +0 -216
  69. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin-options.js +0 -2
  70. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.d.ts +0 -17
  71. package/src/plugins/nx-webpack-plugin/nx-webpack-plugin.js +0 -48
  72. package/src/plugins/plugin.d.ts +0 -9
  73. package/src/plugins/plugin.js +0 -132
  74. package/src/utils/ensure-dependencies.d.ts +0 -6
  75. package/src/utils/ensure-dependencies.js +0 -28
  76. package/src/utils/has-plugin.d.ts +0 -2
  77. package/src/utils/has-plugin.js +0 -11
  78. package/src/utils/webpack/read-webpack-options.d.ts +0 -10
  79. package/src/utils/webpack/read-webpack-options.js +0 -41
  80. package/src/utils/webpack/resolve-user-defined-webpack-config.d.ts +0 -3
@@ -1,31 +1,26 @@
1
1
  {
2
- "$schema": "https://json-schema.org/schema",
2
+ "$schema": "http://json-schema.org/schema",
3
3
  "$id": "NxWebpackInit",
4
4
  "cli": "nx",
5
5
  "title": "Init Webpack Plugin",
6
6
  "description": "Initialize the Webpack Plugin.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "skipFormat": {
10
- "description": "Skip formatting files.",
11
- "type": "boolean",
12
- "default": false
9
+ "uiFramework": {
10
+ "type": "string",
11
+ "description": "UI Framework to use for Webpack.",
12
+ "enum": ["react", "none"],
13
+ "x-prompt": "What UI framework plugin should Webpack use?"
13
14
  },
14
- "skipPackageJson": {
15
- "description": "Do not add dependencies to `package.json`.",
16
- "type": "boolean",
17
- "default": false
15
+ "compiler": {
16
+ "type": "string",
17
+ "enum": ["babel", "swc", "tsc"],
18
+ "description": "The compiler to initialize for.",
19
+ "default": "babel"
18
20
  },
19
- "keepExistingVersions": {
20
- "type": "boolean",
21
- "x-priority": "internal",
22
- "description": "Keep existing dependencies versions",
23
- "default": false
24
- },
25
- "updatePackageScripts": {
21
+ "skipFormat": {
22
+ "description": "Skip formatting files.",
26
23
  "type": "boolean",
27
- "x-priority": "internal",
28
- "description": "Update `package.json` scripts with inferred targets",
29
24
  "default": false
30
25
  }
31
26
  },
@@ -1,14 +1,12 @@
1
1
  import { type Compiler, type WebpackPluginInstance } from 'webpack';
2
- import { type ProjectGraph } from '@nx/devkit';
2
+ import { ExecutorContext } from '@nx/devkit';
3
3
  export declare class GeneratePackageJsonPlugin implements WebpackPluginInstance {
4
4
  private readonly options;
5
+ private readonly context;
6
+ private readonly projectGraph;
5
7
  constructor(options: {
6
8
  tsConfig: string;
7
9
  outputFileName: string;
8
- root: string;
9
- projectName: string;
10
- targetName: string;
11
- projectGraph: ProjectGraph;
12
- });
10
+ }, context: ExecutorContext);
13
11
  apply(compiler: Compiler): void;
14
12
  }
@@ -4,10 +4,13 @@ exports.GeneratePackageJsonPlugin = void 0;
4
4
  const webpack_1 = require("webpack");
5
5
  const js_1 = require("@nx/js");
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const js_2 = require("@nx/js");
7
8
  const pluginName = 'GeneratePackageJsonPlugin';
8
9
  class GeneratePackageJsonPlugin {
9
- constructor(options) {
10
+ constructor(options, context) {
10
11
  this.options = options;
12
+ this.context = context;
13
+ this.projectGraph = context.projectGraph;
11
14
  }
12
15
  apply(compiler) {
13
16
  compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
@@ -15,28 +18,28 @@ class GeneratePackageJsonPlugin {
15
18
  name: pluginName,
16
19
  stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
17
20
  }, () => {
18
- const helperDependencies = (0, js_1.getHelperDependenciesFromProjectGraph)(this.options.root, this.options.projectName, this.options.projectGraph);
19
- const importHelpers = !!(0, js_1.readTsConfig)(this.options.tsConfig).options
21
+ const helperDependencies = (0, js_2.getHelperDependenciesFromProjectGraph)(this.context.root, this.context.projectName, this.projectGraph);
22
+ const importHelpers = !!(0, js_2.readTsConfig)(this.options.tsConfig).options
20
23
  .importHelpers;
21
24
  const shouldAddHelperDependency = importHelpers &&
22
- helperDependencies.every((dep) => dep.target !== js_1.HelperDependency.tsc);
25
+ helperDependencies.every((dep) => dep.target !== js_2.HelperDependency.tsc);
23
26
  if (shouldAddHelperDependency) {
24
27
  helperDependencies.push({
25
28
  type: 'static',
26
- source: this.options.projectName,
27
- target: js_1.HelperDependency.tsc,
29
+ source: this.context.projectName,
30
+ target: js_2.HelperDependency.tsc,
28
31
  });
29
32
  }
30
- const packageJson = (0, js_1.createPackageJson)(this.options.projectName, this.options.projectGraph, {
31
- target: this.options.targetName,
32
- root: this.options.root,
33
+ const packageJson = (0, js_1.createPackageJson)(this.context.projectName, this.projectGraph, {
34
+ target: this.context.targetName,
35
+ root: this.context.root,
33
36
  isProduction: true,
34
37
  helperDependencies: helperDependencies.map((dep) => dep.target),
35
38
  });
36
39
  packageJson.main = packageJson.main ?? this.options.outputFileName;
37
40
  compilation.emitAsset('package.json', new webpack_1.sources.RawSource((0, devkit_1.serializeJson)(packageJson)));
38
- const packageManager = (0, devkit_1.detectPackageManager)(this.options.root);
39
- compilation.emitAsset((0, js_1.getLockFileName)(packageManager), new webpack_1.sources.RawSource((0, js_1.createLockFile)(packageJson, this.options.projectGraph, packageManager)));
41
+ const packageManager = (0, devkit_1.detectPackageManager)(this.context.root);
42
+ compilation.emitAsset((0, js_2.getLockFileName)(packageManager), new webpack_1.sources.RawSource((0, js_1.createLockFile)(packageJson, this.projectGraph, packageManager)));
40
43
  });
41
44
  });
42
45
  }
@@ -1,22 +1,17 @@
1
1
  import { ExecutorContext } from '@nx/devkit';
2
2
  import { Configuration } from 'webpack';
3
3
  import { NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
4
- export declare const nxWebpackComposablePlugin = "nxWebpackComposablePlugin";
5
- export declare function isNxWebpackComposablePlugin(a: unknown): a is AsyncNxComposableWebpackPlugin;
4
+ /** @deprecated use withNx and withWeb plugins directly */
5
+ export declare function getBaseWebpackPartial(options: NormalizedWebpackExecutorOptions, context?: ExecutorContext): Configuration;
6
6
  export interface NxWebpackExecutionContext {
7
7
  options: NormalizedWebpackExecutorOptions;
8
8
  context: ExecutorContext;
9
- configuration?: string;
10
9
  }
11
- export interface NxComposableWebpackPlugin {
10
+ export interface NxWebpackPlugin {
12
11
  (config: Configuration, ctx: NxWebpackExecutionContext): Configuration;
13
12
  }
14
- export interface AsyncNxComposableWebpackPlugin {
13
+ export interface AsyncNxWebpackPlugin {
15
14
  (config: Configuration, ctx: NxWebpackExecutionContext): Configuration | Promise<Configuration>;
16
15
  }
17
- export declare function composePlugins(...plugins: (NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin | Promise<NxComposableWebpackPlugin | AsyncNxComposableWebpackPlugin>)[]): ((config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>) & {
18
- nxWebpackComposablePlugin: boolean;
19
- };
20
- export declare function composePluginsSync(...plugins: NxComposableWebpackPlugin[]): ((config: Configuration, ctx: NxWebpackExecutionContext) => Configuration) & {
21
- nxWebpackComposablePlugin: boolean;
22
- };
16
+ export declare function composePlugins(...plugins: (NxWebpackPlugin | AsyncNxWebpackPlugin | Promise<NxWebpackPlugin | AsyncNxWebpackPlugin>)[]): (config: Configuration, ctx: NxWebpackExecutionContext) => Promise<Configuration>;
17
+ export declare function composePluginsSync(...plugins: NxWebpackPlugin[]): (config: Configuration, ctx: NxWebpackExecutionContext) => Configuration;
@@ -1,66 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composePluginsSync = exports.composePlugins = exports.isNxWebpackComposablePlugin = exports.nxWebpackComposablePlugin = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- exports.nxWebpackComposablePlugin = 'nxWebpackComposablePlugin';
6
- function isNxWebpackComposablePlugin(a) {
7
- return a?.[exports.nxWebpackComposablePlugin] === true;
3
+ exports.composePluginsSync = exports.composePlugins = exports.getBaseWebpackPartial = void 0;
4
+ const with_nx_1 = require("./with-nx");
5
+ const with_web_1 = require("./with-web");
6
+ /** @deprecated use withNx and withWeb plugins directly */
7
+ function getBaseWebpackPartial(options, context) {
8
+ const config = {};
9
+ const configure = composePluginsSync((0, with_nx_1.withNx)(), (0, with_web_1.withWeb)());
10
+ return configure(config, { options, context });
8
11
  }
9
- exports.isNxWebpackComposablePlugin = isNxWebpackComposablePlugin;
12
+ exports.getBaseWebpackPartial = getBaseWebpackPartial;
10
13
  function composePlugins(...plugins) {
11
- return Object.assign(async function combined(config, ctx) {
12
- // Webpack may be calling us as a standard config function.
13
- // Build up Nx context from environment variables.
14
- // This is to enable `@nx/webpack/plugin` to work with existing projects.
15
- if (ctx['env']) {
16
- ensureNxWebpackExecutionContext(ctx);
17
- // Build this from scratch since what webpack passes us is the env, not config,
18
- // and `withNX()` creates a new config object anyway.
19
- config = {};
20
- }
14
+ return async function combined(config, ctx) {
21
15
  for (const plugin of plugins) {
22
16
  const fn = await plugin;
23
17
  config = await fn(config, ctx);
24
18
  }
25
19
  return config;
26
- }, {
27
- [exports.nxWebpackComposablePlugin]: true,
28
- });
20
+ };
29
21
  }
30
22
  exports.composePlugins = composePlugins;
31
23
  function composePluginsSync(...plugins) {
32
- return Object.assign(function combined(config, ctx) {
24
+ return function combined(config, ctx) {
33
25
  for (const plugin of plugins) {
34
26
  config = plugin(config, ctx);
35
27
  }
36
28
  return config;
37
- }, {
38
- [exports.nxWebpackComposablePlugin]: true,
39
- });
40
- }
41
- exports.composePluginsSync = composePluginsSync;
42
- function ensureNxWebpackExecutionContext(ctx) {
43
- const projectName = process.env.NX_TASK_TARGET_PROJECT;
44
- const targetName = process.env.NX_TASK_TARGET_TARGET;
45
- const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
46
- const projectGraph = (0, devkit_1.readCachedProjectGraph)();
47
- const projectNode = projectGraph.nodes[projectName];
48
- ctx.options ??= {
49
- root: devkit_1.workspaceRoot,
50
- projectRoot: projectNode.data.root,
51
- sourceRoot: projectNode.data.sourceRoot ?? projectNode.data.root,
52
- // These aren't actually needed since NxWebpackPlugin and withNx both support them being undefined.
53
- assets: undefined,
54
- outputPath: undefined,
55
- tsConfig: undefined,
56
- outputFileName: undefined,
57
- };
58
- ctx.context ??= {
59
- projectName,
60
- targetName,
61
- configurationName,
62
- cwd: process.cwd(),
63
- root: devkit_1.workspaceRoot,
64
- isVerbose: process.env['NX_VERBOSE_LOGGING'] === 'true',
65
29
  };
66
30
  }
31
+ exports.composePluginsSync = composePluginsSync;
@@ -1,15 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getClientEnvironment = void 0;
4
- // Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
5
- // TODO(v19): Only env vars prefixed with NX_PUBLIC should be bundled. This is a breaking change so we won't do it in v18.
6
- const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
7
4
  function getClientEnvironment(mode) {
8
5
  // Grab NODE_ENV and NX_* environment variables and prepare them to be
9
6
  // injected into the application via DefinePlugin in webpack configuration.
10
7
  const NX_APP = /^NX_/i;
11
8
  const raw = Object.keys(process.env)
12
- .filter((key) => !excludedKeys.includes(key) && NX_APP.test(key))
9
+ .filter((key) => NX_APP.test(key))
13
10
  .reduce((env, key) => {
14
11
  env[key] = process.env[key];
15
12
  return env;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDependentPackagesForProject = void 0;
4
4
  const typescript_1 = require("./typescript");
5
- const devkit_1 = require("@nx/devkit");
6
5
  function getDependentPackagesForProject(projectGraph, name) {
7
6
  const { npmPackages, workspaceLibraries } = collectDependencies(projectGraph, name);
8
7
  return {
@@ -35,22 +34,11 @@ function collectDependencies(projectGraph, name, dependencies = {
35
34
  return dependencies;
36
35
  }
37
36
  function getLibraryImportPath(library, projectGraph) {
38
- let buildLibsFromSource = true;
39
- if (process.env.NX_BUILD_LIBS_FROM_SOURCE) {
40
- buildLibsFromSource = process.env.NX_BUILD_LIBS_FROM_SOURCE === 'true';
41
- }
42
- const libraryNode = projectGraph.nodes[library];
43
- let sourceRoots = [libraryNode.data.sourceRoot];
44
- if (!buildLibsFromSource && process.env.NX_BUILD_TARGET) {
45
- const buildTarget = (0, devkit_1.parseTargetString)(process.env.NX_BUILD_TARGET, projectGraph);
46
- sourceRoots = (0, devkit_1.getOutputsForTargetAndConfiguration)(buildTarget, {}, libraryNode);
47
- }
48
37
  const tsConfigPathMappings = (0, typescript_1.readTsPathMappings)();
38
+ const sourceRoot = projectGraph.nodes[library].data.sourceRoot;
49
39
  for (const [key, value] of Object.entries(tsConfigPathMappings)) {
50
- for (const src of sourceRoots) {
51
- if (value.find((path) => path.startsWith(src))) {
52
- return key;
53
- }
40
+ if (value.find((path) => path.startsWith(sourceRoot))) {
41
+ return key;
54
42
  }
55
43
  }
56
44
  return undefined;
@@ -55,7 +55,7 @@ function getRemotes(devRemotes, skipRemotes, config, context, pathToManifestFile
55
55
  : (0, find_matching_projects_1.findMatchingProjects)([devRemotes], context.projectGraph.nodes));
56
56
  const staticRemotes = knownRemotes.filter((r) => !devServeApps.has(r));
57
57
  const devServeRemotes = knownRemotes.filter((r) => devServeApps.has(r));
58
- const remotePorts = devServeRemotes.map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
58
+ const remotePorts = knownRemotes.map((r) => context.projectGraph.nodes[r].data.targets['serve'].options.port);
59
59
  return {
60
60
  staticRemotes,
61
61
  devRemotes: devServeRemotes,
@@ -39,7 +39,7 @@ function handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal) {
39
39
  : '';
40
40
  // if the remote is defined with anything other than http then we assume it's a promise based remote
41
41
  // In that case we should use what the user provides as the remote location
42
- if (!remoteLocation.startsWith('promise new Promise')) {
42
+ if (remoteLocation.startsWith('http')) {
43
43
  return `${globalPrefix}${baseRemote}/remoteEntry.${remoteEntryExt}`;
44
44
  }
45
45
  else {
@@ -6,7 +6,7 @@ const fs_1 = require("fs");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const nx_1 = require("@nx/devkit/nx");
8
8
  let { readModulePackageJson } = (0, nx_1.requireNx)();
9
- // TODO: Remove this in Nx 19 when Nx 16.7.0 is no longer supported
9
+ // TODO: Remove this in Nx 18 when Nx 16.7.0 is no longer supported
10
10
  readModulePackageJson =
11
11
  readModulePackageJson ??
12
12
  require('nx/src/utils/package-json').readModulePackageJson;
@@ -4,23 +4,18 @@ exports.getRootTsConfigPath = exports.readTsConfig = exports.readTsPathMappings
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const devkit_1 = require("@nx/devkit");
7
- let tsConfig = new Map();
8
- let tsPathMappings = new Map();
7
+ let tsConfig;
8
+ let tsPathMappings;
9
9
  function readTsPathMappings(tsConfigPath = process.env.NX_TSCONFIG_PATH ?? getRootTsConfigPath()) {
10
- if (tsPathMappings.has(tsConfigPath)) {
11
- return tsPathMappings.get(tsConfigPath);
10
+ if (tsPathMappings) {
11
+ return tsPathMappings;
12
12
  }
13
- if (!tsConfig.has(tsConfigPath)) {
14
- tsConfig.set(tsConfigPath, readTsConfiguration(tsConfigPath));
15
- }
16
- tsPathMappings.set(tsConfigPath, {});
17
- Object.entries(tsConfig.get(tsConfigPath).options?.paths ?? {}).forEach(([alias, paths]) => {
18
- tsPathMappings.set(tsConfigPath, {
19
- ...tsPathMappings.get(tsConfigPath),
20
- [alias]: paths.map((path) => path.replace(/^\.\//, '')),
21
- });
13
+ tsConfig ??= readTsConfiguration(tsConfigPath);
14
+ tsPathMappings = {};
15
+ Object.entries(tsConfig.options?.paths ?? {}).forEach(([alias, paths]) => {
16
+ tsPathMappings[alias] = paths.map((path) => path.replace(/^\.\//, ''));
22
17
  });
23
- return tsPathMappings.get(tsConfigPath);
18
+ return tsPathMappings;
24
19
  }
25
20
  exports.readTsPathMappings = readTsPathMappings;
26
21
  function readTsConfiguration(tsConfigPath) {
@@ -1,7 +1,6 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const swcLoaderVersion = "0.1.15";
3
3
  export declare const tsLibVersion = "^2.3.0";
4
- export declare const webpackCliVersion = "^5.1.4";
5
4
  export declare const reactRefreshWebpackPluginVersion = "^0.5.7";
6
5
  export declare const svgrWebpackVersion = "^8.0.1";
7
6
  export declare const reactRefreshVersion = "^0.10.0";
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.urlLoaderVersion = exports.reactRefreshVersion = exports.svgrWebpackVersion = exports.reactRefreshWebpackPluginVersion = exports.webpackCliVersion = exports.tsLibVersion = exports.swcLoaderVersion = exports.nxVersion = void 0;
3
+ exports.urlLoaderVersion = exports.reactRefreshVersion = exports.svgrWebpackVersion = exports.reactRefreshWebpackPluginVersion = exports.tsLibVersion = exports.swcLoaderVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.swcLoaderVersion = '0.1.15';
6
6
  exports.tsLibVersion = '^2.3.0';
7
- exports.webpackCliVersion = '^5.1.4';
8
7
  // React apps
9
8
  exports.reactRefreshWebpackPluginVersion = '^0.5.7';
10
9
  exports.svgrWebpackVersion = '^8.0.1';
@@ -0,0 +1,2 @@
1
+ export declare function resolveCustomWebpackConfig(path: string, tsConfig: string): any;
2
+ export declare function isRegistered(): boolean;
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveUserDefinedWebpackConfig = void 0;
3
+ exports.isRegistered = exports.resolveCustomWebpackConfig = void 0;
4
4
  const internal_1 = require("@nx/js/src/internal");
5
- function resolveUserDefinedWebpackConfig(path, tsConfig,
6
- /** Skip require cache and return latest content */
7
- reload = false) {
8
- if (reload) {
9
- // Clear cache if the path is in the cache
10
- if (require.cache[path]) {
11
- // Clear all entries because config may import other modules
12
- for (const k of Object.keys(require.cache)) {
13
- delete require.cache[k];
14
- }
15
- }
16
- }
5
+ function resolveCustomWebpackConfig(path, tsConfig) {
17
6
  // Don't transpile non-TS files. This prevents workspaces libs from being registered via tsconfig-paths.
18
7
  // There's an issue here with Nx workspace where loading plugins from source (via tsconfig-paths) can lead to errors.
19
8
  if (!/\.(ts|mts|cts)$/.test(path)) {
@@ -36,4 +25,9 @@ reload = false) {
36
25
  : maybeCustomWebpackConfig;
37
26
  return customWebpackConfig;
38
27
  }
39
- exports.resolveUserDefinedWebpackConfig = resolveUserDefinedWebpackConfig;
28
+ exports.resolveCustomWebpackConfig = resolveCustomWebpackConfig;
29
+ function isRegistered() {
30
+ return (require.extensions['.ts'] != undefined ||
31
+ require.extensions['.tsx'] != undefined);
32
+ }
33
+ exports.isRegistered = isRegistered;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const devkit_1 = require("@nx/devkit");
4
4
  // @ts-ignore
5
5
  const stylusLoader = require("stylus-loader");
6
- // TOOD(v19): Remove this file and stylus support.
6
+ // TOOD(v18): Remove this file and stylus support.
7
7
  function default_1(source) {
8
- devkit_1.logger.warn(`Stylus is support is deprecated and will be removed in Nx 19. We recommend that you migrate to Sass by renaming \`.styl\` files to \`.scss\` and ensuring that the content is valid Sass.`);
8
+ devkit_1.logger.warn(`Stylus is support is deprecated and will be removed in Nx 18. We recommend that you migrate to Sass by renaming \`.styl\` files to \`.scss\` and ensuring that the content is valid Sass.`);
9
9
  return stylusLoader.call(this, source);
10
10
  }
11
11
  exports.default = default_1;
@@ -7,11 +7,8 @@ function interpolateEnvironmentVariablesToIndex(contents, deployUrl) {
7
7
  }
8
8
  exports.interpolateEnvironmentVariablesToIndex = interpolateEnvironmentVariablesToIndex;
9
9
  const NX_PREFIX = /^NX_/i;
10
- // Prevent sensitive keys from being bundled when source code uses entire `process.env` object rather than individual keys (e.g. `process.env.NX_FOO`).
11
- // TODO(v19): Only env vars prefixed with NX_PUBLIC should be bundled. This is a breaking change so we won't do it in v18.
12
- const excludedKeys = ['NX_CLOUD_ACCESS_TOKEN', 'NX_CLOUD_ENCRYPTION_KEY'];
13
10
  function isNxEnvironmentKey(x) {
14
- return !excludedKeys.includes(x) && NX_PREFIX.test(x);
11
+ return NX_PREFIX.test(x);
15
12
  }
16
13
  function getClientEnvironment(deployUrl) {
17
14
  return Object.keys(process.env)
@@ -122,7 +122,7 @@ function PostcssCliResources(options) {
122
122
  const resourceCache = new Map();
123
123
  return Promise.all(urlDeclarations.map(async (decl) => {
124
124
  const value = decl.value;
125
- const urlRegex = /url(?:\(\s*(['"]?))(.*?)(?:\1\s*\))/g;
125
+ const urlRegex = /url\(\s*(?:"([^"]+)"|'([^']+)'|(.+?))\s*\)/g;
126
126
  const segments = [];
127
127
  let match;
128
128
  let lastIndex = 0;
@@ -131,7 +131,7 @@ function PostcssCliResources(options) {
131
131
  const inputFile = decl.source && decl.source.input.file;
132
132
  const context = (inputFile && path.dirname(inputFile)) || loader.context;
133
133
  while ((match = urlRegex.exec(value))) {
134
- const originalUrl = match[2];
134
+ const originalUrl = match[1] || match[2] || match[3];
135
135
  let processedUrl;
136
136
  try {
137
137
  processedUrl = await process(originalUrl, context, resourceCache);
@@ -1,8 +1,62 @@
1
- import { NxComposableWebpackPlugin } from './config';
2
- import { NxWebpackPluginOptions } from '../plugins/nx-webpack-plugin/nx-webpack-plugin-options';
3
- export type WithNxOptions = Partial<NxWebpackPluginOptions>;
1
+ import { NormalizedWebpackExecutorOptions } from '../executors/webpack/schema';
2
+ import { NxWebpackPlugin } from './config';
3
+ export interface WithNxOptions {
4
+ skipTypeChecking?: boolean;
5
+ }
4
6
  /**
5
7
  * @param {WithNxOptions} pluginOptions
6
8
  * @returns {NxWebpackPlugin}
7
9
  */
8
- export declare function withNx(pluginOptions?: WithNxOptions): NxComposableWebpackPlugin;
10
+ export declare function withNx(pluginOptions?: WithNxOptions): NxWebpackPlugin;
11
+ export declare function createLoaderFromCompiler(options: NormalizedWebpackExecutorOptions): {
12
+ test: RegExp;
13
+ loader: string;
14
+ exclude: RegExp;
15
+ options: {
16
+ cwd: string;
17
+ emitDecoratorMetadata: boolean;
18
+ isModern: boolean;
19
+ isTest: boolean;
20
+ envName: string;
21
+ cacheDirectory: boolean;
22
+ cacheCompression: boolean;
23
+ };
24
+ } | {
25
+ test: RegExp;
26
+ loader: string;
27
+ exclude: RegExp;
28
+ options: {
29
+ jsc: {
30
+ parser: {
31
+ syntax: string;
32
+ decorators: boolean;
33
+ tsx: boolean;
34
+ };
35
+ transform: {
36
+ react: {
37
+ runtime: string;
38
+ };
39
+ };
40
+ loose: boolean;
41
+ };
42
+ configFile?: undefined;
43
+ transpileOnly?: undefined;
44
+ experimentalWatchApi?: undefined;
45
+ getCustomTransformers?: undefined;
46
+ };
47
+ } | {
48
+ test: RegExp;
49
+ loader: string;
50
+ exclude: RegExp;
51
+ options: {
52
+ configFile: string;
53
+ transpileOnly: boolean;
54
+ experimentalWatchApi: boolean;
55
+ getCustomTransformers: (program: any) => {
56
+ before: any;
57
+ after: any;
58
+ afterDeclarations: any;
59
+ };
60
+ jsc?: undefined;
61
+ };
62
+ };