@nx/js 18.3.0-beta.1 → 18.3.0-beta.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/migrations.json +9 -0
- package/package.json +4 -4
- package/src/executors/swc/schema.json +7 -1
- package/src/executors/swc/swc.impl.js +10 -10
- package/src/executors/tsc/schema.json +2 -1
- package/src/generators/library/library.js +5 -5
- package/src/generators/release-version/release-version.js +4 -0
- package/src/generators/release-version/schema.json +1 -1
- package/src/utils/schema.d.ts +5 -0
- package/src/utils/swc/compile-swc.js +35 -10
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/migrations.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "18.3.0-beta.
|
|
3
|
+
"version": "18.3.0-beta.2",
|
|
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.
|
|
61
|
-
"@nx/workspace": "18.3.0-beta.
|
|
62
|
-
"@nrwl/js": "18.3.0-beta.
|
|
60
|
+
"@nx/devkit": "18.3.0-beta.2",
|
|
61
|
+
"@nx/workspace": "18.3.0-beta.2",
|
|
62
|
+
"@nrwl/js": "18.3.0-beta.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"verdaccio": "^5.0.4"
|
|
@@ -97,7 +97,8 @@
|
|
|
97
97
|
"type": "string"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
]
|
|
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."
|
|
101
102
|
},
|
|
102
103
|
"externalBuildTargets": {
|
|
103
104
|
"type": "array",
|
|
@@ -114,6 +115,11 @@
|
|
|
114
115
|
"x-priority": "internal"
|
|
115
116
|
}
|
|
116
117
|
},
|
|
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
|
+
},
|
|
117
123
|
"required": ["main", "outputPath", "tsConfig"],
|
|
118
124
|
"definitions": {
|
|
119
125
|
"assetPattern": {
|
|
@@ -35,19 +35,15 @@ function normalizeOptions(options, root, sourceRoot, projectRoot) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
const files = (0, assets_1.assetGlobsToFiles)(options.assets, root, outputPath);
|
|
38
|
-
|
|
39
|
-
|
|
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('/') || '.';
|
|
38
|
+
// Always execute from root of project, same as with SWC CLI.
|
|
39
|
+
const swcCwd = (0, path_1.join)(root, projectRoot);
|
|
45
40
|
const { swcrcPath, tmpSwcrcPath } = (0, get_swcrc_path_1.getSwcrcPath)(options, root, projectRoot);
|
|
46
41
|
const swcCliOptions = {
|
|
47
|
-
srcPath:
|
|
48
|
-
destPath: (0, path_1.relative)(
|
|
42
|
+
srcPath: projectRoot,
|
|
43
|
+
destPath: (0, path_1.relative)(swcCwd, outputPath),
|
|
49
44
|
swcCwd,
|
|
50
45
|
swcrcPath,
|
|
46
|
+
stripLeadingPaths: Boolean(options.stripLeadingPaths),
|
|
51
47
|
};
|
|
52
48
|
return {
|
|
53
49
|
...options,
|
|
@@ -76,10 +72,14 @@ async function* swcExecutor(_options, context) {
|
|
|
76
72
|
}
|
|
77
73
|
const inlineProjectGraph = (0, inline_1.handleInliningBuild)(context, options, options.tsConfig);
|
|
78
74
|
if (!(0, inline_1.isInlineGraphEmpty)(inlineProjectGraph)) {
|
|
75
|
+
if (options.stripLeadingPaths) {
|
|
76
|
+
throw new Error(`Cannot use --strip-leading-paths with inlining.`);
|
|
77
|
+
}
|
|
79
78
|
options.projectRoot = '.'; // set to root of workspace to include other libs for type check
|
|
80
79
|
// remap paths for SWC compilation
|
|
81
|
-
options.
|
|
80
|
+
options.inline = true;
|
|
82
81
|
options.swcCliOptions.swcCwd = '.';
|
|
82
|
+
options.swcCliOptions.srcPath = 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
|
|
@@ -629,10 +629,10 @@ function determineEntryFields(options) {
|
|
|
629
629
|
};
|
|
630
630
|
case 'rollup':
|
|
631
631
|
return {
|
|
632
|
-
|
|
632
|
+
// Since we're publishing both formats, skip the type field.
|
|
633
|
+
// Bundlers or Node will determine the entry point to use.
|
|
633
634
|
main: './index.cjs',
|
|
634
635
|
module: './index.js',
|
|
635
|
-
// typings is missing for rollup currently
|
|
636
636
|
};
|
|
637
637
|
case 'vite':
|
|
638
638
|
return {
|
|
@@ -651,9 +651,9 @@ function determineEntryFields(options) {
|
|
|
651
651
|
};
|
|
652
652
|
default: {
|
|
653
653
|
return {
|
|
654
|
-
//
|
|
655
|
-
//
|
|
656
|
-
type:
|
|
654
|
+
// Safest option is to not set a type field.
|
|
655
|
+
// Allow the user to decide which module format their library is using
|
|
656
|
+
type: undefined,
|
|
657
657
|
};
|
|
658
658
|
}
|
|
659
659
|
}
|
|
@@ -357,6 +357,10 @@ function createResolvePackageRoot(customPackageRoot) {
|
|
|
357
357
|
if (!customPackageRoot) {
|
|
358
358
|
return projectNode.data.root;
|
|
359
359
|
}
|
|
360
|
+
if (projectNode.data.root === '.') {
|
|
361
|
+
// TODO This is a temporary workaround to fix NXC-574 until NXC-573 is resolved
|
|
362
|
+
return projectNode.data.root;
|
|
363
|
+
}
|
|
360
364
|
return (0, utils_1.interpolate)(customPackageRoot, {
|
|
361
365
|
workspaceRoot: '',
|
|
362
366
|
projectRoot: projectNode.data.root,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"preid": {
|
|
35
35
|
"type": "string",
|
|
36
|
-
"description": "The optional prerelease identifier to apply to the version, in the case that specifier has been set to prerelease."
|
|
36
|
+
"description": "The optional prerelease identifier to apply to the version, in the case that the specifier argument has been set to prerelease."
|
|
37
37
|
},
|
|
38
38
|
"packageRoot": {
|
|
39
39
|
"type": "string",
|
package/src/utils/schema.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface ExecutorOptions {
|
|
|
51
51
|
external?: 'all' | 'none' | string[];
|
|
52
52
|
externalBuildTargets?: string[];
|
|
53
53
|
generateLockfile?: boolean;
|
|
54
|
+
stripLeadingPaths?: boolean;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export interface NormalizedExecutorOptions extends ExecutorOptions {
|
|
@@ -75,6 +76,7 @@ export interface SwcCliOptions {
|
|
|
75
76
|
destPath: string;
|
|
76
77
|
swcrcPath: string;
|
|
77
78
|
swcCwd: string;
|
|
79
|
+
stripLeadingPaths: boolean;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
export interface NormalizedSwcExecutorOptions
|
|
@@ -84,4 +86,7 @@ export interface NormalizedSwcExecutorOptions
|
|
|
84
86
|
skipTypeCheck: boolean;
|
|
85
87
|
swcCliOptions: SwcCliOptions;
|
|
86
88
|
tmpSwcrcPath: string;
|
|
89
|
+
sourceRoot?: string;
|
|
90
|
+
// TODO(v20): remove inline feature
|
|
91
|
+
inline?: boolean;
|
|
87
92
|
}
|
|
@@ -2,27 +2,50 @@
|
|
|
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
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
6
7
|
const fs_extra_1 = require("fs-extra");
|
|
7
8
|
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
8
9
|
const print_diagnostics_1 = require("../typescript/print-diagnostics");
|
|
9
10
|
const run_type_check_1 = require("../typescript/run-type-check");
|
|
10
|
-
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
function getSwcCmd({ swcCliOptions: { swcrcPath, destPath, stripLeadingPaths }, root, projectRoot, originalProjectRoot, sourceRoot, inline, }, watch = false) {
|
|
11
13
|
const swcCLI = require.resolve('@swc/cli/bin/swc.js');
|
|
12
|
-
let
|
|
13
|
-
// TODO(
|
|
14
|
-
|
|
15
|
-
|
|
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' : ''}`;
|
|
16
30
|
return watch ? swcCmd.concat(' --watch') : swcCmd;
|
|
17
31
|
}
|
|
18
32
|
function getTypeCheckOptions(normalizedOptions) {
|
|
19
|
-
const { projectRoot, watch, tsConfig, root, outputPath } = 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;
|
|
20
43
|
const typeCheckOptions = {
|
|
21
44
|
mode: 'emitDeclarationOnly',
|
|
22
45
|
tsConfigPath: tsConfig,
|
|
23
46
|
outDir: outputPath,
|
|
24
47
|
workspaceRoot: root,
|
|
25
|
-
rootDir:
|
|
48
|
+
rootDir: inputDir,
|
|
26
49
|
};
|
|
27
50
|
if (watch) {
|
|
28
51
|
typeCheckOptions.incremental = true;
|
|
@@ -35,7 +58,7 @@ async function compileSwc(context, normalizedOptions, postCompilationCallback) {
|
|
|
35
58
|
if (normalizedOptions.clean) {
|
|
36
59
|
(0, fs_extra_1.removeSync)(normalizedOptions.outputPath);
|
|
37
60
|
}
|
|
38
|
-
const swcCmdLog = (0,
|
|
61
|
+
const swcCmdLog = (0, node_child_process_1.execSync)(getSwcCmd(normalizedOptions), {
|
|
39
62
|
encoding: 'utf8',
|
|
40
63
|
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
|
41
64
|
});
|
|
@@ -73,7 +96,9 @@ async function* compileSwcWatch(context, normalizedOptions, postCompilationCallb
|
|
|
73
96
|
let stdoutOnData;
|
|
74
97
|
let stderrOnData;
|
|
75
98
|
let watcherOnExit;
|
|
76
|
-
const swcWatcher = (0,
|
|
99
|
+
const swcWatcher = (0, node_child_process_1.exec)(getSwcCmd(normalizedOptions, true), {
|
|
100
|
+
cwd: normalizedOptions.swcCliOptions.swcCwd,
|
|
101
|
+
});
|
|
77
102
|
processOnExit = () => {
|
|
78
103
|
swcWatcher.kill();
|
|
79
104
|
done();
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -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.
|
|
4
|
+
export declare const swcCliVersion = "~0.3.12";
|
|
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";
|
package/src/utils/versions.js
CHANGED
|
@@ -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.
|
|
7
|
+
exports.swcCliVersion = '~0.3.12';
|
|
8
8
|
exports.swcCoreVersion = '~1.3.85';
|
|
9
9
|
exports.swcHelpersVersion = '~0.5.2';
|
|
10
10
|
exports.swcNodeVersion = '~1.8.0';
|