@nx/js 0.0.0-pr-22179-271588f
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/LICENSE +22 -0
- package/README.md +68 -0
- package/babel.d.ts +13 -0
- package/babel.js +91 -0
- package/executors.json +32 -0
- package/generators.json +46 -0
- package/migrations.json +159 -0
- package/package.json +76 -0
- package/plugins/jest/local-registry.d.ts +1 -0
- package/plugins/jest/local-registry.js +4 -0
- package/src/executors/node/lib/kill-tree.d.ts +2 -0
- package/src/executors/node/lib/kill-tree.js +114 -0
- package/src/executors/node/node-with-require-overrides.d.ts +7 -0
- package/src/executors/node/node-with-require-overrides.js +21 -0
- package/src/executors/node/node.impl.d.ts +7 -0
- package/src/executors/node/node.impl.js +288 -0
- package/src/executors/node/schema.d.ts +18 -0
- package/src/executors/node/schema.json +92 -0
- package/src/executors/release-publish/format-bytes.d.ts +1 -0
- package/src/executors/release-publish/format-bytes.js +28 -0
- package/src/executors/release-publish/log-tar.d.ts +1 -0
- package/src/executors/release-publish/log-tar.js +68 -0
- package/src/executors/release-publish/release-publish.impl.d.ts +5 -0
- package/src/executors/release-publish/release-publish.impl.js +198 -0
- package/src/executors/release-publish/schema.d.ts +8 -0
- package/src/executors/release-publish/schema.json +26 -0
- package/src/executors/swc/schema.json +154 -0
- package/src/executors/swc/swc.impl.d.ts +10 -0
- package/src/executors/swc/swc.impl.js +149 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.d.ts +5 -0
- package/src/executors/tsc/lib/batch/build-task-info-per-tsconfig-map.js +62 -0
- package/src/executors/tsc/lib/batch/index.d.ts +4 -0
- package/src/executors/tsc/lib/batch/index.js +7 -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 +17 -0
- package/src/executors/tsc/lib/batch/types.js +2 -0
- package/src/executors/tsc/lib/batch/watch.d.ts +3 -0
- package/src/executors/tsc/lib/batch/watch.js +56 -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/get-task-options.d.ts +3 -0
- package/src/executors/tsc/lib/get-task-options.js +34 -0
- package/src/executors/tsc/lib/get-tsconfig.d.ts +4 -0
- package/src/executors/tsc/lib/get-tsconfig.js +86 -0
- package/src/executors/tsc/lib/index.d.ts +4 -0
- package/src/executors/tsc/lib/index.js +7 -0
- package/src/executors/tsc/lib/normalize-options.d.ts +2 -0
- package/src/executors/tsc/lib/normalize-options.js +39 -0
- package/src/executors/tsc/lib/typescript-compilation.d.ts +29 -0
- package/src/executors/tsc/lib/typescript-compilation.js +203 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.d.ts +3 -0
- package/src/executors/tsc/lib/typescript-diagnostic-reporters.js +37 -0
- package/src/executors/tsc/schema.json +163 -0
- package/src/executors/tsc/tsc.batch-impl.d.ts +5 -0
- package/src/executors/tsc/tsc.batch-impl.js +180 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +97 -0
- package/src/executors/verdaccio/schema.d.ts +7 -0
- package/src/executors/verdaccio/schema.json +35 -0
- package/src/executors/verdaccio/verdaccio.impl.d.ts +12 -0
- package/src/executors/verdaccio/verdaccio.impl.js +220 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +4 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +59 -0
- package/src/generators/convert-to-swc/schema.d.ts +4 -0
- package/src/generators/convert-to-swc/schema.json +36 -0
- package/src/generators/init/files/__fileName__ +20 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +114 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +36 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +30 -0
- package/src/generators/library/files/lib/src/index.ts__tmpl__ +1 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ +7 -0
- package/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ +3 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +14 -0
- package/src/generators/library/files/readme/README.md +19 -0
- package/src/generators/library/library.d.ts +16 -0
- package/src/generators/library/library.js +751 -0
- package/src/generators/library/schema.json +151 -0
- package/src/generators/release-version/release-version.d.ts +5 -0
- package/src/generators/release-version/release-version.js +390 -0
- package/src/generators/release-version/schema.d.ts +1 -0
- package/src/generators/release-version/schema.json +67 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.d.ts +16 -0
- package/src/generators/release-version/test-utils/create-workspace-with-package-dependencies.js +40 -0
- package/src/generators/release-version/utils/package.d.ts +12 -0
- package/src/generators/release-version/utils/package.js +34 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.d.ts +12 -0
- package/src/generators/release-version/utils/resolve-local-package-dependencies.js +78 -0
- package/src/generators/release-version/utils/resolve-version-spec.d.ts +1 -0
- package/src/generators/release-version/utils/resolve-version-spec.js +29 -0
- package/src/generators/release-version/utils/update-lock-file.d.ts +5 -0
- package/src/generators/release-version/utils/update-lock-file.js +105 -0
- package/src/generators/setup-build/generator.d.ts +4 -0
- package/src/generators/setup-build/generator.js +142 -0
- package/src/generators/setup-build/schema.d.ts +7 -0
- package/src/generators/setup-build/schema.json +42 -0
- package/src/generators/setup-verdaccio/files/config.yml +28 -0
- package/src/generators/setup-verdaccio/generator.d.ts +4 -0
- package/src/generators/setup-verdaccio/generator.js +56 -0
- package/src/generators/setup-verdaccio/schema.d.ts +3 -0
- package/src/generators/setup-verdaccio/schema.json +16 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +28 -0
- package/src/internal.d.ts +4 -0
- package/src/internal.js +15 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.d.ts +2 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js +77 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.d.ts +2 -0
- package/src/migrations/update-16-6-0/explicitly-set-projects-to-update-buildable-deps.js +34 -0
- package/src/migrations/update-16-8-2/update-swcrc.d.ts +2 -0
- package/src/migrations/update-16-8-2/update-swcrc.js +23 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.d.ts +6 -0
- package/src/migrations/update-17-0-0/remove-deprecated-build-options.js +30 -0
- package/src/plugins/jest/start-local-registry.d.ts +12 -0
- package/src/plugins/jest/start-local-registry.js +63 -0
- package/src/plugins/rollup/type-definitions.d.ts +8 -0
- package/src/plugins/rollup/type-definitions.js +48 -0
- package/src/utils/add-babel-inputs.d.ts +3 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-local-registry-scripts.d.ts +5 -0
- package/src/utils/add-local-registry-scripts.js +77 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +36 -0
- package/src/utils/assets/copy-assets-handler.d.ts +32 -0
- package/src/utils/assets/copy-assets-handler.js +154 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +27 -0
- package/src/utils/buildable-libs-utils.d.ts +43 -0
- package/src/utils/buildable-libs-utils.js +375 -0
- package/src/utils/check-dependencies.d.ts +8 -0
- package/src/utils/check-dependencies.js +23 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +86 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +52 -0
- package/src/utils/compiler-helper-dependency.d.ts +18 -0
- package/src/utils/compiler-helper-dependency.js +120 -0
- package/src/utils/find-npm-dependencies.d.ts +9 -0
- package/src/utils/find-npm-dependencies.js +140 -0
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +80 -0
- package/src/utils/get-import-path.d.ts +5 -0
- package/src/utils/get-import-path.js +14 -0
- package/src/utils/get-main-file-dir.d.ts +1 -0
- package/src/utils/get-main-file-dir.js +11 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +210 -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/get-npm-scope.d.ts +5 -0
- package/src/utils/package-json/get-npm-scope.js +16 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +30 -0
- package/src/utils/package-json/update-package-json.d.ts +30 -0
- package/src/utils/package-json/update-package-json.js +179 -0
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +34 -0
- package/src/utils/schema.d.ts +87 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +41 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +3 -0
- package/src/utils/swc/add-swc-dependencies.js +18 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +160 -0
- package/src/utils/swc/get-swcrc-path.d.ts +5 -0
- package/src/utils/swc/get-swcrc-path.js +15 -0
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +11 -0
- package/src/utils/typescript/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +5 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +5 -0
- package/src/utils/typescript/add-tslib-dependencies.d.ts +2 -0
- package/src/utils/typescript/add-tslib-dependencies.js +11 -0
- package/src/utils/typescript/ast-utils.d.ts +32 -0
- package/src/utils/typescript/ast-utils.js +266 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +10 -0
- package/src/utils/typescript/compile-typescript-files.js +43 -0
- package/src/utils/typescript/create-ts-config.d.ts +18 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +9 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +18 -0
- package/src/utils/typescript/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +62 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +18 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +128 -0
- package/src/utils/typescript/ts-config.d.ts +9 -0
- package/src/utils/typescript/ts-config.js +85 -0
- package/src/utils/typescript/tsnode-register.d.ts +1 -0
- package/src/utils/typescript/tsnode-register.js +24 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +2 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +21 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +22 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRootTsConfigPath = exports.postProcessInlinedDependencies = exports.handleInliningBuild = exports.isInlineGraphEmpty = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
function isInlineGraphEmpty(inlineGraph) {
|
|
9
|
+
return Object.keys(inlineGraph.nodes).length === 0;
|
|
10
|
+
}
|
|
11
|
+
exports.isInlineGraphEmpty = isInlineGraphEmpty;
|
|
12
|
+
function handleInliningBuild(context, options, tsConfigPath, projectName = context.projectName) {
|
|
13
|
+
const tsConfigJson = (0, devkit_1.readJsonFile)(tsConfigPath);
|
|
14
|
+
const pathAliases = tsConfigJson['compilerOptions']?.['paths'] || readBasePathAliases(context);
|
|
15
|
+
const inlineGraph = createInlineGraph(context, options, pathAliases, projectName);
|
|
16
|
+
if (isInlineGraphEmpty(inlineGraph)) {
|
|
17
|
+
return inlineGraph;
|
|
18
|
+
}
|
|
19
|
+
buildInlineGraphExternals(context, inlineGraph, pathAliases);
|
|
20
|
+
return inlineGraph;
|
|
21
|
+
}
|
|
22
|
+
exports.handleInliningBuild = handleInliningBuild;
|
|
23
|
+
function postProcessInlinedDependencies(outputPath, parentOutputPath, inlineGraph) {
|
|
24
|
+
if (isInlineGraphEmpty(inlineGraph)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const parentDistPath = (0, path_1.join)(outputPath, parentOutputPath);
|
|
28
|
+
const markedForDeletion = new Set();
|
|
29
|
+
// move parentOutput
|
|
30
|
+
movePackage(parentDistPath, outputPath);
|
|
31
|
+
markedForDeletion.add(parentDistPath);
|
|
32
|
+
const inlinedDepsDestOutputRecord = {};
|
|
33
|
+
// move inlined outputs
|
|
34
|
+
for (const inlineDependenciesNames of Object.values(inlineGraph.dependencies)) {
|
|
35
|
+
for (const inlineDependenciesName of inlineDependenciesNames) {
|
|
36
|
+
const inlineDependency = inlineGraph.nodes[inlineDependenciesName];
|
|
37
|
+
const depOutputPath = inlineDependency.buildOutputPath ||
|
|
38
|
+
(0, path_1.join)(outputPath, inlineDependency.root);
|
|
39
|
+
const destDepOutputPath = (0, path_1.join)(outputPath, inlineDependency.name);
|
|
40
|
+
const isBuildable = !!inlineDependency.buildOutputPath;
|
|
41
|
+
if (isBuildable) {
|
|
42
|
+
(0, fs_extra_1.copySync)(depOutputPath, destDepOutputPath, { overwrite: true });
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
movePackage(depOutputPath, destDepOutputPath);
|
|
46
|
+
markedForDeletion.add(depOutputPath);
|
|
47
|
+
}
|
|
48
|
+
// TODO: hard-coded "src"
|
|
49
|
+
inlinedDepsDestOutputRecord[inlineDependency.pathAlias] =
|
|
50
|
+
destDepOutputPath + '/src';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
markedForDeletion.forEach((path) => (0, fs_extra_1.removeSync)(path));
|
|
54
|
+
updateImports(outputPath, inlinedDepsDestOutputRecord);
|
|
55
|
+
}
|
|
56
|
+
exports.postProcessInlinedDependencies = postProcessInlinedDependencies;
|
|
57
|
+
function readBasePathAliases(context) {
|
|
58
|
+
return (0, devkit_1.readJsonFile)(getRootTsConfigPath(context))?.['compilerOptions']['paths'];
|
|
59
|
+
}
|
|
60
|
+
function getRootTsConfigPath(context) {
|
|
61
|
+
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
62
|
+
const tsConfigPath = (0, path_1.join)(context.root, tsConfigName);
|
|
63
|
+
if ((0, fs_1.existsSync)(tsConfigPath)) {
|
|
64
|
+
return tsConfigPath;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new Error('Could not find a root tsconfig.json or tsconfig.base.json file.');
|
|
68
|
+
}
|
|
69
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
70
|
+
function emptyInlineGraph() {
|
|
71
|
+
return { nodes: {}, externals: {}, dependencies: {} };
|
|
72
|
+
}
|
|
73
|
+
function projectNodeToInlineProjectNode(projectNode, pathAlias = '', buildOutputPath = '') {
|
|
74
|
+
return {
|
|
75
|
+
name: projectNode.name,
|
|
76
|
+
root: projectNode.data.root,
|
|
77
|
+
sourceRoot: projectNode.data.sourceRoot,
|
|
78
|
+
pathAlias,
|
|
79
|
+
buildOutputPath,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function createInlineGraph(context, options, pathAliases, projectName, inlineGraph = emptyInlineGraph()) {
|
|
83
|
+
if (options.external == null)
|
|
84
|
+
return inlineGraph;
|
|
85
|
+
const projectDependencies = context.projectGraph.dependencies[projectName] || [];
|
|
86
|
+
if (projectDependencies.length === 0)
|
|
87
|
+
return inlineGraph;
|
|
88
|
+
if (!inlineGraph.nodes[projectName]) {
|
|
89
|
+
inlineGraph.nodes[projectName] = projectNodeToInlineProjectNode(context.projectGraph.nodes[projectName]);
|
|
90
|
+
}
|
|
91
|
+
const implicitDependencies = context.projectGraph.nodes[projectName].data.implicitDependencies || [];
|
|
92
|
+
for (const projectDependency of projectDependencies) {
|
|
93
|
+
// skip npm packages
|
|
94
|
+
if (projectDependency.target.startsWith('npm')) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
// skip implicitDependencies
|
|
98
|
+
if (implicitDependencies.includes(projectDependency.target)) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const pathAlias = getPathAliasForPackage(context.projectGraph.nodes[projectDependency.target], pathAliases);
|
|
102
|
+
const buildOutputPath = getBuildOutputPath(projectDependency.target, context, options);
|
|
103
|
+
const shouldInline =
|
|
104
|
+
/**
|
|
105
|
+
* if all buildable libraries are marked as external,
|
|
106
|
+
* then push the project dependency that doesn't have a build target
|
|
107
|
+
*/
|
|
108
|
+
(options.external === 'all' && !buildOutputPath) ||
|
|
109
|
+
/**
|
|
110
|
+
* if all buildable libraries are marked as internal,
|
|
111
|
+
* then push every project dependency to be inlined
|
|
112
|
+
*/
|
|
113
|
+
options.external === 'none' ||
|
|
114
|
+
/**
|
|
115
|
+
* if some buildable libraries are marked as external,
|
|
116
|
+
* then push the project dependency that IS NOT marked as external OR doesn't have a build target
|
|
117
|
+
*/
|
|
118
|
+
(Array.isArray(options.external) &&
|
|
119
|
+
options.external.length > 0 &&
|
|
120
|
+
!options.external.includes(projectDependency.target)) ||
|
|
121
|
+
!buildOutputPath;
|
|
122
|
+
if (shouldInline) {
|
|
123
|
+
inlineGraph.dependencies[projectName] ??= [];
|
|
124
|
+
inlineGraph.dependencies[projectName].push(projectDependency.target);
|
|
125
|
+
}
|
|
126
|
+
inlineGraph.nodes[projectDependency.target] =
|
|
127
|
+
projectNodeToInlineProjectNode(context.projectGraph.nodes[projectDependency.target], pathAlias, buildOutputPath);
|
|
128
|
+
if (context.projectGraph.dependencies[projectDependency.target].length > 0) {
|
|
129
|
+
inlineGraph = createInlineGraph(context, options, pathAliases, projectDependency.target, inlineGraph);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return inlineGraph;
|
|
133
|
+
}
|
|
134
|
+
function buildInlineGraphExternals(context, inlineProjectGraph, pathAliases) {
|
|
135
|
+
const allNodes = { ...context.projectGraph.nodes };
|
|
136
|
+
for (const [parent, dependencies] of Object.entries(inlineProjectGraph.dependencies)) {
|
|
137
|
+
if (allNodes[parent]) {
|
|
138
|
+
delete allNodes[parent];
|
|
139
|
+
}
|
|
140
|
+
for (const dependencyName of dependencies) {
|
|
141
|
+
const dependencyNode = inlineProjectGraph.nodes[dependencyName];
|
|
142
|
+
// buildable is still external even if it is a dependency
|
|
143
|
+
if (dependencyNode.buildOutputPath) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (allNodes[dependencyName]) {
|
|
147
|
+
delete allNodes[dependencyName];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const [projectName, projectNode] of Object.entries(allNodes)) {
|
|
152
|
+
if (!inlineProjectGraph.externals[projectName]) {
|
|
153
|
+
inlineProjectGraph.externals[projectName] =
|
|
154
|
+
projectNodeToInlineProjectNode(projectNode, getPathAliasForPackage(projectNode, pathAliases));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function movePackage(from, to) {
|
|
159
|
+
if (from === to)
|
|
160
|
+
return;
|
|
161
|
+
(0, fs_extra_1.copySync)(from, to, { overwrite: true });
|
|
162
|
+
}
|
|
163
|
+
function updateImports(destOutputPath, inlinedDepsDestOutputRecord) {
|
|
164
|
+
const pathAliases = Object.keys(inlinedDepsDestOutputRecord);
|
|
165
|
+
if (pathAliases.length == 0) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const importRegex = new RegExp(pathAliases.map((pathAlias) => `["'](${pathAlias})["']`).join('|'), 'g');
|
|
169
|
+
recursiveUpdateImport(destOutputPath, importRegex, inlinedDepsDestOutputRecord);
|
|
170
|
+
}
|
|
171
|
+
function recursiveUpdateImport(dirPath, importRegex, inlinedDepsDestOutputRecord, rootParentDir) {
|
|
172
|
+
const files = (0, fs_extra_1.readdirSync)(dirPath, { withFileTypes: true });
|
|
173
|
+
for (const file of files) {
|
|
174
|
+
// only check .js and .d.ts files
|
|
175
|
+
if (file.isFile() &&
|
|
176
|
+
(file.name.endsWith('.js') || file.name.endsWith('.d.ts'))) {
|
|
177
|
+
const filePath = (0, path_1.join)(dirPath, file.name);
|
|
178
|
+
const fileContent = (0, fs_extra_1.readFileSync)(filePath, 'utf-8');
|
|
179
|
+
const updatedContent = fileContent.replace(importRegex, (matched) => {
|
|
180
|
+
const result = matched.replace(/['"]/g, '');
|
|
181
|
+
// If a match is the same as the rootParentDir, we're checking its own files so we return the matched as in no changes.
|
|
182
|
+
if (result === rootParentDir || !inlinedDepsDestOutputRecord[result])
|
|
183
|
+
return matched;
|
|
184
|
+
const importPath = `"${(0, path_1.relative)(dirPath, inlinedDepsDestOutputRecord[result])}"`;
|
|
185
|
+
return (0, devkit_1.normalizePath)(importPath);
|
|
186
|
+
});
|
|
187
|
+
(0, fs_extra_1.writeFileSync)(filePath, updatedContent);
|
|
188
|
+
}
|
|
189
|
+
else if (file.isDirectory()) {
|
|
190
|
+
recursiveUpdateImport((0, path_1.join)(dirPath, file.name), importRegex, inlinedDepsDestOutputRecord, rootParentDir || file.name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function getPathAliasForPackage(packageNode, pathAliases) {
|
|
195
|
+
if (!packageNode)
|
|
196
|
+
return '';
|
|
197
|
+
for (const [alias, paths] of Object.entries(pathAliases)) {
|
|
198
|
+
if (paths.some((path) => path.includes(packageNode.data.root))) {
|
|
199
|
+
return alias;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return '';
|
|
203
|
+
}
|
|
204
|
+
function getBuildOutputPath(projectName, context, options) {
|
|
205
|
+
const projectTargets = context.projectGraph.nodes[projectName]?.data?.targets;
|
|
206
|
+
if (!projectTargets)
|
|
207
|
+
return '';
|
|
208
|
+
const buildTarget = options.externalBuildTargets.find((buildTarget) => projectTargets[buildTarget]);
|
|
209
|
+
return buildTarget ? projectTargets[buildTarget].options['outputPath'] : '';
|
|
210
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNpmScope = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* Read the npm scope that a workspace should use by default
|
|
7
|
+
*/
|
|
8
|
+
function getNpmScope(tree) {
|
|
9
|
+
const { name } = tree.exists('package.json')
|
|
10
|
+
? (0, devkit_1.readJson)(tree, 'package.json')
|
|
11
|
+
: { name: null };
|
|
12
|
+
if (name?.startsWith('@')) {
|
|
13
|
+
return name.split('/')[0].substring(1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.getNpmScope = getNpmScope;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
3
|
+
import type { UpdatePackageJsonOption } from './update-package-json';
|
|
4
|
+
export interface CopyPackageJsonOptions extends Omit<UpdatePackageJsonOption, 'projectRoot'> {
|
|
5
|
+
watch?: boolean;
|
|
6
|
+
extraDependencies?: DependentBuildableProjectNode[];
|
|
7
|
+
overrideDependencies?: DependentBuildableProjectNode[];
|
|
8
|
+
}
|
|
9
|
+
export interface CopyPackageJsonResult {
|
|
10
|
+
success?: boolean;
|
|
11
|
+
stop?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function copyPackageJson(_options: CopyPackageJsonOptions, context: ExecutorContext): Promise<CopyPackageJsonResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyPackageJson = void 0;
|
|
4
|
+
const watch_for_single_file_changes_1 = require("../watch-for-single-file-changes");
|
|
5
|
+
const update_package_json_1 = require("./update-package-json");
|
|
6
|
+
const check_dependencies_1 = require("../check-dependencies");
|
|
7
|
+
async function copyPackageJson(_options, context) {
|
|
8
|
+
if (!context.target.options.tsConfig) {
|
|
9
|
+
throw new Error(`Could not find tsConfig option for "${context.targetName}" target of "${context.projectName}" project. Check that your project configuration is correct.`);
|
|
10
|
+
}
|
|
11
|
+
let { target, dependencies, projectRoot } = (0, check_dependencies_1.checkDependencies)(context, context.target.options.tsConfig);
|
|
12
|
+
const options = { ..._options, projectRoot };
|
|
13
|
+
if (options.extraDependencies) {
|
|
14
|
+
dependencies.push(...options.extraDependencies);
|
|
15
|
+
}
|
|
16
|
+
if (options.overrideDependencies) {
|
|
17
|
+
dependencies = options.overrideDependencies;
|
|
18
|
+
}
|
|
19
|
+
if (options.watch) {
|
|
20
|
+
const dispose = await (0, watch_for_single_file_changes_1.watchForSingleFileChanges)(context.projectName, options.projectRoot, 'package.json', () => (0, update_package_json_1.updatePackageJson)(options, context, target, dependencies));
|
|
21
|
+
// Copy it once before changes
|
|
22
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
|
|
23
|
+
return { success: true, stop: dispose };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
(0, update_package_json_1.updatePackageJson)(options, context, target, dependencies);
|
|
27
|
+
return { success: true };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.copyPackageJson = copyPackageJson;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExecutorContext, ProjectFileMap, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
+
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
3
|
+
import type { PackageJson } from 'nx/src/utils/package-json';
|
|
4
|
+
export type SupportedFormat = 'cjs' | 'esm';
|
|
5
|
+
export interface UpdatePackageJsonOption {
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
main: string;
|
|
8
|
+
additionalEntryPoints?: string[];
|
|
9
|
+
format?: SupportedFormat[];
|
|
10
|
+
outputPath: string;
|
|
11
|
+
outputFileName?: string;
|
|
12
|
+
outputFileExtensionForCjs?: `.${string}`;
|
|
13
|
+
outputFileExtensionForEsm?: `.${string}`;
|
|
14
|
+
skipTypings?: boolean;
|
|
15
|
+
generateExportsField?: boolean;
|
|
16
|
+
excludeLibsInPackageJson?: boolean;
|
|
17
|
+
updateBuildableProjectDepsInPackageJson?: boolean;
|
|
18
|
+
buildableProjectDepsInPackageJsonType?: 'dependencies' | 'peerDependencies';
|
|
19
|
+
generateLockfile?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function updatePackageJson(options: UpdatePackageJsonOption, context: ExecutorContext, target: ProjectGraphProjectNode, dependencies: DependentBuildableProjectNode[], fileMap?: ProjectFileMap): void;
|
|
22
|
+
interface Exports {
|
|
23
|
+
'.': string;
|
|
24
|
+
[name: string]: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function getExports(options: Pick<UpdatePackageJsonOption, 'main' | 'projectRoot' | 'outputFileName' | 'additionalEntryPoints'> & {
|
|
27
|
+
fileExt: string;
|
|
28
|
+
}): Exports;
|
|
29
|
+
export declare function getUpdatedPackageJsonContent(packageJson: PackageJson, options: UpdatePackageJsonOption): PackageJson;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUpdatedPackageJsonContent = exports.getExports = exports.updatePackageJson = void 0;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
5
|
+
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
7
|
+
const create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
14
|
+
const get_main_file_dir_1 = require("../get-main-file-dir");
|
|
15
|
+
function updatePackageJson(options, context, target, dependencies, fileMap = null) {
|
|
16
|
+
let packageJson;
|
|
17
|
+
if (fileMap == null) {
|
|
18
|
+
fileMap = (0, nx_deps_cache_1.readFileMapCache)()?.fileMap?.projectFileMap || {};
|
|
19
|
+
}
|
|
20
|
+
if (options.updateBuildableProjectDepsInPackageJson) {
|
|
21
|
+
packageJson = (0, create_package_json_1.createPackageJson)(context.projectName, context.projectGraph, {
|
|
22
|
+
target: context.targetName,
|
|
23
|
+
root: context.root,
|
|
24
|
+
// By default we remove devDependencies since this is a production build.
|
|
25
|
+
isProduction: true,
|
|
26
|
+
}, fileMap);
|
|
27
|
+
if (options.excludeLibsInPackageJson) {
|
|
28
|
+
dependencies = dependencies.filter((dep) => dep.node.type !== 'lib');
|
|
29
|
+
}
|
|
30
|
+
addMissingDependencies(packageJson, context, dependencies, options.buildableProjectDepsInPackageJsonType);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const pathToPackageJson = (0, path_1.join)(context.root, options.projectRoot, 'package.json');
|
|
34
|
+
packageJson = (0, fileutils_1.fileExists)(pathToPackageJson)
|
|
35
|
+
? (0, devkit_1.readJsonFile)(pathToPackageJson)
|
|
36
|
+
: { name: context.projectName, version: '0.0.1' };
|
|
37
|
+
}
|
|
38
|
+
// update package specific settings
|
|
39
|
+
packageJson = getUpdatedPackageJsonContent(packageJson, options);
|
|
40
|
+
// save files
|
|
41
|
+
(0, devkit_1.writeJsonFile)(`${options.outputPath}/package.json`, packageJson);
|
|
42
|
+
if (options.generateLockfile) {
|
|
43
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.root);
|
|
44
|
+
const lockFile = (0, lock_file_1.createLockFile)(packageJson, context.projectGraph, packageManager);
|
|
45
|
+
(0, fs_extra_1.writeFileSync)(`${options.outputPath}/${(0, lock_file_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
46
|
+
encoding: 'utf-8',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.updatePackageJson = updatePackageJson;
|
|
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') {
|
|
58
|
+
const workspacePackageJson = (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'package.json'));
|
|
59
|
+
dependencies.forEach((entry) => {
|
|
60
|
+
if (isNpmNode(entry.node, projectGraph)) {
|
|
61
|
+
const { packageName, version } = entry.node.data;
|
|
62
|
+
if (packageJson.dependencies?.[packageName] ||
|
|
63
|
+
packageJson.devDependencies?.[packageName] ||
|
|
64
|
+
packageJson.peerDependencies?.[packageName]) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (workspacePackageJson.devDependencies?.[packageName]) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
packageJson[propType] ??= {};
|
|
71
|
+
packageJson[propType][packageName] = version;
|
|
72
|
+
}
|
|
73
|
+
else if (isWorkspaceProject(entry.node, projectGraph)) {
|
|
74
|
+
const packageName = entry.name;
|
|
75
|
+
if (!!workspacePackageJson.devDependencies?.[packageName]) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!packageJson.dependencies?.[packageName] &&
|
|
79
|
+
!packageJson.devDependencies?.[packageName] &&
|
|
80
|
+
!packageJson.peerDependencies?.[packageName]) {
|
|
81
|
+
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
82
|
+
project: projectName,
|
|
83
|
+
target: targetName,
|
|
84
|
+
configuration: configurationName,
|
|
85
|
+
}, {}, entry.node);
|
|
86
|
+
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
87
|
+
if ((0, fs_1.existsSync)(depPackageJsonPath)) {
|
|
88
|
+
const version = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
89
|
+
packageJson[propType] ??= {};
|
|
90
|
+
packageJson[propType][packageName] = version;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function getExports(options) {
|
|
97
|
+
const mainFile = options.outputFileName
|
|
98
|
+
? options.outputFileName.replace(/\.[tj]s$/, '')
|
|
99
|
+
: (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
|
|
100
|
+
const relativeMainFileDir = options.outputFileName
|
|
101
|
+
? './'
|
|
102
|
+
: (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
|
|
103
|
+
const exports = {
|
|
104
|
+
'.': relativeMainFileDir + mainFile + options.fileExt,
|
|
105
|
+
};
|
|
106
|
+
if (options.additionalEntryPoints) {
|
|
107
|
+
const jsRegex = /\.[jt]sx?$/;
|
|
108
|
+
for (const file of options.additionalEntryPoints) {
|
|
109
|
+
const { ext: fileExt, name: fileName } = (0, path_1.parse)(file);
|
|
110
|
+
const relativeDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(file, options.projectRoot);
|
|
111
|
+
const sourceFilePath = relativeDir + fileName;
|
|
112
|
+
const entryFilepath = sourceFilePath.replace(/^\.\/src\//, './');
|
|
113
|
+
const isJsFile = jsRegex.test(fileExt);
|
|
114
|
+
exports[isJsFile ? entryFilepath : entryFilepath + fileExt] =
|
|
115
|
+
sourceFilePath + (isJsFile ? options.fileExt : fileExt);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return exports;
|
|
119
|
+
}
|
|
120
|
+
exports.getExports = getExports;
|
|
121
|
+
function getUpdatedPackageJsonContent(packageJson, options) {
|
|
122
|
+
// Default is CJS unless esm is explicitly passed.
|
|
123
|
+
const hasCjsFormat = !options.format || options.format?.includes('cjs');
|
|
124
|
+
const hasEsmFormat = options.format?.includes('esm');
|
|
125
|
+
if (options.generateExportsField) {
|
|
126
|
+
packageJson.exports =
|
|
127
|
+
typeof packageJson.exports === 'string' ? {} : { ...packageJson.exports };
|
|
128
|
+
packageJson.exports['./package.json'] = './package.json';
|
|
129
|
+
}
|
|
130
|
+
if (hasEsmFormat) {
|
|
131
|
+
const esmExports = getExports({
|
|
132
|
+
...options,
|
|
133
|
+
fileExt: options.outputFileExtensionForEsm ?? '.js',
|
|
134
|
+
});
|
|
135
|
+
packageJson.module = esmExports['.'];
|
|
136
|
+
if (!hasCjsFormat) {
|
|
137
|
+
packageJson.type = 'module';
|
|
138
|
+
packageJson.main ??= esmExports['.'];
|
|
139
|
+
}
|
|
140
|
+
if (options.generateExportsField) {
|
|
141
|
+
for (const [exportEntry, filePath] of Object.entries(esmExports)) {
|
|
142
|
+
packageJson.exports[exportEntry] = hasCjsFormat
|
|
143
|
+
? { import: filePath }
|
|
144
|
+
: filePath;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// CJS output may have .cjs or .js file extensions.
|
|
149
|
+
// Bundlers like rollup and esbuild supports .cjs for CJS and .js for ESM.
|
|
150
|
+
// Bundlers/Compilers like webpack, tsc, swc do not have different file extensions (unless you use .mts or .cts in source).
|
|
151
|
+
if (hasCjsFormat) {
|
|
152
|
+
const cjsExports = getExports({
|
|
153
|
+
...options,
|
|
154
|
+
fileExt: options.outputFileExtensionForCjs ?? '.js',
|
|
155
|
+
});
|
|
156
|
+
packageJson.main = cjsExports['.'];
|
|
157
|
+
if (!hasEsmFormat) {
|
|
158
|
+
packageJson.type = 'commonjs';
|
|
159
|
+
}
|
|
160
|
+
if (options.generateExportsField) {
|
|
161
|
+
for (const [exportEntry, filePath] of Object.entries(cjsExports)) {
|
|
162
|
+
if (hasEsmFormat) {
|
|
163
|
+
packageJson.exports[exportEntry]['default'] ??= filePath;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
packageJson.exports[exportEntry] = filePath;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!options.skipTypings) {
|
|
172
|
+
const mainFile = (0, path_1.basename)(options.main).replace(/\.[tj]s$/, '');
|
|
173
|
+
const relativeMainFileDir = (0, get_main_file_dir_1.getRelativeDirectoryToProjectRoot)(options.main, options.projectRoot);
|
|
174
|
+
const typingsFile = `${relativeMainFileDir}${mainFile}.d.ts`;
|
|
175
|
+
packageJson.types = packageJson.types ?? typingsFile;
|
|
176
|
+
}
|
|
177
|
+
return packageJson;
|
|
178
|
+
}
|
|
179
|
+
exports.getUpdatedPackageJsonContent = getUpdatedPackageJsonContent;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveUserExistingPrettierConfig = void 0;
|
|
4
|
+
let prettier;
|
|
5
|
+
try {
|
|
6
|
+
prettier = require('prettier');
|
|
7
|
+
}
|
|
8
|
+
catch { }
|
|
9
|
+
async function resolveUserExistingPrettierConfig() {
|
|
10
|
+
if (!prettier) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const filepath = await prettier.resolveConfigFile();
|
|
15
|
+
if (!filepath) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const config = await prettier.resolveConfig(process.cwd(), {
|
|
19
|
+
useCache: false,
|
|
20
|
+
config: filepath,
|
|
21
|
+
});
|
|
22
|
+
if (!config) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
sourceFilepath: filepath,
|
|
27
|
+
config: config,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.resolveUserExistingPrettierConfig = resolveUserExistingPrettierConfig;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { AssetGlob, FileInputOutput } from './assets/assets';
|
|
3
|
+
import { TransformerEntry } from './typescript/types';
|
|
4
|
+
// nx-ignore-next-line
|
|
5
|
+
const { Linter } = require('@nx/eslint'); // use require to import to avoid circular dependency
|
|
6
|
+
|
|
7
|
+
export type Compiler = 'tsc' | 'swc';
|
|
8
|
+
export type Bundler = 'swc' | 'tsc' | 'rollup' | 'vite' | 'esbuild' | 'none';
|
|
9
|
+
|
|
10
|
+
export interface LibraryGeneratorSchema {
|
|
11
|
+
name: string;
|
|
12
|
+
directory?: string;
|
|
13
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
14
|
+
skipFormat?: boolean;
|
|
15
|
+
tags?: string;
|
|
16
|
+
skipTsConfig?: boolean;
|
|
17
|
+
skipPackageJson?: boolean;
|
|
18
|
+
includeBabelRc?: boolean;
|
|
19
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
20
|
+
linter?: Linter;
|
|
21
|
+
testEnvironment?: 'jsdom' | 'node';
|
|
22
|
+
importPath?: string;
|
|
23
|
+
js?: boolean;
|
|
24
|
+
pascalCaseFiles?: boolean;
|
|
25
|
+
strict?: boolean;
|
|
26
|
+
publishable?: boolean;
|
|
27
|
+
buildable?: boolean;
|
|
28
|
+
setParserOptionsProject?: boolean;
|
|
29
|
+
config?: 'workspace' | 'project' | 'npm-scripts';
|
|
30
|
+
compiler?: Compiler;
|
|
31
|
+
bundler?: Bundler;
|
|
32
|
+
skipTypeCheck?: boolean;
|
|
33
|
+
minimal?: boolean;
|
|
34
|
+
rootProject?: boolean;
|
|
35
|
+
simpleName?: boolean;
|
|
36
|
+
addPlugin?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ExecutorOptions {
|
|
40
|
+
assets: Array<AssetGlob | string>;
|
|
41
|
+
main: string;
|
|
42
|
+
rootDir?: string;
|
|
43
|
+
outputPath: string;
|
|
44
|
+
tsConfig: string;
|
|
45
|
+
generateExportsField?: boolean;
|
|
46
|
+
additionalEntryPoints?: string[];
|
|
47
|
+
swcrc?: string;
|
|
48
|
+
watch: boolean;
|
|
49
|
+
clean?: boolean;
|
|
50
|
+
transformers: TransformerEntry[];
|
|
51
|
+
external?: 'all' | 'none' | string[];
|
|
52
|
+
externalBuildTargets?: string[];
|
|
53
|
+
generateLockfile?: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface NormalizedExecutorOptions extends ExecutorOptions {
|
|
57
|
+
rootDir: string;
|
|
58
|
+
projectRoot: string;
|
|
59
|
+
mainOutputPath: string;
|
|
60
|
+
files: Array<FileInputOutput>;
|
|
61
|
+
root?: string;
|
|
62
|
+
sourceRoot?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface SwcExecutorOptions extends ExecutorOptions {
|
|
66
|
+
skipTypeCheck?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated
|
|
69
|
+
*/
|
|
70
|
+
swcExclude?: string[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SwcCliOptions {
|
|
74
|
+
srcPath: string;
|
|
75
|
+
destPath: string;
|
|
76
|
+
swcrcPath: string;
|
|
77
|
+
swcCwd: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface NormalizedSwcExecutorOptions
|
|
81
|
+
extends NormalizedExecutorOptions {
|
|
82
|
+
originalProjectRoot: string;
|
|
83
|
+
swcExclude: string[];
|
|
84
|
+
skipTypeCheck: boolean;
|
|
85
|
+
swcCliOptions: SwcCliOptions;
|
|
86
|
+
tmpSwcrcPath: string;
|
|
87
|
+
}
|