@nx/js 18.3.0-beta.2 → 18.3.0-beta.3

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/migrations.json CHANGED
@@ -167,15 +167,6 @@
167
167
  "alwaysAddToPackageJson": false
168
168
  }
169
169
  }
170
- },
171
- "18.2.5": {
172
- "version": "18.2.5-beta.0",
173
- "packages": {
174
- "@swc/cli": {
175
- "version": "~0.3.12",
176
- "alwaysAddToPackageJson": false
177
- }
178
- }
179
170
  }
180
171
  }
181
172
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "18.3.0-beta.2",
3
+ "version": "18.3.0-beta.3",
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": {
@@ -57,9 +57,9 @@
57
57
  "semver": "^7.5.3",
58
58
  "source-map-support": "0.5.19",
59
59
  "tslib": "^2.3.0",
60
- "@nx/devkit": "18.3.0-beta.2",
61
- "@nx/workspace": "18.3.0-beta.2",
62
- "@nrwl/js": "18.3.0-beta.2"
60
+ "@nx/devkit": "18.3.0-beta.3",
61
+ "@nx/workspace": "18.3.0-beta.3",
62
+ "@nrwl/js": "18.3.0-beta.3"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "verdaccio": "^5.0.4"
@@ -97,8 +97,7 @@
97
97
  "type": "string"
98
98
  }
99
99
  }
100
- ],
101
- "x-deprecated": "Make sure all dependencies are buildable by running `nx g @nx/js:setup-build`. This option will be removed in Nx 20."
100
+ ]
102
101
  },
103
102
  "externalBuildTargets": {
104
103
  "type": "array",
@@ -115,11 +114,6 @@
115
114
  "x-priority": "internal"
116
115
  }
117
116
  },
118
- "stripLeadingPaths": {
119
- "type": "boolean",
120
- "description": "Remove leading directory from output (e.g. src). See: https://swc.rs/docs/usage/cli#--strip-leading-paths",
121
- "default": false
122
- },
123
117
  "required": ["main", "outputPath", "tsConfig"],
124
118
  "definitions": {
125
119
  "assetPattern": {
@@ -35,15 +35,19 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
35
35
  }
36
36
  }
37
37
  const files = (0, assets_1.assetGlobsToFiles)(options.assets, root, outputPath);
38
- // Always execute from root of project, same as with SWC CLI.
39
- const swcCwd = (0, path_1.join)(root, projectRoot);
38
+ const projectRootParts = projectRoot.split('/');
39
+ // We pop the last part of the `projectRoot` to pass
40
+ // the last part (projectDir) and the remainder (projectRootParts) to swc
41
+ const projectDir = projectRootParts.pop();
42
+ // default to current directory if projectRootParts is [].
43
+ // Eg: when a project is at the root level, outside of layout dir
44
+ const swcCwd = projectRootParts.join('/') || '.';
40
45
  const { swcrcPath, tmpSwcrcPath } = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
41
46
  const swcCliOptions = {
42
- srcPath: projectRoot,
43
- destPath: (0, path_1.relative)(swcCwd, outputPath),
47
+ srcPath: projectDir,
48
+ destPath: (0, path_1.relative)((0, path_1.join)(root, swcCwd), outputPath),
44
49
  swcCwd,
45
50
  swcrcPath,
46
- stripLeadingPaths: Boolean(options.stripLeadingPaths),
47
51
  };
48
52
  return {
49
53
  ...options,
@@ -72,14 +76,10 @@ async function* swcExecutor(_options, context) {
72
76
  }
73
77
  const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, options.tsConfig);
74
78
  if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
75
- if (options.stripLeadingPaths) {
76
- throw new Error(`Cannot use --strip-leading-paths with inlining.`);
77
- }
78
79
  options.projectRoot = '.'; // set to root of workspace to include other libs for type check
79
80
  // remap paths for SWC compilation
80
- options.inline = true;
81
- options.swcCliOptions.swcCwd = '.';
82
81
  options.swcCliOptions.srcPath = options.swcCliOptions.swcCwd;
82
+ options.swcCliOptions.swcCwd = '.';
83
83
  options.swcCliOptions.destPath = (0, path_1.join)(options.swcCliOptions.destPath.split((0, path_1.normalize)('../')).at(-1), options.swcCliOptions.srcPath);
84
84
  // tmp swcrc with dependencies to exclude
85
85
  // - buildable libraries
@@ -85,8 +85,7 @@
85
85
  "type": "string"
86
86
  }
87
87
  }
88
- ],
89
- "x-deprecated": "Make sure all dependencies are buildable by running `nx g @nx/js:setup-build`. This option will be removed in Nx 20."
88
+ ]
90
89
  },
