@nx/webpack 17.2.4 → 17.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/webpack",
3
- "version": "17.2.4",
3
+ "version": "17.2.6",
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": {
@@ -62,9 +62,9 @@
62
62
  "webpack-dev-server": "^4.9.3",
63
63
  "webpack-node-externals": "^3.0.0",
64
64
  "webpack-subresource-integrity": "^5.1.0",
65
- "@nx/devkit": "17.2.4",
66
- "@nx/js": "17.2.4",
67
- "@nrwl/webpack": "17.2.4"
65
+ "@nx/devkit": "17.2.6",
66
+ "@nx/js": "17.2.6",
67
+ "@nrwl/webpack": "17.2.6"
68
68
  },
69
69
  "publishConfig": {
70
70
  "access": "public"
@@ -18,6 +18,8 @@ async function* devServerExecutor(serveOptions, context) {
18
18
  process.env.NODE_ENV ??= 'development';
19
19
  const { root: projectRoot, sourceRoot } = context.projectsConfigurations.projects[context.projectName];
20
20
  const buildOptions = (0, normalize_options_1.normalizeOptions)(getBuildOptions(serveOptions, context), context.root, projectRoot, sourceRoot);
21
+ process.env.NX_BUILD_LIBS_FROM_SOURCE = `${buildOptions.buildLibsFromSource}`;
22
+ process.env.NX_BUILD_TARGET = serveOptions.buildTarget;
21
23
  // TODO(jack): Figure out a way to port this into NxWebpackPlugin
22
24
  if (!buildOptions.buildLibsFromSource) {
23
25
  if (!buildOptions.tsConfig) {
@@ -26,6 +28,7 @@ async function* devServerExecutor(serveOptions, context) {
26
28
  const { target, dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, 'build', // should be generalized
27
29
  context.configurationName);
28
30
  buildOptions.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(buildOptions.tsConfig, context.root, target.data.root, dependencies);
31
+ process.env.NX_TSCONFIG_PATH = buildOptions.tsConfig;
29
32
  }
30
33
  let config;
31
34
  const devServer = (0, get_dev_server_config_1.getDevServerOptions)(context.root, serveOptions, buildOptions);
@@ -64,6 +64,12 @@ async function* webpackExecutor(_options, context) {
64
64
  process.env.NODE_ENV ||= isScriptOptimizeOn
65
65
  ? 'production'
66
66
  : 'development';
67
+ process.env.NX_BUILD_LIBS_FROM_SOURCE = `${options.buildLibsFromSource}`;
68
+ process.env.NX_BUILD_TARGET = (0, devkit_1.targetToTargetString)({
69
+ project: context.projectName,
70
+ target: context.targetName,
71
+ configuration: context.configurationName,
72
+ });
67
73
  if (options.compiler === 'swc') {
68
74
  try {
69
75
  require.resolve('swc-loader');
@@ -80,6 +86,7 @@ async function* webpackExecutor(_options, context) {
80
86
  if (!options.buildLibsFromSource && context.targetName) {
81
87
  const { dependencies } = (0, buildable_libs_utils_1.calculateProjectBuildableDependencies)(context.taskGraph, context.projectGraph, context.root, context.projectName, context.targetName, context.configurationName);
82
88
  options.tsConfig = (0, buildable_libs_utils_1.createTmpTsConfig)(options.tsConfig, context.root, metadata.root, dependencies);
89
+ process.env.NX_TSCONFIG_PATH = options.tsConfig;
83
90
  }
84
91
  // Delete output path before bundling
85
92
  if (options.deleteOutputPath && options.outputPath) {
@@ -2,6 +2,7 @@
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");
5
6
  function getDependentPackagesForProject(projectGraph, name) {
6
7
  const { npmPackages, workspaceLibraries } = collectDependencies(projectGraph, name);
7
8
  return {
@@ -34,11 +35,22 @@ function collectDependencies(projectGraph, name, dependencies = {
34
35
  return dependencies;
35
36
  }
36
37
  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
+ }
37
48
  const tsConfigPathMappings = (0, typescript_1.readTsPathMappings)();
38
- const sourceRoot = projectGraph.nodes[library].data.sourceRoot;
39
49
  for (const [key, value] of Object.entries(tsConfigPathMappings)) {
40
- if (value.find((path) => path.startsWith(sourceRoot))) {
41
- return key;
50
+ for (const src of sourceRoots) {
51
+ if (value.find((path) => path.startsWith(src))) {
52
+ return key;
53
+ }
42
54
  }
43
55
  }
44
56
  return undefined;
@@ -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('http')) {
42
+ if (!remoteLocation.startsWith('promise new Promise')) {
43
43
  return `${globalPrefix}${baseRemote}/remoteEntry.${remoteEntryExt}`;
44
44
  }
45
45
  else {