@nx/js 16.4.0-beta.0 → 16.4.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/babel.js +0 -1
- package/executors.json +1 -0
- package/package.json +6 -5
- package/src/executors/node/compat.js +0 -1
- package/src/executors/node/lib/kill-tree.js +0 -1
- package/src/executors/node/node-with-require-overrides.js +0 -1
- package/src/executors/node/node.impl.js +14 -10
- package/src/executors/swc/compat.js +0 -1
- package/src/executors/swc/swc.impl.js +0 -1
- package/src/executors/tsc/compat.js +0 -1
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +4 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +54 -0
- package/src/executors/tsc/lib/batch/generate-temp-tsconfig.d.ts +3 -0
- package/src/executors/tsc/lib/batch/generate-temp-tsconfig.js +52 -0
- package/src/executors/tsc/lib/batch/get-task-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/get-task-options.js +24 -0
- package/src/executors/tsc/lib/batch/index.d.ts +8 -0
- package/src/executors/tsc/lib/batch/index.js +11 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.d.ts +3 -0
- package/src/executors/tsc/lib/batch/normalize-tasks-options.js +14 -0
- package/src/executors/tsc/lib/batch/types.d.ts +12 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/typescript-compilation.d.ts +7 -0
- package/src/executors/tsc/lib/batch/typescript-compilation.js +195 -0
- package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.d.ts +4 -0
- package/src/executors/tsc/lib/batch/typescript-diagnostic-reporters.js +44 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +63 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.d.ts +3 -0
- package/src/executors/tsc/lib/get-custom-transformers-factory.js +13 -0
- package/src/executors/tsc/lib/index.d.ts +2 -0
- package/src/executors/tsc/lib/index.js +5 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +32 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +4 -0
- package/src/executors/tsc/tsc.batch-impl.js +47 -0
- package/src/executors/tsc/tsc.impl.d.ts +0 -1
- package/src/executors/tsc/tsc.impl.js +4 -40
- package/src/executors/verdaccio/compat.js +0 -1
- package/src/executors/verdaccio/verdaccio.impl.d.ts +1 -0
- package/src/executors/verdaccio/verdaccio.impl.js +18 -8
- package/src/generators/convert-to-swc/convert-to-swc.js +0 -1
- package/src/generators/init/init.js +0 -1
- package/src/generators/library/library.js +0 -11
- package/src/generators/setup-verdaccio/generator.js +0 -1
- package/src/index.js +0 -1
- package/src/internal.js +0 -1
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +0 -1
- package/src/migrations/update-13-8-5/update-node-executor.js +0 -1
- package/src/migrations/update-13-8-5/update-swcrc.js +0 -1
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +0 -1
- package/src/migrations/update-14-1-5/update-swcrc-path.js +0 -1
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -1
- package/src/utils/add-babel-inputs.d.ts +1 -0
- package/src/utils/add-babel-inputs.js +2 -1
- package/src/utils/assets/assets.js +0 -1
- package/src/utils/assets/copy-assets-handler.d.ts +5 -1
- package/src/utils/assets/copy-assets-handler.js +34 -24
- package/src/utils/assets/index.js +0 -1
- package/src/utils/buildable-libs-utils.js +0 -1
- package/src/utils/check-dependencies.js +0 -1
- package/src/utils/code-frames/highlight.js +0 -1
- package/src/utils/code-frames/identifiers.js +0 -1
- package/src/utils/compiler-helper-dependency.js +0 -1
- package/src/utils/generate-globs.js +0 -1
- package/src/utils/get-import-path.js +0 -1
- package/src/utils/inline.d.ts +1 -1
- package/src/utils/inline.js +3 -4
- package/src/utils/minimal-publish-script.js +0 -1
- package/src/utils/package-json/get-npm-scope.js +0 -1
- package/src/utils/package-json/index.js +0 -1
- package/src/utils/package-json/update-package-json.js +0 -1
- package/src/utils/prettier.js +0 -1
- package/src/utils/schema.d.ts +3 -2
- package/src/utils/swc/add-swc-config.js +0 -1
- package/src/utils/swc/add-swc-dependencies.js +0 -1
- package/src/utils/swc/compile-swc.js +0 -1
- package/src/utils/swc/get-swcrc-path.js +0 -1
- package/src/utils/swc/inline.js +0 -1
- package/src/utils/typescript/__mocks__/plugin-a.js +0 -1
- package/src/utils/typescript/__mocks__/plugin-b.js +0 -1
- package/src/utils/typescript/add-tslib-dependencies.js +0 -1
- package/src/utils/typescript/ast-utils.js +0 -1
- package/src/utils/typescript/compile-typescript-files.js +0 -1
- package/src/utils/typescript/create-ts-config.js +0 -1
- package/src/utils/typescript/ensure-typescript.js +0 -1
- package/src/utils/typescript/get-source-nodes.js +0 -1
- package/src/utils/typescript/load-ts-transformers.js +0 -1
- package/src/utils/typescript/print-diagnostics.js +0 -1
- package/src/utils/typescript/run-type-check.js +0 -1
- package/src/utils/typescript/ts-config.js +0 -1
- package/src/utils/typescript/types.js +0 -1
- package/src/utils/versions.js +0 -1
- package/src/utils/watch-for-single-file-changes.js +0 -1
- package/babel.js.map +0 -1
- package/src/executors/node/compat.js.map +0 -1
- package/src/executors/node/lib/kill-tree.js.map +0 -1
- package/src/executors/node/node-with-require-overrides.js.map +0 -1
- package/src/executors/node/node.impl.js.map +0 -1
- package/src/executors/swc/compat.js.map +0 -1
- package/src/executors/swc/swc.impl.js.map +0 -1
- package/src/executors/tsc/compat.js.map +0 -1
- package/src/executors/tsc/tsc.impl.js.map +0 -1
- package/src/executors/verdaccio/compat.js.map +0 -1
- package/src/executors/verdaccio/verdaccio.impl.js.map +0 -1
- package/src/generators/convert-to-swc/convert-to-swc.js.map +0 -1
- package/src/generators/init/init.js.map +0 -1
- package/src/generators/library/library.js.map +0 -1
- package/src/generators/setup-verdaccio/generator.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/internal.js.map +0 -1
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +0 -1
- package/src/migrations/update-13-8-5/update-node-executor.js.map +0 -1
- package/src/migrations/update-13-8-5/update-swcrc.js.map +0 -1
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +0 -1
- package/src/migrations/update-14-1-5/update-swcrc-path.js.map +0 -1
- package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +0 -1
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +0 -1
- package/src/utils/add-babel-inputs.js.map +0 -1
- package/src/utils/assets/assets.js.map +0 -1
- package/src/utils/assets/copy-assets-handler.js.map +0 -1
- package/src/utils/assets/index.js.map +0 -1
- package/src/utils/buildable-libs-utils.js.map +0 -1
- package/src/utils/check-dependencies.js.map +0 -1
- package/src/utils/code-frames/highlight.js.map +0 -1
- package/src/utils/code-frames/identifiers.js.map +0 -1
- package/src/utils/compiler-helper-dependency.js.map +0 -1
- package/src/utils/generate-globs.js.map +0 -1
- package/src/utils/get-import-path.js.map +0 -1
- package/src/utils/inline.js.map +0 -1
- package/src/utils/minimal-publish-script.js.map +0 -1
- package/src/utils/package-json/get-npm-scope.js.map +0 -1
- package/src/utils/package-json/index.js.map +0 -1
- package/src/utils/package-json/update-package-json.js.map +0 -1
- package/src/utils/prettier.js.map +0 -1
- package/src/utils/swc/add-swc-config.js.map +0 -1
- package/src/utils/swc/add-swc-dependencies.js.map +0 -1
- package/src/utils/swc/compile-swc.js.map +0 -1
- package/src/utils/swc/get-swcrc-path.js.map +0 -1
- package/src/utils/swc/inline.js.map +0 -1
- package/src/utils/typescript/__mocks__/plugin-a.js.map +0 -1
- package/src/utils/typescript/__mocks__/plugin-b.js.map +0 -1
- package/src/utils/typescript/add-tslib-dependencies.js.map +0 -1
- package/src/utils/typescript/ast-utils.js.map +0 -1
- package/src/utils/typescript/compile-typescript-files.js.map +0 -1
- package/src/utils/typescript/create-ts-config.js.map +0 -1
- package/src/utils/typescript/ensure-typescript.js.map +0 -1
- package/src/utils/typescript/get-source-nodes.js.map +0 -1
- package/src/utils/typescript/load-ts-transformers.js.map +0 -1
- package/src/utils/typescript/print-diagnostics.js.map +0 -1
- package/src/utils/typescript/run-type-check.js.map +0 -1
- package/src/utils/typescript/ts-config.js.map +0 -1
- package/src/utils/typescript/types.js.map +0 -1
- package/src/utils/versions.js.map +0 -1
- package/src/utils/watch-for-single-file-changes.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.watchTaskProjectsFileChangesForAssets = exports.watchTaskProjectsPackageJsonFileChanges = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
function watchTaskProjectsPackageJsonFileChanges(taskInfos, callback) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const projects = [];
|
|
11
|
+
const packageJsonTaskInfoMap = new Map();
|
|
12
|
+
taskInfos.forEach((t) => {
|
|
13
|
+
projects.push(t.context.projectName);
|
|
14
|
+
packageJsonTaskInfoMap.set((0, path_1.join)(t.options.projectRoot, 'package.json'), t);
|
|
15
|
+
});
|
|
16
|
+
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({ watchProjects: projects }, (err, data) => {
|
|
17
|
+
var _a;
|
|
18
|
+
if (err === 'closed') {
|
|
19
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
else if (err) {
|
|
23
|
+
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const changedTasks = [];
|
|
27
|
+
data.changedFiles.forEach((file) => {
|
|
28
|
+
if (packageJsonTaskInfoMap.has(file.path)) {
|
|
29
|
+
changedTasks.push(packageJsonTaskInfoMap.get(file.path));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (changedTasks.length) {
|
|
33
|
+
callback(changedTasks);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return () => unregisterFileWatcher();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.watchTaskProjectsPackageJsonFileChanges = watchTaskProjectsPackageJsonFileChanges;
|
|
41
|
+
function watchTaskProjectsFileChangesForAssets(taskInfos) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({
|
|
44
|
+
watchProjects: taskInfos.map((t) => t.context.projectName),
|
|
45
|
+
includeDependentProjects: true,
|
|
46
|
+
includeGlobalWorkspaceFiles: true,
|
|
47
|
+
}, (err, data) => {
|
|
48
|
+
var _a;
|
|
49
|
+
if (err === 'closed') {
|
|
50
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
else if (err) {
|
|
54
|
+
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
taskInfos.forEach((t) => t.assetsHandler.processWatchEvents(data.changedFiles));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return () => unregisterFileWatcher();
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.watchTaskProjectsFileChangesForAssets = watchTaskProjectsFileChangesForAssets;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomTrasformersFactory = void 0;
|
|
4
|
+
const load_ts_transformers_1 = require("../../../utils/typescript/load-ts-transformers");
|
|
5
|
+
function getCustomTrasformersFactory(transformers) {
|
|
6
|
+
const { compilerPluginHooks } = (0, load_ts_transformers_1.loadTsTransformers)(transformers);
|
|
7
|
+
return (program) => ({
|
|
8
|
+
before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)),
|
|
9
|
+
after: compilerPluginHooks.afterHooks.map((hook) => hook(program)),
|
|
10
|
+
afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.getCustomTrasformersFactory = getCustomTrasformersFactory;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const assets_1 = require("../../../utils/assets/assets");
|
|
6
|
+
function normalizeOptions(options, contextRoot, sourceRoot, projectRoot) {
|
|
7
|
+
const outputPath = (0, path_1.join)(contextRoot, options.outputPath);
|
|
8
|
+
const rootDir = options.rootDir
|
|
9
|
+
? (0, path_1.join)(contextRoot, options.rootDir)
|
|
10
|
+
: (0, path_1.join)(contextRoot, projectRoot);
|
|
11
|
+
if (options.watch == null) {
|
|
12
|
+
options.watch = false;
|
|
13
|
+
}
|
|
14
|
+
// TODO: put back when inlining story is more stable
|
|
15
|
+
// if (options.external == null) {
|
|
16
|
+
// options.external = 'all';
|
|
17
|
+
// } else if (Array.isArray(options.external) && options.external.length === 0) {
|
|
18
|
+
// options.external = 'none';
|
|
19
|
+
// }
|
|
20
|
+
if (Array.isArray(options.external) && options.external.length > 0) {
|
|
21
|
+
const firstItem = options.external[0];
|
|
22
|
+
if (firstItem === 'all' || firstItem === 'none') {
|
|
23
|
+
options.external = firstItem;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const files = (0, assets_1.assetGlobsToFiles)(options.assets, contextRoot, outputPath);
|
|
27
|
+
return Object.assign(Object.assign({}, options), { root: contextRoot, sourceRoot,
|
|
28
|
+
projectRoot,
|
|
29
|
+
files,
|
|
30
|
+
outputPath, tsConfig: (0, path_1.join)(contextRoot, options.tsConfig), rootDir, mainOutputPath: (0, path_1.resolve)(outputPath, options.main.replace(`${projectRoot}/`, '').replace('.ts', '.js')) });
|
|
31
|
+
}
|
|
32
|
+
exports.normalizeOptions = normalizeOptions;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
2
|
+
import type { ExecutorOptions } from '../../utils/schema';
|
|
3
|
+
export declare function tscBatchExecutor(taskGraph: TaskGraph, inputs: Record<string, ExecutorOptions>, overrides: ExecutorOptions, context: ExecutorContext): AsyncGenerator<import("../../../../../build/packages/nx/src/tasks-runner/batch/batch-messages").BatchResults, any, undefined>;
|
|
4
|
+
export default tscBatchExecutor;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tscBatchExecutor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
7
|
+
const batch_1 = require("./lib/batch");
|
|
8
|
+
function tscBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
9
|
+
return tslib_1.__asyncGenerator(this, arguments, function* tscBatchExecutor_1() {
|
|
10
|
+
const tasksOptions = (0, batch_1.normalizeTasksOptions)(inputs, context);
|
|
11
|
+
let shouldWatch = false;
|
|
12
|
+
Object.values(tasksOptions).forEach((taskOptions) => {
|
|
13
|
+
if (taskOptions.clean) {
|
|
14
|
+
(0, fs_1.rmSync)(taskOptions.outputPath, { force: true, recursive: true });
|
|
15
|
+
}
|
|
16
|
+
if (taskOptions.watch) {
|
|
17
|
+
shouldWatch = true;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const tsConfigTaskInfoMap = {};
|
|
21
|
+
(0, batch_1.buildTaskInfoPerTsConfigMap)(tsConfigTaskInfoMap, tasksOptions, context, Object.keys(taskGraph.tasks), shouldWatch);
|
|
22
|
+
const typescriptCompilation = (0, batch_1.compileBatchTypescript)(tsConfigTaskInfoMap, taskGraph, shouldWatch, (taskInfo) => {
|
|
23
|
+
taskInfo.assetsHandler.processAllAssetsOnceSync();
|
|
24
|
+
(0, update_package_json_1.updatePackageJson)(taskInfo.options, taskInfo.context, taskInfo.projectGraphNode, taskInfo.buildableProjectNodeDependencies);
|
|
25
|
+
});
|
|
26
|
+
if (shouldWatch) {
|
|
27
|
+
const taskInfos = Object.values(tsConfigTaskInfoMap);
|
|
28
|
+
const watchAssetsChangesDisposer = yield tslib_1.__await((0, batch_1.watchTaskProjectsFileChangesForAssets)(taskInfos));
|
|
29
|
+
const watchProjectsChangesDisposer = yield tslib_1.__await((0, batch_1.watchTaskProjectsPackageJsonFileChanges)(taskInfos, (changedTaskInfos) => {
|
|
30
|
+
for (const t of changedTaskInfos) {
|
|
31
|
+
(0, update_package_json_1.updatePackageJson)(t.options, t.context, t.projectGraphNode, t.buildableProjectNodeDependencies);
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
|
+
const handleTermination = (exitCode) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
yield typescriptCompilation.close();
|
|
36
|
+
watchAssetsChangesDisposer();
|
|
37
|
+
watchProjectsChangesDisposer();
|
|
38
|
+
process.exit(exitCode);
|
|
39
|
+
});
|
|
40
|
+
process.on('SIGINT', () => handleTermination(128 + 2));
|
|
41
|
+
process.on('SIGTERM', () => handleTermination(128 + 15));
|
|
42
|
+
}
|
|
43
|
+
return yield tslib_1.__await(yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(typescriptCompilation.iterator))));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.tscBatchExecutor = tscBatchExecutor;
|
|
47
|
+
exports.default = tscBatchExecutor;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import type { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation';
|
|
3
3
|
import { ExecutorOptions, NormalizedExecutorOptions } from '../../utils/schema';
|
|
4
|
-
export declare function normalizeOptions(options: ExecutorOptions, contextRoot: string, sourceRoot: string, projectRoot: string): NormalizedExecutorOptions;
|
|
5
4
|
export declare function createTypeScriptCompilationOptions(normalizedOptions: NormalizedExecutorOptions, context: ExecutorContext): TypeScriptCompilationOptions;
|
|
6
5
|
export declare function tscExecutor(_options: ExecutorOptions, context: ExecutorContext): AsyncGenerator<import("../../utils/typescript/compile-typescript-files").TypescriptCompilationResult, any, undefined>;
|
|
7
6
|
export default tscExecutor;
|
|
@@ -1,51 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tscExecutor = exports.createTypeScriptCompilationOptions =
|
|
3
|
+
exports.tscExecutor = exports.createTypeScriptCompilationOptions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const assets_1 = require("../../utils/assets/assets");
|
|
6
|
-
const path_1 = require("path");
|
|
7
5
|
const copy_assets_handler_1 = require("../../utils/assets/copy-assets-handler");
|
|
8
6
|
const check_dependencies_1 = require("../../utils/check-dependencies");
|
|
9
7
|
const compiler_helper_dependency_1 = require("../../utils/compiler-helper-dependency");
|
|
10
8
|
const inline_1 = require("../../utils/inline");
|
|
11
9
|
const update_package_json_1 = require("../../utils/package-json/update-package-json");
|
|
12
10
|
const compile_typescript_files_1 = require("../../utils/typescript/compile-typescript-files");
|
|
13
|
-
const load_ts_transformers_1 = require("../../utils/typescript/load-ts-transformers");
|
|
14
11
|
const watch_for_single_file_changes_1 = require("../../utils/watch-for-single-file-changes");
|
|
15
|
-
|
|
16
|
-
const outputPath = (0, path_1.join)(contextRoot, options.outputPath);
|
|
17
|
-
const rootDir = options.rootDir
|
|
18
|
-
? (0, path_1.join)(contextRoot, options.rootDir)
|
|
19
|
-
: projectRoot;
|
|
20
|
-
if (options.watch == null) {
|
|
21
|
-
options.watch = false;
|
|
22
|
-
}
|
|
23
|
-
// TODO: put back when inlining story is more stable
|
|
24
|
-
// if (options.external == null) {
|
|
25
|
-
// options.external = 'all';
|
|
26
|
-
// } else if (Array.isArray(options.external) && options.external.length === 0) {
|
|
27
|
-
// options.external = 'none';
|
|
28
|
-
// }
|
|
29
|
-
if (Array.isArray(options.external) && options.external.length > 0) {
|
|
30
|
-
const firstItem = options.external[0];
|
|
31
|
-
if (firstItem === 'all' || firstItem === 'none') {
|
|
32
|
-
options.external = firstItem;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const files = (0, assets_1.assetGlobsToFiles)(options.assets, contextRoot, outputPath);
|
|
36
|
-
return Object.assign(Object.assign({}, options), { root: contextRoot, sourceRoot,
|
|
37
|
-
projectRoot,
|
|
38
|
-
files,
|
|
39
|
-
outputPath, tsConfig: (0, path_1.join)(contextRoot, options.tsConfig), rootDir, mainOutputPath: (0, path_1.resolve)(outputPath, options.main.replace(`${projectRoot}/`, '').replace('.ts', '.js')) });
|
|
40
|
-
}
|
|
41
|
-
exports.normalizeOptions = normalizeOptions;
|
|
12
|
+
const lib_1 = require("./lib");
|
|
42
13
|
function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
43
|
-
const { compilerPluginHooks } = (0, load_ts_transformers_1.loadTsTransformers)(normalizedOptions.transformers);
|
|
44
|
-
const getCustomTransformers = (program) => ({
|
|
45
|
-
before: compilerPluginHooks.beforeHooks.map((hook) => hook(program)),
|
|
46
|
-
after: compilerPluginHooks.afterHooks.map((hook) => hook(program)),
|
|
47
|
-
afterDeclarations: compilerPluginHooks.afterDeclarationsHooks.map((hook) => hook(program)),
|
|
48
|
-
});
|
|
49
14
|
return {
|
|
50
15
|
outputPath: normalizedOptions.outputPath,
|
|
51
16
|
projectName: context.projectName,
|
|
@@ -54,14 +19,14 @@ function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
|
54
19
|
tsConfig: normalizedOptions.tsConfig,
|
|
55
20
|
watch: normalizedOptions.watch,
|
|
56
21
|
deleteOutputPath: normalizedOptions.clean,
|
|
57
|
-
getCustomTransformers,
|
|
22
|
+
getCustomTransformers: (0, lib_1.getCustomTrasformersFactory)(normalizedOptions.transformers),
|
|
58
23
|
};
|
|
59
24
|
}
|
|
60
25
|
exports.createTypeScriptCompilationOptions = createTypeScriptCompilationOptions;
|
|
61
26
|
function tscExecutor(_options, context) {
|
|
62
27
|
return tslib_1.__asyncGenerator(this, arguments, function* tscExecutor_1() {
|
|
63
28
|
const { sourceRoot, root } = context.projectsConfigurations.projects[context.projectName];
|
|
64
|
-
const options = normalizeOptions(_options, context.root, sourceRoot, root);
|
|
29
|
+
const options = (0, lib_1.normalizeOptions)(_options, context.root, sourceRoot, root);
|
|
65
30
|
const { projectRoot, tmpTsConfig, target, dependencies } = (0, check_dependencies_1.checkDependencies)(context, _options.tsConfig);
|
|
66
31
|
if (tmpTsConfig) {
|
|
67
32
|
options.tsConfig = tmpTsConfig;
|
|
@@ -103,4 +68,3 @@ function tscExecutor(_options, context) {
|
|
|
103
68
|
}
|
|
104
69
|
exports.tscExecutor = tscExecutor;
|
|
105
70
|
exports.default = tscExecutor;
|
|
106
|
-
//# sourceMappingURL=tsc.impl.js.map
|
|
@@ -3,4 +3,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const devkit_1 = require("@nx/devkit");
|
|
4
4
|
const verdaccio_impl_1 = require("./verdaccio.impl");
|
|
5
5
|
exports.default = (0, devkit_1.convertNxExecutor)(verdaccio_impl_1.verdaccioExecutor);
|
|
6
|
-
//# sourceMappingURL=compat.js.map
|
|
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
|
+
const detectPort = require("detect-port");
|
|
9
|
+
const path_1 = require("path");
|
|
8
10
|
let childProcess;
|
|
9
11
|
/**
|
|
10
12
|
* - set npm and yarn to use local registry
|
|
@@ -36,16 +38,23 @@ function verdaccioExecutor(options, context) {
|
|
|
36
38
|
process.on('SIGINT', processExitListener);
|
|
37
39
|
process.on('SIGHUP', processExitListener);
|
|
38
40
|
try {
|
|
39
|
-
yield
|
|
41
|
+
const port = yield detectPort(options.port);
|
|
42
|
+
if (port === options.port) {
|
|
43
|
+
devkit_1.logger.info(`Port ${options.port} was occupied. Using port ${port}.`);
|
|
44
|
+
options.port = port;
|
|
45
|
+
}
|
|
46
|
+
yield startVerdaccio(options, context.root);
|
|
40
47
|
}
|
|
41
48
|
catch (e) {
|
|
42
|
-
devkit_1.logger.error('Failed to start verdaccio: ' + e.toString());
|
|
49
|
+
devkit_1.logger.error('Failed to start verdaccio: ' + (e === null || e === void 0 ? void 0 : e.toString()));
|
|
43
50
|
return {
|
|
44
51
|
success: false,
|
|
52
|
+
port: options.port,
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
55
|
return {
|
|
48
56
|
success: true,
|
|
57
|
+
port: options.port,
|
|
49
58
|
};
|
|
50
59
|
});
|
|
51
60
|
}
|
|
@@ -53,10 +62,12 @@ exports.verdaccioExecutor = verdaccioExecutor;
|
|
|
53
62
|
/**
|
|
54
63
|
* Fork the verdaccio process: https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module
|
|
55
64
|
*/
|
|
56
|
-
function startVerdaccio(options) {
|
|
65
|
+
function startVerdaccio(options, workspaceRoot) {
|
|
57
66
|
return new Promise((resolve, reject) => {
|
|
58
|
-
childProcess = (0, child_process_1.fork)(require.resolve('verdaccio/bin/verdaccio'), createVerdaccioOptions(options), {
|
|
59
|
-
env: Object.assign(Object.assign({}, process.env), { VERDACCIO_HANDLE_KILL_SIGNALS: 'true' }),
|
|
67
|
+
childProcess = (0, child_process_1.fork)(require.resolve('verdaccio/bin/verdaccio'), createVerdaccioOptions(options, workspaceRoot), {
|
|
68
|
+
env: Object.assign(Object.assign(Object.assign({}, process.env), { VERDACCIO_HANDLE_KILL_SIGNALS: 'true' }), (options.storage
|
|
69
|
+
? { VERDACCIO_STORAGE_PATH: options.storage }
|
|
70
|
+
: {})),
|
|
60
71
|
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
|
61
72
|
});
|
|
62
73
|
childProcess.stdout.on('data', (data) => {
|
|
@@ -87,13 +98,13 @@ function startVerdaccio(options) {
|
|
|
87
98
|
});
|
|
88
99
|
});
|
|
89
100
|
}
|
|
90
|
-
function createVerdaccioOptions(options) {
|
|
101
|
+
function createVerdaccioOptions(options, workspaceRoot) {
|
|
91
102
|
const verdaccioArgs = [];
|
|
92
103
|
if (options.port) {
|
|
93
104
|
verdaccioArgs.push('--listen', options.port.toString());
|
|
94
105
|
}
|
|
95
106
|
if (options.config) {
|
|
96
|
-
verdaccioArgs.push('--config', options.config);
|
|
107
|
+
verdaccioArgs.push('--config', (0, path_1.join)(workspaceRoot, options.config));
|
|
97
108
|
}
|
|
98
109
|
return verdaccioArgs;
|
|
99
110
|
}
|
|
@@ -164,4 +175,3 @@ function setupYarn(options) {
|
|
|
164
175
|
};
|
|
165
176
|
}
|
|
166
177
|
exports.default = verdaccioExecutor;
|
|
167
|
-
//# sourceMappingURL=verdaccio.impl.js.map
|
|
@@ -47,9 +47,6 @@ function projectGenerator(tree, schema, destinationDir, filesDir) {
|
|
|
47
47
|
});
|
|
48
48
|
tasks.push(viteTask);
|
|
49
49
|
}
|
|
50
|
-
if (options.bundler === 'rollup') {
|
|
51
|
-
ensureBabelRootConfigExists(tree);
|
|
52
|
-
}
|
|
53
50
|
if (options.linter !== 'none') {
|
|
54
51
|
const lintCallback = yield addLint(tree, options);
|
|
55
52
|
tasks.push(lintCallback);
|
|
@@ -384,13 +381,6 @@ function getBuildExecutor(bundler) {
|
|
|
384
381
|
return undefined;
|
|
385
382
|
}
|
|
386
383
|
}
|
|
387
|
-
function ensureBabelRootConfigExists(tree) {
|
|
388
|
-
if (tree.exists('babel.config.json'))
|
|
389
|
-
return;
|
|
390
|
-
(0, devkit_1.writeJson)(tree, 'babel.config.json', {
|
|
391
|
-
babelrcRoots: ['*'],
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
384
|
function getOutputPath(options, destinationDir) {
|
|
395
385
|
const parts = ['dist'];
|
|
396
386
|
if (destinationDir) {
|
|
@@ -422,4 +412,3 @@ function createProjectTsConfigJson(tree, options) {
|
|
|
422
412
|
}
|
|
423
413
|
exports.default = libraryGenerator;
|
|
424
414
|
exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
|
|
425
|
-
//# sourceMappingURL=library.js.map
|
package/src/index.js
CHANGED
|
@@ -24,4 +24,3 @@ Object.defineProperty(exports, "getLockFileName", { enumerable: true, get: funct
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
25
25
|
var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
26
26
|
Object.defineProperty(exports, "createPackageJson", { enumerable: true, get: function () { return create_package_json_1.createPackageJson; } });
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/src/internal.js
CHANGED
|
@@ -10,4 +10,3 @@ Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get:
|
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
11
|
var target_project_locator_1 = require("nx/src/plugins/js/project-graph/build-dependencies/target-project-locator");
|
|
12
12
|
Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return target_project_locator_1.TargetProjectLocator; } });
|
|
13
|
-
//# sourceMappingURL=internal.js.map
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addBabelInputs = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/** @deprecated Do not use this function as the root babel.config.json file is no longer needed */
|
|
6
|
+
// TODO(jack): Remove This in Nx 17 once we don't need to support Nx 15 anymore. Currently this function is used in v15 migrations.
|
|
5
7
|
function addBabelInputs(tree) {
|
|
6
8
|
var _a;
|
|
7
9
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
@@ -20,4 +22,3 @@ function addBabelInputs(tree) {
|
|
|
20
22
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
21
23
|
}
|
|
22
24
|
exports.addBabelInputs = addBabelInputs;
|
|
23
|
-
//# sourceMappingURL=add-babel-inputs.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AssetGlob } from './assets';
|
|
2
|
+
import { ChangedFile } from 'nx/src/daemon/client/client';
|
|
2
3
|
export type FileEventType = 'create' | 'update' | 'delete';
|
|
3
4
|
export interface FileEvent {
|
|
4
5
|
type: FileEventType;
|
|
@@ -22,7 +23,10 @@ export declare class CopyAssetsHandler {
|
|
|
22
23
|
private readonly callback;
|
|
23
24
|
constructor(opts: CopyAssetHandlerOptions);
|
|
24
25
|
processAllAssetsOnce(): Promise<void>;
|
|
26
|
+
processAllAssetsOnceSync(): void;
|
|
25
27
|
watchAndProcessOnAssetChange(): Promise<() => void>;
|
|
26
|
-
|
|
28
|
+
processWatchEvents(events: ChangedFile[]): Promise<void>;
|
|
29
|
+
private filesToEvent;
|
|
30
|
+
private normalizeAssetPattern;
|
|
27
31
|
}
|
|
28
32
|
export {};
|
|
@@ -74,35 +74,27 @@ class CopyAssetsHandler {
|
|
|
74
74
|
processAllAssetsOnce() {
|
|
75
75
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
76
|
yield Promise.all(this.assetGlobs.map((ag) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
|
|
78
|
-
if (typeof ag === 'string') {
|
|
79
|
-
pattern = ag;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
pattern = ag.pattern;
|
|
83
|
-
}
|
|
77
|
+
const pattern = this.normalizeAssetPattern(ag);
|
|
84
78
|
// fast-glob only supports Unix paths
|
|
85
79
|
const files = yield fg(pattern.replace(/\\/g, '/'), {
|
|
86
80
|
cwd: this.rootDir,
|
|
87
81
|
dot: true, // enable hidden files
|
|
88
82
|
});
|
|
89
|
-
this.callback(
|
|
90
|
-
var _a;
|
|
91
|
-
if (!((_a = ag.ignore) === null || _a === void 0 ? void 0 : _a.some((ig) => minimatch(src, ig))) &&
|
|
92
|
-
!this.ignore.ignores(src)) {
|
|
93
|
-
const relPath = path.relative(ag.input, src);
|
|
94
|
-
const dest = relPath.startsWith('..') ? src : relPath;
|
|
95
|
-
acc.push({
|
|
96
|
-
type: 'create',
|
|
97
|
-
src: path.join(this.rootDir, src),
|
|
98
|
-
dest: path.join(this.rootDir, ag.output, dest),
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return acc;
|
|
102
|
-
}, []));
|
|
83
|
+
this.callback(this.filesToEvent(files, ag));
|
|
103
84
|
})));
|
|
104
85
|
});
|
|
105
86
|
}
|
|
87
|
+
processAllAssetsOnceSync() {
|
|
88
|
+
this.assetGlobs.forEach((ag) => {
|
|
89
|
+
const pattern = this.normalizeAssetPattern(ag);
|
|
90
|
+
// fast-glob only supports Unix paths
|
|
91
|
+
const files = fg.sync(pattern.replace(/\\/g, '/'), {
|
|
92
|
+
cwd: this.rootDir,
|
|
93
|
+
dot: true, // enable hidden files
|
|
94
|
+
});
|
|
95
|
+
this.callback(this.filesToEvent(files, ag));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
106
98
|
watchAndProcessOnAssetChange() {
|
|
107
99
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
108
100
|
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({
|
|
@@ -118,13 +110,13 @@ class CopyAssetsHandler {
|
|
|
118
110
|
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
119
111
|
}
|
|
120
112
|
else {
|
|
121
|
-
this.
|
|
113
|
+
this.processWatchEvents(data.changedFiles);
|
|
122
114
|
}
|
|
123
115
|
});
|
|
124
116
|
return () => unregisterFileWatcher();
|
|
125
117
|
});
|
|
126
118
|
}
|
|
127
|
-
|
|
119
|
+
processWatchEvents(events) {
|
|
128
120
|
var _a;
|
|
129
121
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
130
122
|
const fileEvents = [];
|
|
@@ -150,6 +142,24 @@ class CopyAssetsHandler {
|
|
|
150
142
|
this.callback(fileEvents);
|
|
151
143
|
});
|
|
152
144
|
}
|
|
145
|
+
filesToEvent(files, assetGlob) {
|
|
146
|
+
return files.reduce((acc, src) => {
|
|
147
|
+
var _a;
|
|
148
|
+
if (!((_a = assetGlob.ignore) === null || _a === void 0 ? void 0 : _a.some((ig) => minimatch(src, ig))) &&
|
|
149
|
+
!this.ignore.ignores(src)) {
|
|
150
|
+
const relPath = path.relative(assetGlob.input, src);
|
|
151
|
+
const dest = relPath.startsWith('..') ? src : relPath;
|
|
152
|
+
acc.push({
|
|
153
|
+
type: 'create',
|
|
154
|
+
src: path.join(this.rootDir, src),
|
|
155
|
+
dest: path.join(this.rootDir, assetGlob.output, dest),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return acc;
|
|
159
|
+
}, []);
|
|
160
|
+
}
|
|
161
|
+
normalizeAssetPattern(assetEntry) {
|
|
162
|
+
return typeof assetEntry === 'string' ? assetEntry : assetEntry.pattern;
|
|
163
|
+
}
|
|
153
164
|
}
|
|
154
165
|
exports.CopyAssetsHandler = CopyAssetsHandler;
|
|
155
|
-
//# sourceMappingURL=copy-assets-handler.js.map
|