@nx/webpack 19.0.0 → 19.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "19.0.0",
3
+ "version": "19.0.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.",
6
6
  "repository": {
@@ -63,9 +63,9 @@
63
63
  "webpack-dev-server": "^4.9.3",
64
64
  "webpack-node-externals": "^3.0.0",
65
65
  "webpack-subresource-integrity": "^5.1.0",
66
- "@nx/devkit": "19.0.0",
67
- "@nx/js": "19.0.0",
68
- "@nrwl/webpack": "19.0.0"
66
+ "@nx/devkit": "19.0.2",
67
+ "@nx/js": "19.0.2",
68
+ "@nrwl/webpack": "19.0.2"
69
69
  },
70
70
  "publishConfig": {
71
71
  "access": "public"
@@ -84,6 +84,8 @@ export interface WebpackExecutorOptions {
84
84
  stylePreprocessorOptions?: any;
85
85
  styles?: Array<ExtraEntryPointClass | string>;
86
86
  subresourceIntegrity?: boolean;
87
+ publicPath?: string;
88
+ rebaseRootRelative?: boolean;
87
89
  }
88
90
 
89
91
  export interface NormalizedWebpackExecutorOptions
@@ -235,7 +235,7 @@
235
235
  "type": "boolean",
236
236
  "description": "Do not apply Nx webpack plugins automatically. Plugins need to be applied in the project's webpack.config.js file (e.g. withNx, withReact, etc.).",
237
237
  "default": true,
238
- "x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 19. See https://nx.dev/recipes/webpack/webpack-config-setup."
238
+ "x-deprecated": "Automatic configuration of Webpack is deprecated in favor of an explicit 'webpack.config.js' file. This option will be removed in Nx 20. See https://nx.dev/recipes/webpack/webpack-config-setup."
239
239
  },
240
240
  "standardWebpackConfigFunction": {
241
241
  "type": "boolean",
@@ -299,6 +299,14 @@
299
299
  "type": "string",
300
300
  "description": "Path to the babel configuration file of your project. If not provided, Nx will default to the .babelrc file at the root of your project. See https://babeljs.io/docs/en/config-files",
301
301
  "x-completion-type": "file"
302
+ },
303
+ "publicPath": {
304
+ "type": "string",
305
+ "description": "Set a public path for assets resources with absolute paths."
306
+ },
307
+ "rebaseRootRelative": {
308
+ "type": "boolean",
309
+ "description": "Whether to rebase absolute path for assets in postcss cli resources."
302
310
  }
303
311
  },
304
312
  "required": [],
@@ -68,27 +68,22 @@ function applyNxIndependentConfig(options, config) {
68
68
  : false;
69
69
  config.output = {
70
70
  ...config.output,
71
- libraryTarget: (config.output?.libraryTarget ??
72
- options.target === 'node')
73
- ? 'commonjs'
74
- : undefined,
71
+ libraryTarget: config.output?.libraryTarget ??
72
+ (options.target === 'node' ? 'commonjs' : undefined),
75
73
  path: config.output?.path ??
76
74
  (options.outputPath
77
75
  ? path.join(options.root, options.outputPath)
78
76
  : undefined),
79
- filename: config.output?.filename ?? options.outputHashing
80
- ? `[name]${hashFormat.script}.js`
81
- : '[name].js',
82
- chunkFilename: config.output?.chunkFilename ?? options.outputHashing
83
- ? `[name]${hashFormat.chunk}.js`
84
- : '[name].js',
77
+ filename: config.output?.filename ??
78
+ (options.outputHashing ? `[name]${hashFormat.script}.js` : '[name].js'),
79
+ chunkFilename: config.output?.chunkFilename ??
80
+ (options.outputHashing ? `[name]${hashFormat.chunk}.js` : '[name].js'),
85
81
  hashFunction: config.output?.hashFunction ?? 'xxhash64',
86
82
  // Disabled for performance
87
83
  pathinfo: config.output?.pathinfo ?? false,
88
84
  // Use CJS for Node since it has the widest support.
89
- scriptType: config.output?.scriptType ?? options.target === 'node'
90
- ? undefined
91
- : 'module',
85
+ scriptType: config.output?.scriptType ??
86
+ (options.target === 'node' ? undefined : 'module'),
92
87
  };
93
88
  config.watch = options.watch;
94
89
  config.watchOptions = {
@@ -46,14 +46,18 @@ function createLoaderFromCompiler(options) {
46
46
  },
47
47
  };
48
48
  case 'babel':
49
- const tsConfig = (0, js_1.readTsConfig)(path.join(options.root, options.tsConfig));
49
+ const tsConfig = options.tsConfig
50
+ ? (0, js_1.readTsConfig)(path.join(options.root, options.tsConfig))
51
+ : undefined;
50
52
  const babelConfig = {
51
53
  test: /\.([jt])sx?$/,
52
54
  loader: path.join(__dirname, '../../../utils/web-babel-loader'),
53
55
  exclude: /node_modules/,
54
56
  options: {
55
57
  cwd: path.join(options.root, options.sourceRoot),
56
- emitDecoratorMetadata: tsConfig.options.emitDecoratorMetadata,
58
+ emitDecoratorMetadata: tsConfig
59
+ ? tsConfig.options.emitDecoratorMetadata
60
+ : false,
57
61
  isModern: true,
58
62
  isTest: process.env.NX_CYPRESS_COMPONENT_TEST === 'true',
59
63
  envName: process.env.BABEL_ENV ?? process.env.NODE_ENV,
@@ -103,6 +103,8 @@ function postcssOptionsCreator(options, { includePaths, forCssModules = false, }
103
103
  deployUrl: options.deployUrl,
104
104
  loader,
105
105
  filename: `[name]${hashFormat.file}.[ext]`,
106
+ publicPath: options.publicPath,
107
+ rebaseRootRelative: options.rebaseRootRelative,
106
108
  }),
107
109
  autoprefixer(),
108
110
  ]),
