@nx/js 16.8.1 → 16.9.0-beta.1
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/README.md +1 -1
- package/package.json +5 -5
- package/src/executors/tsc/tsc.batch-impl.js +3 -2
- package/src/executors/tsc/tsc.impl.d.ts +0 -3
- package/src/executors/tsc/tsc.impl.js +4 -12
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/utils/package-json/create-entry-points.d.ts +1 -0
- package/src/utils/package-json/create-entry-points.js +23 -0
- package/src/utils/package-json/update-package-json.js +9 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[]()
|
|
9
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
10
10
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
11
|
-
[](https://go.nx.dev/community)
|
|
12
12
|
|
|
13
13
|
</div>
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.9.0-beta.1",
|
|
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.
|
|
43
|
-
"@nx/devkit": "16.
|
|
44
|
-
"@nx/workspace": "16.
|
|
42
|
+
"@nrwl/js": "16.9.0-beta.1",
|
|
43
|
+
"@nx/devkit": "16.9.0-beta.1",
|
|
44
|
+
"@nx/workspace": "16.9.0-beta.1",
|
|
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": "
|
|
74
|
+
"gitHead": "5056d6cefb2949ba865019e8b71e633fba28c091"
|
|
75
75
|
}
|
|
@@ -8,6 +8,7 @@ const update_package_json_1 = require("../../utils/package-json/update-package-j
|
|
|
8
8
|
const tsc_impl_1 = require("./tsc.impl");
|
|
9
9
|
const lib_1 = require("./lib");
|
|
10
10
|
const batch_1 = require("./lib/batch");
|
|
11
|
+
const create_entry_points_1 = require("../../utils/package-json/create-entry-points");
|
|
11
12
|
async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
12
13
|
const tasksOptions = (0, batch_1.normalizeTasksOptions)(inputs, context);
|
|
13
14
|
let shouldWatch = false;
|
|
@@ -48,7 +49,7 @@ async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
|
48
49
|
taskInfo.assetsHandler.processAllAssetsOnceSync();
|
|
49
50
|
(0, update_package_json_1.updatePackageJson)({
|
|
50
51
|
...taskInfo.options,
|
|
51
|
-
additionalEntryPoints: (0,
|
|
52
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(taskInfo.options.additionalEntryPoints, context.root),
|
|
52
53
|
format: [(0, tsc_impl_1.determineModuleFormatFromTsConfig)(tsConfig)],
|
|
53
54
|
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
54
55
|
// TSC can match them correctly based on file names.
|
|
@@ -72,7 +73,7 @@ async function* tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
|
72
73
|
for (const t of changedTaskInfos) {
|
|
73
74
|
(0, update_package_json_1.updatePackageJson)({
|
|
74
75
|
...t.options,
|
|
75
|
-
additionalEntryPoints: (0,
|
|
76
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(t.options.additionalEntryPoints, context.root),
|
|
76
77
|
format: [(0, tsc_impl_1.determineModuleFormatFromTsConfig)(t.options.tsConfig)],
|
|
77
78
|
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
78
79
|
// TSC can match them correctly based on file names.
|
|
@@ -4,7 +4,4 @@ import { ExecutorOptions, NormalizedExecutorOptions } from '../../utils/schema';
|
|
|
4
4
|
export declare function determineModuleFormatFromTsConfig(absolutePathToTsConfig: string): 'cjs' | 'esm';
|
|
5
5
|
export declare function createTypeScriptCompilationOptions(normalizedOptions: NormalizedExecutorOptions, context: ExecutorContext): TypeScriptCompilationOptions;
|
|
6
6
|
export declare function tscExecutor(_options: ExecutorOptions, context: ExecutorContext): AsyncGenerator<import("../../utils/typescript/compile-typescript-files").TypescriptCompilationResult, any, undefined>;
|
|
7
|
-
export declare function createEntryPoints(options: {
|
|
8
|
-
additionalEntryPoints?: string[];
|
|
9
|
-
}, context: ExecutorContext): string[];
|
|
10
7
|
export default tscExecutor;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.tscExecutor = exports.createTypeScriptCompilationOptions = exports.determineModuleFormatFromTsConfig = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
|
-
const fast_glob_1 = require("fast-glob");
|
|
6
5
|
const copy_assets_handler_1 = require("../../utils/assets/copy-assets-handler");
|
|
7
6
|
const check_dependencies_1 = require("../../utils/check-dependencies");
|
|
8
7
|
const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
|
|
@@ -12,6 +11,7 @@ const compile_typescript_files_1 = require("../../utils/typescript/compile-types
|
|
|
12
11
|
const watch_for_single_file_changes_1 = require("../../utils/watch-for-single-file-changes");
|
|
13
12
|
const lib_1 = require("./lib");
|
|
14
13
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
14
|
+
const create_entry_points_1 = require("../../utils/package-json/create-entry-points");
|
|
15
15
|
function determineModuleFormatFromTsConfig(absolutePathToTsConfig) {
|
|
16
16
|
const tsConfig = (0, ts_config_1.readTsConfig)(absolutePathToTsConfig);
|
|
17
17
|
if (tsConfig.options.module === ts.ModuleKind.ES2015 ||
|
|
@@ -64,7 +64,7 @@ async function* tscExecutor(_options, context) {
|
|
|
64
64
|
await assetHandler.processAllAssetsOnce();
|
|
65
65
|
(0, update_package_json_1.updatePackageJson)({
|
|
66
66
|
...options,
|
|
67
|
-
additionalEntryPoints: createEntryPoints(options, context),
|
|
67
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(options.additionalEntryPoints, context.root),
|
|
68
68
|
format: [determineModuleFormatFromTsConfig(options.tsConfig)],
|
|
69
69
|
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
70
70
|
// TSC can match them correctly based on file names.
|
|
@@ -76,7 +76,7 @@ async function* tscExecutor(_options, context) {
|
|
|
76
76
|
const disposeWatchAssetChanges = await assetHandler.watchAndProcessOnAssetChange();
|
|
77
77
|
const disposePackageJsonChanges = await (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)({
|
|
78
78
|
...options,
|
|
79
|
-
additionalEntryPoints: createEntryPoints(options, context),
|
|
79
|
+
additionalEntryPoints: (0, create_entry_points_1.createEntryPoints)(options.additionalEntryPoints, context.root),
|
|
80
80
|
// As long as d.ts files match their .js counterparts, we don't need to emit them.
|
|
81
81
|
// TSC can match them correctly based on file names.
|
|
82
82
|
skipTypings: true,
|
|
@@ -94,12 +94,4 @@ async function* tscExecutor(_options, context) {
|
|
|
94
94
|
return yield* typescriptCompilation.iterator;
|
|
95
95
|
}
|
|
96
96
|
exports.tscExecutor = tscExecutor;
|
|
97
|
-
function createEntryPoints(options, context) {
|
|
98
|
-
if (!options.additionalEntryPoints?.length)
|
|
99
|
-
return [];
|
|
100
|
-
return (0, fast_glob_1.sync)(options.additionalEntryPoints, {
|
|
101
|
-
cwd: context.root,
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
exports.createEntryPoints = createEntryPoints;
|
|
105
97
|
exports.default = tscExecutor;
|
package/src/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './utils/typescript/ast-utils';
|
|
|
10
10
|
export * from './utils/package-json';
|
|
11
11
|
export * from './utils/assets';
|
|
12
12
|
export * from './utils/package-json/update-package-json';
|
|
13
|
+
export * from './utils/package-json/create-entry-points';
|
|
13
14
|
export { libraryGenerator } from './generators/library/library';
|
|
14
15
|
export { initGenerator } from './generators/init/init';
|
|
15
16
|
export { createLockFile, getLockFileName, } from 'nx/src/plugins/js/lock-file/lock-file';
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ tslib_1.__exportStar(require("./utils/typescript/ast-utils"), exports);
|
|
|
14
14
|
tslib_1.__exportStar(require("./utils/package-json"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./utils/assets"), exports);
|
|
16
16
|
tslib_1.__exportStar(require("./utils/package-json/update-package-json"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./utils/package-json/create-entry-points"), exports);
|
|
17
18
|
var library_1 = require("./generators/library/library");
|
|
18
19
|
Object.defineProperty(exports, "libraryGenerator", { enumerable: true, get: function () { return library_1.libraryGenerator; } });
|
|
19
20
|
var init_1 = require("./generators/init/init");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createEntryPoints(additionalEntryPoints: undefined | string[], root: string): string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEntryPoints = void 0;
|
|
4
|
+
const fast_glob_1 = require("fast-glob");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
function createEntryPoints(additionalEntryPoints, root) {
|
|
7
|
+
if (!additionalEntryPoints?.length)
|
|
8
|
+
return [];
|
|
9
|
+
const files = [];
|
|
10
|
+
// NOTE: calling globSync for each pattern is slower than calling it all at once.
|
|
11
|
+
// We're doing it this way in order to show a warning for unmatched patterns.
|
|
12
|
+
// If a pattern is unmatched, it is very likely a mistake by the user.
|
|
13
|
+
// Performance impact should be negligible since there shouldn't be that many entry points.
|
|
14
|
+
// Benchmarks show only 1-3% difference in execution time.
|
|
15
|
+
for (const pattern of additionalEntryPoints) {
|
|
16
|
+
const matched = (0, fast_glob_1.sync)([pattern], { cwd: root });
|
|
17
|
+
if (!matched.length)
|
|
18
|
+
devkit_1.logger.warn(`The pattern ${pattern} did not match any files.`);
|
|
19
|
+
files.push(...matched);
|
|
20
|
+
}
|
|
21
|
+
return files;
|
|
22
|
+
}
|
|
23
|
+
exports.createEntryPoints = createEntryPoints;
|
|
@@ -8,7 +8,6 @@ const create_package_json_1 = require("nx/src/plugins/js/package-json/create-pac
|
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const fs_extra_1 = require("fs-extra");
|
|
11
|
-
const operators_1 = require("nx/src/project-graph/operators");
|
|
12
11
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
13
12
|
const fs_1 = require("fs");
|
|
14
13
|
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
@@ -49,10 +48,16 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
exports.updatePackageJson = updatePackageJson;
|
|
52
|
-
function
|
|
51
|
+
function isNpmNode(node, graph) {
|
|
52
|
+
return !!(graph.externalNodes[node.name]?.type === 'npm');
|
|
53
|
+
}
|
|
54
|
+
function isWorkspaceProject(node, graph) {
|
|
55
|
+
return !!graph.nodes[node.name];
|
|
56
|
+
}
|
|
57
|
+
function addMissingDependencies(packageJson, { projectName, targetName, configurationName, root, projectGraph, }, dependencies, propType = 'dependencies') {
|
|
53
58
|
const workspacePackageJson = (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'package.json'));
|
|
54
59
|
dependencies.forEach((entry) => {
|
|
55
|
-
if ((
|
|
60
|
+
if (isNpmNode(entry.node, projectGraph)) {
|
|
56
61
|
const { packageName, version } = entry.node.data;
|
|
57
62
|
if (packageJson.dependencies?.[packageName] ||
|
|
58
63
|
packageJson.devDependencies?.[packageName] ||
|
|
@@ -65,7 +70,7 @@ function addMissingDependencies(packageJson, { projectName, targetName, configur
|
|
|
65
70
|
packageJson[propType] ??= {};
|
|
66
71
|
packageJson[propType][packageName] = version;
|
|
67
72
|
}
|
|
68
|
-
else {
|
|
73
|
+
else if (isWorkspaceProject(entry.node, projectGraph)) {
|
|
69
74
|
const packageName = entry.name;
|
|
70
75
|
if (!!workspacePackageJson.devDependencies?.[packageName]) {
|
|
71
76
|
return;
|