@nx/js 16.7.0-beta.4 → 16.7.0-beta.5

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/js",
3
- "version": "16.7.0-beta.4",
3
+ "version": "16.7.0-beta.5",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "@babel/preset-env": "^7.22.9",
40
40
  "@babel/preset-typescript": "^7.22.5",
41
41
  "@babel/runtime": "^7.22.6",
42
- "@nrwl/js": "16.7.0-beta.4",
43
- "@nx/devkit": "16.7.0-beta.4",
44
- "@nx/workspace": "16.7.0-beta.4",
42
+ "@nrwl/js": "16.7.0-beta.5",
43
+ "@nx/devkit": "16.7.0-beta.5",
44
+ "@nx/workspace": "16.7.0-beta.5",
45
45
  "@phenomnomnominal/tsquery": "~5.0.1",
46
46
  "babel-plugin-const-enum": "^1.0.1",
47
47
  "babel-plugin-macros": "^2.8.0",
@@ -71,5 +71,5 @@
71
71
  "access": "public"
72
72
  },
73
73
  "type": "commonjs",
74
- "gitHead": "dcbba686b182737b66ebbfb9db372769e77ba005"
74
+ "gitHead": "fa513731d4e6a960f112a5af6b0d725b2e624b36"
75
75
  }
@@ -36,12 +36,18 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
36
36
  }
37
37
  }
38
38
  const files = (0, assets_1.assetGlobsToFiles)(options.assets, root, outputPath);
39
+ const projectRootParts = projectRoot.split('/');
40
+ // We pop the last part of the `projectRoot` to pass
41
+ // the last part (projectDir) and the remainder (projectRootParts) to swc
42
+ const projectDir = projectRootParts.pop();
43
+ // default to current directory if projectRootParts is [].
44
+ // Eg: when a project is at the root level, outside of layout dir
45
+ const swcCwd = projectRootParts.join('/') || '.';
39
46
  const swcrcPath = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
40
- // TODO(meeroslav): Check why this is needed in order for swc to properly nest folders
41
- const distParent = outputPath.split('/').slice(0, -1).join('/');
42
47
  const swcCliOptions = {
43
- srcPath: projectRoot,
44
- destPath: (0, path_1.relative)(root, distParent),
48
+ srcPath: projectDir,
49
+ destPath: (0, path_1.relative)((0, path_1.join)(root, swcCwd), outputPath),
50
+ swcCwd,
45
51
  swcrcPath,
46
52
  };
47
53
  return Object.assign(Object.assign({}, options), { mainOutputPath: (0, path_1.resolve)(outputPath, options.main.replace(`${projectRoot}/`, '').replace('.ts', '.js')), files,
@@ -64,8 +70,13 @@ function swcExecutor(_options, context) {
64
70
  const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, options.tsConfig);
65
71
  if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
66
72
  options.projectRoot = '.'; // set to root of workspace to include other libs for type check
67
- options.swcCliOptions.srcPath = root.split('/').slice(0, -1).join('/'); // set to root of libraries to include other libs
68
- options.swcCliOptions.destPath = (0, path_1.join)(_options.outputPath, options.swcCliOptions.srcPath); // new destPath is dist/{libs}/{parentLib}/{libs}
73
+ // remap paths for SWC compilation
74
+ options.swcCliOptions.srcPath = options.swcCliOptions.swcCwd;
75
+ options.swcCliOptions.swcCwd = '.';
76
+ options.swcCliOptions.destPath = options.swcCliOptions.destPath
77
+ .split('../')
78
+ .at(-1)
79
+ .concat('/', options.swcCliOptions.srcPath);
69
80
  // tmp swcrc with dependencies to exclude
70
81
  // - buildable libraries
71
82
  // - other libraries that are not dependent on the current project
@@ -349,7 +349,7 @@ function normalizeOptions(tree, options) {
349
349
  if (!options.linter && options.config !== 'npm-scripts') {
350
350
  options.linter = Linter.EsLint;
351
351
  }
352
- const { projectName, names: projectNames, projectDirectory, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
352
+ const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
353
353
  name: options.name,
354
354
  projectType: 'library',
355
355
  directory: options.directory,
@@ -357,7 +357,7 @@ function normalizeOptions(tree, options) {
357
357
  projectNameAndRootFormat: options.projectNameAndRootFormat,
358
358
  rootProject: options.rootProject,
359
359
  });
360
- options.rootProject = projectDirectory === '.';
360
+ options.rootProject = projectRoot === '.';
361
361
  const fileName = getCaseAwareFileName({
362
362
  fileName: options.simpleName
363
363
  ? projectNames.projectSimpleName
@@ -368,7 +368,9 @@ function normalizeOptions(tree, options) {
368
368
  ? options.tags.split(',').map((s) => s.trim())
369
369
  : [];
370
370
  (_c = options.minimal) !== null && _c !== void 0 ? _c : (options.minimal = false);
371
- return Object.assign(Object.assign({}, options), { fileName, name: projectName, projectNames, projectRoot: projectDirectory, parsedTags,
371
+ return Object.assign(Object.assign({}, options), { fileName, name: projectName, projectNames,
372
+ projectRoot,
373
+ parsedTags,
372
374
  importPath });
373
375
  });
374
376
  }
@@ -9,8 +9,8 @@ const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
9
  const print_diagnostics_1 = require("../typescript/print-diagnostics");
10
10
  const run_type_check_1 = require("../typescript/run-type-check");
11
11
  function getSwcCmd({ swcrcPath, srcPath, destPath }, watch = false) {
12
- const packageManager = (0, devkit_1.getPackageManagerCommand)();
13
- let swcCmd = `${packageManager.exec} swc ${
12
+ const swcCLI = require.resolve('@swc/cli/bin/swc.js');
13
+ let swcCmd = `${swcCLI} ${
14
14
  // TODO(jack): clean this up when we remove inline module support
15
15
  // Handle root project
16
16
  srcPath === '.' ? 'src' : srcPath} -d ${srcPath === '.' ? `${destPath}/src` : destPath} --config-file=${swcrcPath}`;
@@ -39,6 +39,7 @@ function compileSwc(context, normalizedOptions, postCompilationCallback) {
39
39
  }
40
40
  const swcCmdLog = (0, child_process_1.execSync)(getSwcCmd(normalizedOptions.swcCliOptions), {
41
41
  encoding: 'utf8',
42
+ cwd: normalizedOptions.swcCliOptions.swcCwd,
42
43
  });
43
44
  devkit_1.logger.log(swcCmdLog.replace(/\n/, ''));
44
45
  const isCompileSuccess = swcCmdLog.includes('Successfully compiled');