@@ -202,6 +202,14 @@ export interface NxAppWebpackPluginOptions {
202
202
  * Watch for file changes.
203
203
  */
204
204
  watch?: boolean;
205
+ /**
206
+ * Set a public path for assets resources with absolute paths.
207
+ */
208
+ publicPath?: string;
209
+ /**
210
+ * Whether to rebase absolute path for assets in postcss cli resources.
211
+ */
212
+ rebaseRootRelative?: boolean;
205
213
  }
206
214
  export interface NormalizedNxAppWebpackPluginOptions extends NxAppWebpackPluginOptions {
207
215
  projectName: string;
@@ -22,15 +22,22 @@ function shareWorkspaceLibraries(workspaceLibs, tsConfigPath = process.env.NX_TS
22
22
  if (!Object.keys(tsconfigPathAliases).length) {
23
23
  return getEmptySharedLibrariesConfig();
24
24
  }
25
+ // Nested projects must come first, sort them as such
26
+ const sortedTsConfigPathAliases = {};
27
+ Object.keys(tsconfigPathAliases)
28
+ .sort((a, b) => {
29
+ return b.split('/').length - a.split('/').length;
30
+ })
31
+ .forEach((key) => (sortedTsConfigPathAliases[key] = tsconfigPathAliases[key]));
25
32
  const pathMappings = [];
26
- for (const [key, paths] of Object.entries(tsconfigPathAliases)) {
33
+ for (const [key, paths] of Object.entries(sortedTsConfigPathAliases)) {
27
34
  const library = workspaceLibs.find((lib) => lib.importKey === key);
28
35
  if (!library) {
29
36
  continue;
30
37
  }
31
38
  // This is for Angular Projects that use ng-package.json
32
39
  // It will do nothing for React Projects
33
- (0, secondary_entry_points_1.collectWorkspaceLibrarySecondaryEntryPoints)(library, tsconfigPathAliases).forEach(({ name, path }) => pathMappings.push({
40
+ (0, secondary_entry_points_1.collectWorkspaceLibrarySecondaryEntryPoints)(library, sortedTsConfigPathAliases).forEach(({ name, path }) => pathMappings.push({
34
41
  name,
35
42
  path,
36
43
  }));
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const stylusLoader = require("stylus-loader");
6
6
  // TOOD(v19): 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 20. 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;
@@ -6,6 +6,7 @@ export interface PostcssCliResourcesOptions {
6
6
  rebaseRootRelative?: boolean;
7
7
  filename: string;
8
8
  loader: LoaderContext<unknown>;
9
+ publicPath: string;
9
10
  }
10
11
  export declare function PostcssCliResources(options: PostcssCliResourcesOptions): {
11
12
  postcssPlugin: string;
@@ -25,7 +25,7 @@ async function resolve(file, base, resolver) {
25
25
  }
26
26
  module.exports.postcss = true;
27
27
  function PostcssCliResources(options) {
28
- const { deployUrl = '', baseHref = '', resourcesOutputPath = '', rebaseRootRelative = false, filename, loader, } = options;
28
+ const { deployUrl = '', baseHref = '', resourcesOutputPath = '', rebaseRootRelative = false, filename, loader, publicPath = '', } = options;
29
29
  const dedupeSlashes = (url) => url.replace(/\/\/+/g, '/');
30
30
  const process = async (inputUrl, context, resourceCache) => {
31
31
  // If root-relative, absolute or protocol relative url, leave as is
@@ -62,7 +62,7 @@ function PostcssCliResources(options) {
62
62
  }
63
63
  else {
64
64
  // Join together base-href, deploy-url and the original URL.
65
- outputUrl = dedupeSlashes(`/${baseHref}/${deployUrl}/${inputUrl}`);
65
+ outputUrl = dedupeSlashes(`/${baseHref}/${deployUrl}/${publicPath}/${inputUrl}`);
66
66
  }
67
67
  resourceCache.set(cacheKey, outputUrl);
68
68
  return outputUrl;