@nx/webpack 17.0.0-beta.2 → 17.0.0-beta.4

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/executors.json CHANGED
@@ -1,21 +1,4 @@
1
1
  {
2
- "builders": {
3
- "webpack": {
4
- "implementation": "./src/executors/webpack/compat",
5
- "schema": "./src/executors/webpack/schema.json",
6
- "description": "Run webpack build."
7
- },
8
- "dev-server": {
9
- "implementation": "./src/executors/dev-server/compat",
10
- "schema": "./src/executors/dev-server/schema.json",
11
- "description": "Serve a web application."
12
- },
13
- "ssr-dev-server": {
14
- "implementation": "./src/executors/ssr-dev-server/compat",
15
- "schema": "./src/executors/ssr-dev-server/schema.json",
16
- "description": "Serve a SSR application."
17
- }
18
- },
19
2
  "executors": {
20
3
  "webpack": {
21
4
  "implementation": "./src/executors/webpack/webpack.impl",
package/generators.json CHANGED
@@ -1,21 +1,6 @@
1
1
  {
2
2
  "name": "Nx Webpack",
3
3
  "version": "0.1",
4
- "schematics": {
5
- "init": {
6
- "factory": "./src/generators/init/init#webpackInitSchematic",
7
- "schema": "./src/generators/init/schema.json",
8
- "description": "Initialize the `@nrwl/webpack` plugin.",
9
- "hidden": true
10
- },
11
- "configuration": {
12
- "aliases": ["webpack-project"],
13
- "factory": "./src/generators/configuration/configuration#compat",
14
- "schema": "./src/generators/configuration/schema.json",
15
- "description": "Add webpack configuration to a project.",
16
- "hidden": true
17
- }
18
- },
19
4
  "generators": {
20
5
  "init": {
21
6
  "factory": "./src/generators/init/init#webpackInitGenerator",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "17.0.0-beta.2",
3
+ "version": "17.0.0-beta.4",
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": {
@@ -22,8 +22,8 @@
22
22
  "url": "https://github.com/nrwl/nx/issues"
23
23
  },
24
24
  "homepage": "https://nx.dev",
25
- "schematics": "./generators.json",
26
- "builders": "./executors.json",
25
+ "generators": "./generators.json",
26
+ "executors": "./executors.json",
27
27
  "ng-update": {
28
28
  "requirements": {},
29
29
  "migrations": "./migrations.json"
@@ -52,8 +52,6 @@
52
52
  "sass-loader": "^12.2.0",
53
53
  "source-map-loader": "^3.0.0",
54
54
  "style-loader": "^3.3.0",
55
- "stylus": "^0.59.0",
56
- "stylus-loader": "^7.1.0",
57
55
  "terser-webpack-plugin": "^5.3.3",
58
56
  "ts-loader": "^9.3.1",
59
57
  "tsconfig-paths-webpack-plugin": "4.0.0",
@@ -62,9 +60,9 @@
62
60
  "webpack-dev-server": "^4.9.3",
63
61
  "webpack-node-externals": "^3.0.0",
64
62
  "webpack-subresource-integrity": "^5.1.0",
65
- "@nx/devkit": "17.0.0-beta.2",
66
- "@nx/js": "17.0.0-beta.2",
67
- "@nrwl/webpack": "17.0.0-beta.2"
63
+ "@nx/devkit": "17.0.0-beta.4",
64
+ "@nx/js": "17.0.0-beta.4",
65
+ "@nrwl/webpack": "17.0.0-beta.4"
68
66
  },
69
67
  "publishConfig": {
70
68
  "access": "public"
@@ -15,7 +15,7 @@ async function* ssrDevServerExecutor(options, context) {
15
15
  let browserBuilt = false;
16
16
  let nodeStarted = false;
17
17
  const combined = (0, async_iterable_1.combineAsyncIterables)(runBrowser, runServer);
18
- process.env['port'] = `${options.port}`;
18
+ process.env['PORT'] = `${options.port}`;
19
19
  for await (const output of combined) {
20
20
  if (!output.success)
21
21
  throw new Error('Could not build application');
@@ -12,13 +12,15 @@ const run_webpack_1 = require("./lib/run-webpack");
12
12
  const fs_1 = require("../../utils/fs");
13
13
  const custom_webpack_1 = require("../../utils/webpack/custom-webpack");
14
14
  const normalize_options_1 = require("./lib/normalize-options");
15
- async function getWebpackConfigs(options, context) {
15
+ async function getWebpackConfigs(options, projectRoot, context) {
16
16
  if (options.isolatedConfig && !options.webpackConfig) {
17
17
  throw new Error(`Using "isolatedConfig" without a "webpackConfig" is not supported.`);
18
18
  }
19
19
  let customWebpack = null;
20
20
  if (options.webpackConfig) {
21
- customWebpack = (0, custom_webpack_1.resolveCustomWebpackConfig)(options.webpackConfig, options.tsConfig);
21
+ customWebpack = (0, custom_webpack_1.resolveCustomWebpackConfig)(options.webpackConfig, options.tsConfig.startsWith(context.root)
22
+ ? options.tsConfig
23
+ : (0, path_1.join)(context.root, options.tsConfig));
22
24
  if (typeof customWebpack.then === 'function') {
23
25
  customWebpack = await customWebpack;
24
26
  }
@@ -76,7 +78,7 @@ async function* webpackExecutor(_options, context) {
76
78
  devkit_1.logger.warn((0, devkit_1.stripIndents) `The project ${context.projectName} is using the 'generatePackageJson' option which is deprecated for library projects. It should only be used for applications.
77
79
  For libraries, configure the project to use the '@nx/dependency-checks' ESLint rule instead (https://nx.dev/packages/eslint-plugin/documents/dependency-checks).`);
78
80
  }
79
- const configs = await getWebpackConfigs(options, context);
81
+ const configs = await getWebpackConfigs(options, metadata.root, context);
80
82
  return yield* (0, rxjs_for_await_1.eachValueFrom)((0, rxjs_1.of)(configs).pipe((0, operators_1.mergeMap)((config) => (Array.isArray(config) ? (0, rxjs_1.from)(config) : (0, rxjs_1.of)(config))),
81
83
  // Run build sequentially and bail when first one fails.
82
84
  (0, operators_1.mergeScan)((acc, config) => {
@@ -2,4 +2,3 @@ import type { Tree } from '@nx/devkit';
2
2
  import { ConfigurationGeneratorSchema } from './schema';
3
3
  export declare function configurationGenerator(tree: Tree, options: ConfigurationGeneratorSchema): Promise<import("@nx/devkit").GeneratorCallback>;
4
4
  export default configurationGenerator;
5
- export declare const compat: (generatorOptions: ConfigurationGeneratorSchema) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compat = exports.configurationGenerator = void 0;
3
+ exports.configurationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const init_1 = require("../init/init");
6
6
  async function configurationGenerator(tree, options) {
@@ -120,4 +120,3 @@ function addServeTarget(tree, options) {
120
120
  });
121
121
  }
122
122
  exports.default = configurationGenerator;
123
- exports.compat = (0, devkit_1.convertNxGenerator)(configurationGenerator);
@@ -2,4 +2,3 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function webpackInitGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
4
  export default webpackInitGenerator;
5
- export declare const webpackInitSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webpackInitSchematic = exports.webpackInitGenerator = void 0;
3
+ exports.webpackInitGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const add_swc_dependencies_1 = require("@nx/js/src/utils/swc/add-swc-dependencies");
6
6
  const versions_1 = require("../../utils/versions");
@@ -33,4 +33,3 @@ async function webpackInitGenerator(tree, schema) {
33
33
  }
34
34
  exports.webpackInitGenerator = webpackInitGenerator;
35
35
  exports.default = webpackInitGenerator;
36
- exports.webpackInitSchematic = (0, devkit_1.convertNxGenerator)(webpackInitGenerator);
@@ -5,7 +5,7 @@ const path_1 = require("path");
5
5
  const loader_utils_1 = require("loader-utils");
6
6
  function getCSSModuleLocalIdent(ctx, localIdentName, localName, options) {
7
7
  // Use the filename or folder name, based on some uses the index.js / index.module.(css|scss|sass) project style
8
- const fileNameOrFolder = ctx.resourcePath.match(/index\.module\.(css|scss|sass|styl)$/)
8
+ const fileNameOrFolder = ctx.resourcePath.match(/index\.module\.(css|scss|sass)$/)
9
9
  ? '[folder]'
10
10
  : '[name]';
11
11
  // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique.
@@ -13,7 +13,7 @@ export type SharedWorkspaceLibraryConfig = {
13
13
  getLibraries: (projectRoot: string, eager?: boolean) => Record<string, SharedLibraryConfig>;
14
14
  getReplacementPlugin: () => NormalModuleReplacementPlugin;
15
15
  };
16
- export type Remotes = string[] | [remoteName: string, remoteUrl: string][];
16
+ export type Remotes = Array<string | [remoteName: string, remoteUrl: string]>;
17
17
  export interface SharedLibraryConfig {
18
18
  singleton?: boolean;
19
19
  strictVersion?: boolean;
@@ -37,7 +37,14 @@ function handleArrayRemote(remote, remoteEntryExt, isRemoteGlobal) {
37
37
  const globalPrefix = isRemoteGlobal
38
38
  ? `${remoteName.replace(/-/g, '_')}@`
39
39
  : '';
40
- return `${globalPrefix}${baseRemote}/remoteEntry.${remoteEntryExt}`;
40
+ // if the remote is defined with anything other than http then we assume it's a promise based remote
41
+ // In that case we should use what the user provides as the remote location
42
+ if (remoteLocation.startsWith('http')) {
43
+ return `${globalPrefix}${baseRemote}/remoteEntry.${remoteEntryExt}`;
44
+ }
45
+ else {
46
+ return remoteLocation;
47
+ }
41
48
  }
42
49
  // Helper function to deal with remotes that are strings
43
50
  function handleStringRemote(remote, determineRemoteUrl, isRemoteGlobal) {
@@ -3,15 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isRegistered = exports.resolveCustomWebpackConfig = void 0;
4
4
  const internal_1 = require("@nx/js/src/internal");
5
5
  function resolveCustomWebpackConfig(path, tsConfig) {
6
+ // Don't transpile non-TS files. This prevents workspaces libs from being registered via tsconfig-paths.
7
+ // There's an issue here with Nx workspace where loading plugins from source (via tsconfig-paths) can lead to errors.
8
+ if (!/\.(ts|mts|cts)$/.test(path)) {
9
+ return require(path);
10
+ }
6
11
  const cleanupTranspiler = (0, internal_1.registerTsProject)(tsConfig);
7
- const customWebpackConfig = require(path);
12
+ const maybeCustomWebpackConfig = require(path);
8
13
  cleanupTranspiler();
9
14
  // If the user provides a configuration in TS file
10
- // then there are 2 cases for exporing an object. The first one is:
15
+ // then there are 3 cases for exporing an object. The first one is:
11
16
  // `module.exports = { ... }`. And the second one is:
12
17
  // `export default { ... }`. The ESM format is compiled into:
13
18
  // `{ default: { ... } }`
14
- return customWebpackConfig.default || customWebpackConfig;
19
+ // There is also a case of
20
+ // `{ default: { default: { ... } }`
21
+ const customWebpackConfig = 'default' in maybeCustomWebpackConfig
22
+ ? 'default' in maybeCustomWebpackConfig.default
23
+ ? maybeCustomWebpackConfig.default.default
24
+ : maybeCustomWebpackConfig.default
25
+ : maybeCustomWebpackConfig;
26
+ return customWebpackConfig;
15
27
  }
16
28
  exports.resolveCustomWebpackConfig = resolveCustomWebpackConfig;
17
29
  function isRegistered() {
@@ -57,7 +57,7 @@ function withWeb(pluginOptions = {}) {
57
57
  ];
58
58
  if (stylesOptimization) {
59
59
  minimizer.push(new CssMinimizerPlugin({
60
- test: /\.(?:css|scss|sass|less|styl)$/,
60
+ test: /\.(?:css|scss|sass|less)$/,
61
61
  }));
62
62
  }
63
63
  if (!pluginOptions.ssr) {
@@ -131,21 +131,6 @@ function withWeb(pluginOptions = {}) {
131
131
  },
132
132
  ],
133
133
  },
134
- {
135
- test: /\.module\.styl$/,
136
- exclude: globalStylePaths,
137
- use: [
138
- ...getCommonLoadersForCssModules(mergedOptions, includePaths),
139
- {
140
- loader: require.resolve('stylus-loader'),
141
- options: {
142
- stylusOptions: {
143
- include: includePaths,
144
- },
145
- },
146
- },
147
- ],
148
- },
149
134
  ];
150
135
  const globalCssRules = [
151
136
  {
@@ -190,22 +175,6 @@ function withWeb(pluginOptions = {}) {
190
175
  },
191
176
  ],
192
177
  },
193
- {
194
- test: /\.styl$/,
195
- exclude: globalStylePaths,
196
- use: [
197
- ...getCommonLoadersForGlobalCss(mergedOptions, includePaths),
198
- {
199
- loader: require.resolve('stylus-loader'),
200
- options: {
201
- sourceMap: !!mergedOptions.sourceMap,
202
- stylusOptions: {
203
- include: includePaths,
204
- },
205
- },
206
- },
207
- ],
208
- },
209
178
  ];
210
179
  const globalStyleRules = [
211
180
  {
@@ -250,26 +219,10 @@ function withWeb(pluginOptions = {}) {
250
219
  },
251
220
  ],
252
221
  },
253
- {
254
- test: /\.styl$/,
255
- include: globalStylePaths,
256
- use: [
257
- ...getCommonLoadersForGlobalStyle(mergedOptions, includePaths),
258
- {
259
- loader: require.resolve('stylus-loader'),
260
- options: {
261
- sourceMap: !!mergedOptions.sourceMap,
262
- stylusOptions: {
263
- include: includePaths,
264
- },
265
- },
266
- },
267
- ],
268
- },
269
222
  ];
270
223
  const rules = [
271
224
  {
272
- test: /\.css$|\.scss$|\.sass$|\.less$|\.styl$/,
225
+ test: /\.css$|\.scss$|\.sass$|\.less$/,
273
226
  oneOf: [...cssModuleRules, ...globalCssRules, ...globalStyleRules],
274
227
  },
275
228
  ];
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const dev_server_impl_1 = require("./dev-server.impl");
5
- exports.default = (0, devkit_1.convertNxExecutor)(dev_server_impl_1.default);
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const ssr_dev_server_impl_1 = require("./ssr-dev-server.impl");
5
- exports.default = (0, devkit_1.convertNxExecutor)(ssr_dev_server_impl_1.default);
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const webpack_impl_1 = require("./webpack.impl");
5
- exports.default = (0, devkit_1.convertNxExecutor)(webpack_impl_1.webpackExecutor);