91
90
  "externalBuildTargets": {
92
91
  "type": "array",
@@ -51,7 +51,6 @@ export interface ExecutorOptions {
51
51
  external?: 'all' | 'none' | string[];
52
52
  externalBuildTargets?: string[];
53
53
  generateLockfile?: boolean;
54
- stripLeadingPaths?: boolean;
55
54
  }
56
55
 
57
56
  export interface NormalizedExecutorOptions extends ExecutorOptions {
@@ -76,7 +75,6 @@ export interface SwcCliOptions {
76
75
  destPath: string;
77
76
  swcrcPath: string;
78
77
  swcCwd: string;
79
- stripLeadingPaths: boolean;
80
78
  }
81
79
 
82
80
  export interface NormalizedSwcExecutorOptions
@@ -86,7 +84,4 @@ export interface NormalizedSwcExecutorOptions
86
84
  skipTypeCheck: boolean;
87
85
  swcCliOptions: SwcCliOptions;
88
86
  tmpSwcrcPath: string;
89
- sourceRoot?: string;
90
- // TODO(v20): remove inline feature
91
- inline?: boolean;
92
87
  }
@@ -2,50 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.compileSwcWatch = exports.compileSwc = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const node_child_process_1 = require("node:child_process");
6
- const node_path_1 = require("node:path");
5
+ const child_process_1 = require("child_process");
7
6
  const fs_extra_1 = require("fs-extra");
8
7
  const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
9
8
  const print_diagnostics_1 = require("../typescript/print-diagnostics");
10
9
  const run_type_check_1 = require("../typescript/run-type-check");
11
- const path_1 = require("path");
12
- function getSwcCmd({ swcCliOptions: { swcrcPath, destPath, stripLeadingPaths }, root, projectRoot, originalProjectRoot, sourceRoot, inline, }, watch = false) {
10
+ function getSwcCmd({ swcrcPath, srcPath, destPath }, watch = false) {
13
11
  const swcCLI = require.resolve('@swc/cli/bin/swc.js');
14
- let inputDir;
15
- // TODO(v20): remove inline feature
16
- if (inline) {
17
- inputDir = originalProjectRoot.split('/')[0];
18
- }
19
- else {
20
- if (sourceRoot) {
21
- inputDir = (0, path_1.relative)(projectRoot, sourceRoot);
22
- }
23
- else {
24
- // If sourceRoot is not provided, check if `src` exists and use that instead.
25
- // This is important for root projects to avoid compiling too many directories.
26
- inputDir = (0, fs_extra_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src')) ? 'src' : '.';
27
- }
28
- }
29
- let swcCmd = `node ${swcCLI} ${inputDir || '.'} -d ${destPath} --config-file=${swcrcPath} ${stripLeadingPaths ? '--strip-leading-paths' : ''}`;
12
+ let swcCmd = `node ${swcCLI} ${
13
+ // TODO(jack): clean this up when we remove inline module support
14
+ // Handle root project
15
+ srcPath === '.' ? 'src' : srcPath} -d ${srcPath === '.' ? `${destPath}/src` : destPath} --config-file=${swcrcPath}`;
30
16
  return watch ? swcCmd.concat(' --watch') : swcCmd;
31
17
  }
32
18
  function getTypeCheckOptions(normalizedOptions) {
33
- const { sourceRoot, projectRoot, watch, tsConfig, root, outputPath } = normalizedOptions;
34
- const inputDir =
35
- // If `--strip-leading-paths` SWC option is used, we need to transpile from `src` directory.
36
- !normalizedOptions.swcCliOptions.stripLeadingPaths
37
- ? projectRoot
38
- : sourceRoot
39
- ? sourceRoot
40
- : (0, fs_extra_1.existsSync)((0, node_path_1.join)(root, projectRoot, 'src'))
41
- ? (0, node_path_1.join)(projectRoot, 'src')
42
- : projectRoot;
19
+ const { projectRoot, watch, tsConfig, root, outputPath } = normalizedOptions;
43
20
  const typeCheckOptions = {
44
21
  mode: 'emitDeclarationOnly',
45
22
  tsConfigPath: tsConfig,
46
23
  outDir: outputPath,
47
24
  workspaceRoot: root,
48
- rootDir: inputDir,
25
+ rootDir: projectRoot,
49
26
  };
50
27
  if (watch) {
51
28
  typeCheckOptions.incremental = true;
@@ -58,7 +35,7 @@ async function compileSwc(context, normalizedOptions, postCompilationCallback) {
58
35
  if (normalizedOptions.clean) {
59
36
  (0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
60
37
  }
61
- const swcCmdLog = (0, node_child_process_1.execSync)(getSwcCmd(normalizedOptions), {
38
+ const swcCmdLog = (0, child_process_1.execSync)(getSwcCmd(normalizedOptions.swcCliOptions), {
62
39
  encoding: 'utf8',
63
40
  cwd: normalizedOptions.swcCliOptions.swcCwd,
64
41
  });
@@ -96,9 +73,7 @@ async function* compileSwcWatch(context, normalizedOptions, postCompilationCallb
96
73
  let stdoutOnData;
97
74
  let stderrOnData;
98
75
  let watcherOnExit;
99
- const swcWatcher = (0, node_child_process_1.exec)(getSwcCmd(normalizedOptions, true), {
100
- cwd: normalizedOptions.swcCliOptions.swcCwd,
101
- });
76
+ const swcWatcher = (0, child_process_1.exec)(getSwcCmd(normalizedOptions.swcCliOptions, true), { cwd: normalizedOptions.swcCliOptions.swcCwd });
102
77
  processOnExit = () => {
103
78
  swcWatcher.kill();
104
79
  done();
@@ -1,7 +1,7 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const esbuildVersion = "^0.19.2";
3
3
  export declare const prettierVersion = "^2.6.2";
4
- export declare const swcCliVersion = "~0.3.12";
4
+ export declare const swcCliVersion = "~0.1.62";
5
5
  export declare const swcCoreVersion = "~1.3.85";
6
6
  export declare const swcHelpersVersion = "~0.5.2";
7
7
  export declare const swcNodeVersion = "~1.8.0";
@@ -4,7 +4,7 @@ exports.supportedTypescriptVersions = exports.typescriptVersion = exports.verdac
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.esbuildVersion = '^0.19.2';
6
6
  exports.prettierVersion = '^2.6.2';
7
- exports.swcCliVersion = '~0.3.12';
7
+ exports.swcCliVersion = '~0.1.62';
8
8
  exports.swcCoreVersion = '~1.3.85';
9
9
  exports.swcHelpersVersion = '~0.5.2';
10
10
  exports.swcNodeVersion = '~1.8.0';