@nrwl/js 14.8.7 → 14.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/CHANGELOG.md +1 -1
- package/LICENSE +22 -22
- package/README.md +5 -26
- package/babel.d.ts +10 -0
- package/babel.js +89 -0
- package/babel.js.map +1 -0
- package/generators.json +4 -2
- package/migrations.json +20 -1
- package/package.json +19 -10
- package/src/executors/node/node.impl.js +36 -28
- package/src/executors/node/node.impl.js.map +1 -1
- package/src/executors/node/schema.json +3 -1
- package/src/executors/swc/schema.json +39 -5
- package/src/executors/swc/swc.impl.d.ts +4 -0
- package/src/executors/swc/swc.impl.js +56 -6
- package/src/executors/swc/swc.impl.js.map +1 -1
- package/src/executors/tsc/schema.json +36 -3
- package/src/executors/tsc/tsc.impl.d.ts +2 -5
- package/src/executors/tsc/tsc.impl.js +35 -13
- package/src/executors/tsc/tsc.impl.js.map +1 -1
- package/src/generators/convert-to-swc/convert-to-swc.js +2 -4
- package/src/generators/convert-to-swc/convert-to-swc.js.map +1 -1
- package/src/generators/init/files/__fileName__ +20 -0
- package/src/generators/init/init.d.ts +4 -2
- package/src/generators/init/init.js +59 -2
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/init/schema.d.ts +6 -0
- package/src/generators/init/schema.json +24 -1
- package/src/generators/library/files/jest-config/jest.config.__ext__ +8 -1
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +2 -2
- package/src/generators/library/library.js +136 -85
- package/src/generators/library/library.js.map +1 -1
- package/src/generators/library/schema.json +29 -19
- package/src/index.d.ts +8 -0
- package/src/index.js +12 -1
- package/src/index.js.map +1 -1
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +1 -1
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +1 -1
- package/src/migrations/update-13-8-5/update-swcrc.js +2 -2
- package/src/migrations/update-13-8-5/update-swcrc.js.map +1 -1
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +1 -1
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +1 -1
- package/src/migrations/update-14-1-5/update-swcrc-path.js +1 -1
- package/src/migrations/update-14-1-5/update-swcrc-path.js.map +1 -1
- 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 +81 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +1 -0
- package/src/utils/add-babel-inputs.d.ts +2 -0
- package/src/utils/add-babel-inputs.js +27 -0
- package/src/utils/add-babel-inputs.js.map +1 -0
- package/src/utils/assets/copy-assets-handler.d.ts +2 -2
- package/src/utils/assets/copy-assets-handler.js +12 -5
- package/src/utils/assets/copy-assets-handler.js.map +1 -1
- package/src/utils/assets/index.js +11 -14
- package/src/utils/assets/index.js.map +1 -1
- package/src/utils/buildable-libs-utils.d.ts +32 -0
- package/src/utils/buildable-libs-utils.js +309 -0
- package/src/utils/buildable-libs-utils.js.map +1 -0
- package/src/utils/check-dependencies.d.ts +2 -2
- package/src/utils/check-dependencies.js +1 -1
- package/src/utils/check-dependencies.js.map +1 -1
- package/src/utils/code-frames/identifiers.d.ts +0 -20
- package/src/utils/code-frames/identifiers.js +38 -184
- package/src/utils/code-frames/identifiers.js.map +1 -1
- package/src/utils/compiler-helper-dependency.d.ts +1 -1
- package/src/utils/compiler-helper-dependency.js +2 -2
- package/src/utils/compiler-helper-dependency.js.map +1 -1
- package/src/utils/generate-globs.d.ts +6 -0
- package/src/utils/generate-globs.js +81 -0
- package/src/utils/generate-globs.js.map +1 -0
- package/src/utils/inline.d.ts +19 -0
- package/src/utils/inline.js +210 -0
- package/src/utils/inline.js.map +1 -0
- package/src/utils/package-json/index.d.ts +2 -1
- package/src/utils/package-json/index.js +6 -5
- package/src/utils/package-json/index.js.map +1 -1
- package/src/utils/package-json/update-package-json.d.ts +4 -2
- package/src/utils/package-json/update-package-json.js +96 -16
- package/src/utils/package-json/update-package-json.js.map +1 -1
- package/src/utils/prettier.d.ts +6 -0
- package/src/utils/prettier.js +38 -0
- package/src/utils/prettier.js.map +1 -0
- package/src/utils/schema.d.ts +8 -3
- package/src/utils/swc/add-swc-config.d.ts +1 -1
- package/src/utils/swc/add-swc-config.js +7 -7
- package/src/utils/swc/add-swc-config.js.map +1 -1
- package/src/utils/swc/compile-swc.d.ts +4 -0
- package/src/utils/swc/compile-swc.js +10 -7
- package/src/utils/swc/compile-swc.js.map +1 -1
- package/src/utils/swc/get-swcrc-path.d.ts +1 -1
- package/src/utils/swc/get-swcrc-path.js +7 -4
- package/src/utils/swc/get-swcrc-path.js.map +1 -1
- package/src/utils/swc/inline.d.ts +2 -0
- package/src/utils/swc/inline.js +13 -0
- package/src/utils/swc/inline.js.map +1 -0
- package/src/utils/typescript/ast-utils.d.ts +22 -0
- package/src/utils/typescript/ast-utils.js +199 -0
- package/src/utils/typescript/ast-utils.js.map +1 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +6 -2
- package/src/utils/typescript/compile-typescript-files.js +16 -10
- package/src/utils/typescript/compile-typescript-files.js.map +1 -1
- package/src/utils/typescript/create-ts-config.d.ts +17 -0
- package/src/utils/typescript/create-ts-config.js +48 -0
- package/src/utils/typescript/create-ts-config.js.map +1 -0
- package/src/utils/typescript/ensure-typescript.d.ts +1 -0
- package/src/utils/typescript/ensure-typescript.js +10 -0
- package/src/utils/typescript/ensure-typescript.js.map +1 -0
- package/src/utils/typescript/get-source-nodes.d.ts +2 -0
- package/src/utils/typescript/get-source-nodes.js +19 -0
- package/src/utils/typescript/get-source-nodes.js.map +1 -0
- package/src/utils/typescript/run-type-check.d.ts +2 -2
- package/src/utils/typescript/run-type-check.js +7 -5
- package/src/utils/typescript/run-type-check.js.map +1 -1
- package/src/utils/typescript/ts-config.d.ts +11 -0
- package/src/utils/typescript/ts-config.js +55 -0
- package/src/utils/typescript/ts-config.js.map +1 -0
- package/src/utils/typescript/types.d.ts +2 -2
- package/src/utils/versions.d.ts +4 -2
- package/src/utils/versions.js +5 -3
- package/src/utils/versions.js.map +1 -1
- package/src/utils/watch-for-single-file-changes.d.ts +1 -1
- package/src/utils/watch-for-single-file-changes.js +11 -13
- package/src/utils/watch-for-single-file-changes.js.map +1 -1
- package/src/utils/code-frames/code-frames.d.ts +0 -14
- package/src/utils/code-frames/code-frames.js +0 -125
- package/src/utils/code-frames/code-frames.js.map +0 -1
- package/src/utils/create-async-iterable/create-async-iteratable.d.ts +0 -6
- package/src/utils/create-async-iterable/create-async-iteratable.js +0 -62
- package/src/utils/create-async-iterable/create-async-iteratable.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.excludeJestConfigSwcrc = void 0;
|
|
4
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nrwl/
|
|
5
|
+
const executor_options_utils_1 = require("@nrwl/devkit/src/generators/executor-options-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function excludeJestConfigSwcrc(tree) {
|
|
8
8
|
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (config, projectName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exclude-jest-config-swcrc.js","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-14-0-0/exclude-jest-config-swcrc.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;
|
|
1
|
+
{"version":3,"file":"exclude-jest-config-swcrc.js","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-14-0-0/exclude-jest-config-swcrc.ts"],"names":[],"mappings":";;;AAAA,yCAA0E;AAC1E,+FAA4F;AAE5F,+BAA4B;AAE5B,SAAgB,sBAAsB,CAAC,IAAU;IAC/C,IAAA,+CAAsB,EACpB,IAAI,EACJ,cAAc,EACd,CAAC,MAA0B,EAAE,WAAW,EAAE,EAAE;QAC1C,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAClE,MAAM,UAAU,GAAG,IAAA,WAAI,EAAC,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAE1D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;YAAE,OAAO;QAErC,IAAA,mBAAU,EACR,IAAI,EACJ,UAAU,EACV,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;oBAC9B,gBAAgB;oBAChB,GAAG,IAAI,CAAC,OAAO;iBAChB,CAAC,CAAC;gBACH,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC;aACrC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EACD,EAAE,cAAc,EAAE,IAAI,EAAE,CACzB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AA3BD,wDA2BC;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateSwcrcPath = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
-
const executor_options_utils_1 = require("@nrwl/
|
|
6
|
+
const executor_options_utils_1 = require("@nrwl/devkit/src/generators/executor-options-utils");
|
|
7
7
|
function updateSwcrcPath(tree) {
|
|
8
8
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
9
|
let changesMade = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-swcrc-path.js","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-14-1-5/update-swcrc-path.ts"],"names":[],"mappings":";;;;AAAA,yCAMsB;AACtB
|
|
1
|
+
{"version":3,"file":"update-swcrc-path.js","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-14-1-5/update-swcrc-path.ts"],"names":[],"mappings":";;;;AAAA,yCAMsB;AACtB,+FAA4F;AAK5F,SAAsB,eAAe,CAAC,IAAU;;QAC9C,IAAI,WAAW,GAAG,KAAK,CAAC;QAExB,IAAA,+CAAsB,EACpB,IAAI,EACJ,cAAc,EACd,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE;YAChD,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAClE,MAAM,eAAe,GAA0B,iBAAiB;gBAC9D,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC;gBACrE,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;YAE9C,IAAI,CAAC,eAAe,CAAC,SAAS;gBAAE,OAAO;YAEvC,MAAM,YAAY,GAAG,IAAA,0BAAiB,EACpC,aAAa,CAAC,IAAI,EAClB,eAAe,CAAC,SAAS,CAC1B,CAAC;YAEF,OAAO,eAAe,CAAC,SAAS,CAAC;YACjC,eAAe,CAAC,KAAK,GAAG,YAAY,CAAC;YAErC,IAAA,mCAA0B,EAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;YAE7D,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC,CACF,CAAC;QAEF,IAAI,WAAW,EAAE;YACf,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AA/BD,0CA+BC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
const executor_options_utils_1 = require("@nrwl/devkit/src/generators/executor-options-utils");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
function default_1(tree) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
let changesMade = false;
|
|
10
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
11
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/js:swc', (_, projectName, target, configurationName) => {
|
|
12
|
+
const projectConfiguration = projects.get(projectName);
|
|
13
|
+
const executorOptions = configurationName
|
|
14
|
+
? projectConfiguration.targets[target].configurations[configurationName]
|
|
15
|
+
: projectConfiguration.targets[target].options;
|
|
16
|
+
// if the project uses a custom path to swcrc file
|
|
17
|
+
// and only if it's the default name
|
|
18
|
+
if (executorOptions.swcrc &&
|
|
19
|
+
executorOptions.swcrc.includes('.lib.swcrc')) {
|
|
20
|
+
const newSwcrc = executorOptions.swcrc.replace('.lib.swcrc', '.swcrc');
|
|
21
|
+
// rename the swcrc file first
|
|
22
|
+
tree.rename(executorOptions.swcrc, newSwcrc);
|
|
23
|
+
// then update the executor options
|
|
24
|
+
executorOptions.swcrc = newSwcrc;
|
|
25
|
+
changesMade = true;
|
|
26
|
+
}
|
|
27
|
+
const libSwcrcPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, '.lib.swcrc') ||
|
|
28
|
+
(0, devkit_1.joinPathFragments)(projectConfiguration.sourceRoot, '.lib.swcrc');
|
|
29
|
+
const isLibSwcrcExist = tree.exists(libSwcrcPath);
|
|
30
|
+
if (isLibSwcrcExist) {
|
|
31
|
+
tree.rename(libSwcrcPath, libSwcrcPath.replace('.lib.swcrc', '.swcrc'));
|
|
32
|
+
changesMade = true;
|
|
33
|
+
}
|
|
34
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
|
|
35
|
+
});
|
|
36
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (_, projectName, target, configurationName) => {
|
|
37
|
+
const projectConfiguration = projects.get(projectName);
|
|
38
|
+
const executorOptions = configurationName
|
|
39
|
+
? projectConfiguration.targets[target].configurations[configurationName]
|
|
40
|
+
: projectConfiguration.targets[target].options;
|
|
41
|
+
const isJestConfigExist = executorOptions.jestConfig && tree.exists(executorOptions.jestConfig);
|
|
42
|
+
if (isJestConfigExist) {
|
|
43
|
+
const jestConfig = tree.read(executorOptions.jestConfig, 'utf-8');
|
|
44
|
+
const jsonParseNodes = tsquery_1.tsquery.query(jestConfig, ':matches(CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]))');
|
|
45
|
+
if (jsonParseNodes.length) {
|
|
46
|
+
// if we already assign false to swcrc, skip
|
|
47
|
+
if (jestConfig.includes('.swcrc = false')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
let updatedJestConfig = tsquery_1.tsquery.replace(jestConfig, 'CallExpression:has(Identifier[name="JSON"]):has(Identifier[name="parse"]) TemplateSpan', (templateSpan) => {
|
|
51
|
+
if (templateSpan.literal.text === '/.lib.swcrc') {
|
|
52
|
+
return templateSpan
|
|
53
|
+
.getFullText()
|
|
54
|
+
.replace('.lib.swcrc', '.swcrc');
|
|
55
|
+
}
|
|
56
|
+
return '';
|
|
57
|
+
});
|
|
58
|
+
updatedJestConfig = tsquery_1.tsquery.replace(updatedJestConfig, ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))', (node) => {
|
|
59
|
+
return `
|
|
60
|
+
|
|
61
|
+
// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
|
|
62
|
+
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
|
|
63
|
+
if (swcJestConfig.swcrc === undefined) {
|
|
64
|
+
swcJestConfig.swcrc = false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
${node.getFullText()}
|
|
68
|
+
`;
|
|
69
|
+
});
|
|
70
|
+
tree.write(executorOptions.jestConfig, updatedJestConfig);
|
|
71
|
+
changesMade = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (changesMade) {
|
|
76
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.default = default_1;
|
|
81
|
+
//# sourceMappingURL=rename-swcrc-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-swcrc-config.js","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-15-8-0/rename-swcrc-config.ts"],"names":[],"mappings":";;;AAAA,yCAMsB;AACtB,+FAA4F;AAE5F,uDAAoD;AAGpD,mBAA+B,IAAU;;QACvC,IAAI,WAAW,GAAG,KAAK,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAEnC,IAAA,+CAAsB,EACpB,IAAI,EACJ,cAAc,EACd,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,EAAE,EAAE;YAC5C,MAAM,oBAAoB,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACvD,MAAM,eAAe,GAAuB,iBAAiB;gBAC3D,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC;gBACxE,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACjD,kDAAkD;YAClD,oCAAoC;YACpC,IACE,eAAe,CAAC,KAAK;gBACrB,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAC5C;gBACA,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;gBACvE,8BAA8B;gBAC9B,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC7C,mCAAmC;gBACnC,eAAe,CAAC,KAA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AEF,IAAI,cAAc,CAAC,MAAM,EAAE;oBACzB,4CAA4C;oBAC5C,IAAI,UAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;wBACzC,OAAO;qBACR;oBAED,IAAI,iBAAiB,GAAG,iBAAO,CAAC,OAAO,CACrC,UAAU,EACV,wFAAwF,EACxF,CAAC,YAA0B,EAAE,EAAE;wBAC7B,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE;4BAC/C,OAAO,YAAY;iCAChB,WAAW,EAAE;iCACb,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;yBACpC;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CACF,CAAC;oBAEF,iBAAiB,GAAG,iBAAO,CAAC,OAAO,CACjC,iBAAiB,EACjB,6GAA6G,EAC7G,CAAC,IAAI,EAAE,EAAE;wBACP,OAAO;;;;;;;;EAQnB,IAAI,CAAC,WAAW,EAAE;CACnB,CAAC;oBACU,CAAC,CACF,CAAC;oBAEF,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;oBAC1D,WAAW,GAAG,IAAI,CAAC;iBACpB;aACF;QACH,CAAC,CACF,CAAC;QAEF,IAAI,WAAW,EAAE;YACf,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AA1GD,4BA0GC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addBabelInputs = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
function addBabelInputs(tree) {
|
|
7
|
+
var _a;
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
10
|
+
let globalBabelFile = ['babel.config.js', 'babel.config.json'].find((file) => tree.exists(file));
|
|
11
|
+
if (!globalBabelFile) {
|
|
12
|
+
(0, devkit_1.writeJson)(tree, '/babel.config.json', {
|
|
13
|
+
babelrcRoots: ['*'], // Make sure .babelrc files other than root can be loaded in a monorepo
|
|
14
|
+
});
|
|
15
|
+
globalBabelFile = 'babel.config.json';
|
|
16
|
+
}
|
|
17
|
+
if ((_a = nxJson.namedInputs) === null || _a === void 0 ? void 0 : _a.sharedGlobals) {
|
|
18
|
+
const sharedGlobalFileset = new Set(nxJson.namedInputs.sharedGlobals);
|
|
19
|
+
sharedGlobalFileset.add((0, devkit_1.joinPathFragments)('{workspaceRoot}', globalBabelFile));
|
|
20
|
+
nxJson.namedInputs.sharedGlobals = Array.from(sharedGlobalFileset);
|
|
21
|
+
}
|
|
22
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
23
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.addBabelInputs = addBabelInputs;
|
|
27
|
+
//# sourceMappingURL=add-babel-inputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-babel-inputs.js","sourceRoot":"","sources":["../../../../../packages/js/src/utils/add-babel-inputs.ts"],"names":[],"mappings":";;;;AAAA,yCAOsB;AAEtB,SAAsB,cAAc,CAAC,IAAU;;;QAC7C,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,IAAI,CAAC,CAAC;QAChC,IAAI,eAAe,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC3E,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAClB,CAAC;QAEF,IAAI,CAAC,eAAe,EAAE;YACpB,IAAA,kBAAS,EAAC,IAAI,EAAE,oBAAoB,EAAE;gBACpC,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE,uEAAuE;aAC7F,CAAC,CAAC;YACH,eAAe,GAAG,mBAAmB,CAAC;SACvC;QAED,IAAI,MAAA,MAAM,CAAC,WAAW,0CAAE,aAAa,EAAE;YACrC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;YACtE,mBAAmB,CAAC,GAAG,CACrB,IAAA,0BAAiB,EAAC,iBAAiB,EAAE,eAAe,CAAC,CACtD,CAAC;YACF,MAAM,CAAC,WAAW,CAAC,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;SACpE;QAED,IAAA,qBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;;CACzB;AAxBD,wCAwBC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AssetGlob } from '@nrwl/workspace/src/utilities/assets';
|
|
2
|
-
export
|
|
2
|
+
export type FileEventType = 'create' | 'update' | 'delete';
|
|
3
3
|
export interface FileEvent {
|
|
4
4
|
type: FileEventType;
|
|
5
5
|
src: string;
|
|
@@ -22,7 +22,7 @@ export declare class CopyAssetsHandler {
|
|
|
22
22
|
private readonly callback;
|
|
23
23
|
constructor(opts: CopyAssetHandlerOptions);
|
|
24
24
|
processAllAssetsOnce(): Promise<void>;
|
|
25
|
-
watchAndProcessOnAssetChange(): Promise<() =>
|
|
25
|
+
watchAndProcessOnAssetChange(): Promise<() => void>;
|
|
26
26
|
private processEvents;
|
|
27
27
|
}
|
|
28
28
|
export {};
|
|
@@ -8,6 +8,7 @@ const fse = require("fs-extra");
|
|
|
8
8
|
const ignore_1 = require("ignore");
|
|
9
9
|
const fg = require("fast-glob");
|
|
10
10
|
const devkit_1 = require("@nrwl/devkit");
|
|
11
|
+
const client_1 = require("nx/src/daemon/client/client");
|
|
11
12
|
const defaultFileEventHandler = (events) => {
|
|
12
13
|
const dirs = new Set(events.map((event) => path.dirname(event.dest)));
|
|
13
14
|
dirs.forEach((d) => fse.ensureDirSync(d));
|
|
@@ -104,17 +105,23 @@ class CopyAssetsHandler {
|
|
|
104
105
|
}
|
|
105
106
|
watchAndProcessOnAssetChange() {
|
|
106
107
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
const
|
|
108
|
-
|
|
108
|
+
const unregisterFileWatcher = yield client_1.daemonClient.registerFileWatcher({
|
|
109
|
+
watchProjects: 'all',
|
|
110
|
+
includeGlobalWorkspaceFiles: true,
|
|
111
|
+
}, (err, data) => {
|
|
109
112
|
var _a;
|
|
110
|
-
if (err) {
|
|
113
|
+
if (err === 'closed') {
|
|
114
|
+
devkit_1.logger.error(`Watch error: Daemon closed the connection`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
else if (err) {
|
|
111
118
|
devkit_1.logger.error(`Watch error: ${(_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unknown'}`);
|
|
112
119
|
}
|
|
113
120
|
else {
|
|
114
|
-
this.processEvents(
|
|
121
|
+
this.processEvents(data.changedFiles);
|
|
115
122
|
}
|
|
116
123
|
});
|
|
117
|
-
return () =>
|
|
124
|
+
return () => unregisterFileWatcher();
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
processEvents(events) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-assets-handler.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/copy-assets-handler.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"copy-assets-handler.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/copy-assets-handler.ts"],"names":[],"mappings":";;;;AAAA,uCAAuC;AACvC,6BAA6B;AAC7B,gCAAgC;AAChC,mCAAwC;AACxC,gCAAgC;AAEhC,yCAAsC;AACtC,wDAAwE;AA0BjE,MAAM,uBAAuB,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC7D,MAAM,IAAI,GAAG,IAAI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
7
7
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
8
|
const assetHandler = new copy_assets_handler_1.CopyAssetsHandler({
|
|
9
|
-
projectDir: context.
|
|
9
|
+
projectDir: context.projectsConfigurations.projects[context.projectName].root,
|
|
10
10
|
rootDir: context.root,
|
|
11
11
|
outputDir: options.outputPath,
|
|
12
12
|
assets: options.assets,
|
|
13
13
|
callback: typeof (options === null || options === void 0 ? void 0 : options.watch) === 'object' ? options.watch.onCopy : undefined,
|
|
14
14
|
});
|
|
15
|
+
const result = {
|
|
16
|
+
success: true,
|
|
17
|
+
};
|
|
15
18
|
if (options.watch) {
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
success: true,
|
|
19
|
-
stop: dispose,
|
|
20
|
-
};
|
|
19
|
+
result.stop = yield assetHandler.watchAndProcessOnAssetChange();
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
yield assetHandler.processAllAssetsOnce();
|
|
25
|
-
}
|
|
26
|
-
catch (_a) {
|
|
27
|
-
return { success: false };
|
|
28
|
-
}
|
|
29
|
-
return { success: true };
|
|
21
|
+
try {
|
|
22
|
+
yield assetHandler.processAllAssetsOnce();
|
|
30
23
|
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
result.success = false;
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
31
28
|
});
|
|
32
29
|
}
|
|
33
30
|
exports.copyAssets = copyAssets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/index.ts"],"names":[],"mappings":";;;;AACA,+DAAqE;AAmBrE,SAAsB,UAAU,CAC9B,OAA0B,EAC1B,OAAwB;;QAExB,MAAM,YAAY,GAAG,IAAI,uCAAiB,CAAC;YACzC,UAAU,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/index.ts"],"names":[],"mappings":";;;;AACA,+DAAqE;AAmBrE,SAAsB,UAAU,CAC9B,OAA0B,EAC1B,OAAwB;;QAExB,MAAM,YAAY,GAAG,IAAI,uCAAiB,CAAC;YACzC,UAAU,EACR,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI;YACnE,OAAO,EAAE,OAAO,CAAC,IAAI;YACrB,SAAS,EAAE,OAAO,CAAC,UAAU;YAC7B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EACN,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SACxE,CAAC,CAAC;QACH,MAAM,MAAM,GAAqB;YAC/B,OAAO,EAAE,IAAI;SACd,CAAC;QAEF,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,MAAM,CAAC,IAAI,GAAG,MAAM,YAAY,CAAC,4BAA4B,EAAE,CAAC;SACjE;QAED,IAAI;YACF,MAAM,YAAY,CAAC,oBAAoB,EAAE,CAAC;SAC3C;QAAC,WAAM;YACN,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;SACxB;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CAAA;AA5BD,gCA4BC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProjectGraph, ProjectGraphProjectNode } from '@nrwl/devkit';
|
|
2
|
+
import { ProjectGraphExternalNode } from '@nrwl/devkit';
|
|
3
|
+
import type * as ts from 'typescript';
|
|
4
|
+
export type DependentBuildableProjectNode = {
|
|
5
|
+
name: string;
|
|
6
|
+
outputs: string[];
|
|
7
|
+
node: ProjectGraphProjectNode | ProjectGraphExternalNode;
|
|
8
|
+
};
|
|
9
|
+
export declare function calculateProjectDependencies(projGraph: ProjectGraph, root: string, projectName: string, targetName: string, configurationName: string, shallow?: boolean): {
|
|
10
|
+
target: ProjectGraphProjectNode;
|
|
11
|
+
dependencies: DependentBuildableProjectNode[];
|
|
12
|
+
nonBuildableDependencies: string[];
|
|
13
|
+
topLevelDependencies: DependentBuildableProjectNode[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Util function to create tsconfig compilerOptions object with support for workspace libs paths.
|
|
17
|
+
*
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @param tsConfig String of config path or object parsed via ts.parseJsonConfigFileContent.
|
|
21
|
+
* @param dependencies Dependencies calculated by Nx.
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeCompilerOptionsPaths(tsConfig: string | ts.ParsedCommandLine, dependencies: DependentBuildableProjectNode[]): ts.MapLike<string[]>;
|
|
24
|
+
export declare function createTmpTsConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, dependencies: DependentBuildableProjectNode[]): string;
|
|
25
|
+
export declare function checkDependentProjectsHaveBeenBuilt(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): boolean;
|
|
26
|
+
export declare function findMissingBuildDependencies(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): DependentBuildableProjectNode[];
|
|
27
|
+
export declare function updatePaths(dependencies: DependentBuildableProjectNode[], paths: Record<string, string[]>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
|
|
30
|
+
* the proper dependency and version
|
|
31
|
+
*/
|
|
32
|
+
export declare function updateBuildableProjectPackageJsonDependencies(root: string, projectName: string, targetName: string, configurationName: string, node: ProjectGraphProjectNode, dependencies: DependentBuildableProjectNode[], typeOfDependency?: 'dependencies' | 'peerDependencies'): void;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateBuildableProjectPackageJsonDependencies = exports.updatePaths = exports.findMissingBuildDependencies = exports.checkDependentProjectsHaveBeenBuilt = exports.createTmpTsConfig = exports.computeCompilerOptionsPaths = exports.calculateProjectDependencies = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
6
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const output_1 = require("nx/src/utils/output");
|
|
9
|
+
const operators_1 = require("nx/src/project-graph/operators");
|
|
10
|
+
const ensure_typescript_1 = require("./typescript/ensure-typescript");
|
|
11
|
+
let tsModule;
|
|
12
|
+
function isBuildable(target, node) {
|
|
13
|
+
return (node.data.targets &&
|
|
14
|
+
node.data.targets[target] &&
|
|
15
|
+
node.data.targets[target].executor !== '');
|
|
16
|
+
}
|
|
17
|
+
function calculateProjectDependencies(projGraph, root, projectName, targetName, configurationName, shallow) {
|
|
18
|
+
const target = projGraph.nodes[projectName];
|
|
19
|
+
// gather the library dependencies
|
|
20
|
+
const nonBuildableDependencies = [];
|
|
21
|
+
const topLevelDependencies = [];
|
|
22
|
+
const collectedDeps = collectDependencies(projectName, projGraph, [], shallow);
|
|
23
|
+
const missing = collectedDeps.reduce((missing, { name: dep }) => {
|
|
24
|
+
const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
|
|
25
|
+
if (!depNode) {
|
|
26
|
+
missing = missing || [];
|
|
27
|
+
missing.push(dep);
|
|
28
|
+
}
|
|
29
|
+
return missing;
|
|
30
|
+
}, null);
|
|
31
|
+
if (missing) {
|
|
32
|
+
throw new Error(`Unable to find ${missing.join(', ')} in project graph.`);
|
|
33
|
+
}
|
|
34
|
+
const dependencies = collectedDeps
|
|
35
|
+
.map(({ name: dep, isTopLevel }) => {
|
|
36
|
+
let project = null;
|
|
37
|
+
const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
|
|
38
|
+
if (depNode.type === 'lib') {
|
|
39
|
+
if (isBuildable(targetName, depNode)) {
|
|
40
|
+
const libPackageJsonPath = (0, path_1.join)(root, depNode.data.root, 'package.json');
|
|
41
|
+
project = {
|
|
42
|
+
name: (0, fileutils_1.fileExists)(libPackageJsonPath)
|
|
43
|
+
? (0, devkit_1.readJsonFile)(libPackageJsonPath).name // i.e. @workspace/mylib
|
|
44
|
+
: dep,
|
|
45
|
+
outputs: (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
46
|
+
overrides: {},
|
|
47
|
+
target: {
|
|
48
|
+
project: projectName,
|
|
49
|
+
target: targetName,
|
|
50
|
+
configuration: configurationName,
|
|
51
|
+
},
|
|
52
|
+
}, depNode),
|
|
53
|
+
node: depNode,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
nonBuildableDependencies.push(dep);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (depNode.type === 'npm') {
|
|
61
|
+
project = {
|
|
62
|
+
name: depNode.data.packageName,
|
|
63
|
+
outputs: [],
|
|
64
|
+
node: depNode,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (project && isTopLevel) {
|
|
68
|
+
topLevelDependencies.push(project);
|
|
69
|
+
}
|
|
70
|
+
return project;
|
|
71
|
+
})
|
|
72
|
+
.filter((x) => !!x);
|
|
73
|
+
dependencies.sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0));
|
|
74
|
+
return {
|
|
75
|
+
target,
|
|
76
|
+
dependencies,
|
|
77
|
+
nonBuildableDependencies,
|
|
78
|
+
topLevelDependencies,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.calculateProjectDependencies = calculateProjectDependencies;
|
|
82
|
+
function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps = true) {
|
|
83
|
+
(projGraph.dependencies[project] || []).forEach((dependency) => {
|
|
84
|
+
if (!acc.some((dep) => dep.name === dependency.target)) {
|
|
85
|
+
// Temporary skip this. Currently the set of external nodes is built from package.json, not lock file.
|
|
86
|
+
// As a result, some nodes might be missing. This should not cause any issues, we can just skip them.
|
|
87
|
+
if (dependency.target.startsWith('npm:') &&
|
|
88
|
+
!projGraph.externalNodes[dependency.target])
|
|
89
|
+
return;
|
|
90
|
+
acc.push({ name: dependency.target, isTopLevel: areTopLevelDeps });
|
|
91
|
+
const isInternalTarget = projGraph.nodes[dependency.target];
|
|
92
|
+
if (!shallow && isInternalTarget) {
|
|
93
|
+
collectDependencies(dependency.target, projGraph, acc, shallow, false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return acc;
|
|
98
|
+
}
|
|
99
|
+
function readTsConfigWithRemappedPaths(tsConfig, generatedTsConfigPath, dependencies) {
|
|
100
|
+
const generatedTsConfig = { compilerOptions: {} };
|
|
101
|
+
generatedTsConfig.extends = (0, path_1.relative)((0, path_1.dirname)(generatedTsConfigPath), tsConfig);
|
|
102
|
+
generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(tsConfig, dependencies);
|
|
103
|
+
if (process.env.NX_VERBOSE_LOGGING_PATH_MAPPINGS === 'true') {
|
|
104
|
+
output_1.output.log({
|
|
105
|
+
title: 'TypeScript path mappings have been rewritten.',
|
|
106
|
+
});
|
|
107
|
+
console.log(JSON.stringify(generatedTsConfig.compilerOptions.paths, null, 2));
|
|
108
|
+
}
|
|
109
|
+
return generatedTsConfig;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Util function to create tsconfig compilerOptions object with support for workspace libs paths.
|
|
113
|
+
*
|
|
114
|
+
*
|
|
115
|
+
*
|
|
116
|
+
* @param tsConfig String of config path or object parsed via ts.parseJsonConfigFileContent.
|
|
117
|
+
* @param dependencies Dependencies calculated by Nx.
|
|
118
|
+
*/
|
|
119
|
+
function computeCompilerOptionsPaths(tsConfig, dependencies) {
|
|
120
|
+
const paths = readPaths(tsConfig) || {};
|
|
121
|
+
updatePaths(dependencies, paths);
|
|
122
|
+
return paths;
|
|
123
|
+
}
|
|
124
|
+
exports.computeCompilerOptionsPaths = computeCompilerOptionsPaths;
|
|
125
|
+
function readPaths(tsConfig) {
|
|
126
|
+
var _a;
|
|
127
|
+
if (!tsModule) {
|
|
128
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
let config;
|
|
132
|
+
if (typeof tsConfig === 'string') {
|
|
133
|
+
const configFile = tsModule.readConfigFile(tsConfig, tsModule.sys.readFile);
|
|
134
|
+
config = tsModule.parseJsonConfigFileContent(configFile.config, tsModule.sys, (0, path_1.dirname)(tsConfig));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
config = tsConfig;
|
|
138
|
+
}
|
|
139
|
+
if ((_a = config.options) === null || _a === void 0 ? void 0 : _a.paths) {
|
|
140
|
+
return config.options.paths;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function createTmpTsConfig(tsconfigPath, workspaceRoot, projectRoot, dependencies) {
|
|
151
|
+
const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, 'tsconfig.generated.json');
|
|
152
|
+
const parsedTSConfig = readTsConfigWithRemappedPaths(tsconfigPath, tmpTsConfigPath, dependencies);
|
|
153
|
+
process.on('exit', () => cleanupTmpTsConfigFile(tmpTsConfigPath));
|
|
154
|
+
(0, devkit_1.writeJsonFile)(tmpTsConfigPath, parsedTSConfig);
|
|
155
|
+
return (0, path_1.join)(tmpTsConfigPath);
|
|
156
|
+
}
|
|
157
|
+
exports.createTmpTsConfig = createTmpTsConfig;
|
|
158
|
+
function cleanupTmpTsConfigFile(tmpTsConfigPath) {
|
|
159
|
+
try {
|
|
160
|
+
if (tmpTsConfigPath) {
|
|
161
|
+
(0, fs_1.unlinkSync)(tmpTsConfigPath);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e) { }
|
|
165
|
+
}
|
|
166
|
+
function checkDependentProjectsHaveBeenBuilt(root, projectName, targetName, projectDependencies) {
|
|
167
|
+
const missing = findMissingBuildDependencies(root, projectName, targetName, projectDependencies);
|
|
168
|
+
if (missing.length > 0) {
|
|
169
|
+
console.error((0, devkit_1.stripIndents) `
|
|
170
|
+
It looks like all of ${projectName}'s dependencies have not been built yet:
|
|
171
|
+
${missing.map((x) => ` - ${x.node.name}`).join('\n')}
|
|
172
|
+
|
|
173
|
+
You might be missing a "targetDefaults" configuration in your root nx.json (https://nx.dev/reference/project-configuration#target-defaults),
|
|
174
|
+
or "dependsOn" configured in ${projectName}'s project.json (https://nx.dev/reference/project-configuration#dependson)
|
|
175
|
+
`);
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
exports.checkDependentProjectsHaveBeenBuilt = checkDependentProjectsHaveBeenBuilt;
|
|
183
|
+
function findMissingBuildDependencies(root, projectName, targetName, projectDependencies) {
|
|
184
|
+
const depLibsToBuildFirst = [];
|
|
185
|
+
// verify whether all dependent libraries have been built
|
|
186
|
+
projectDependencies.forEach((dep) => {
|
|
187
|
+
if (dep.node.type !== 'lib') {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const paths = dep.outputs.map((p) => (0, path_1.join)(root, p));
|
|
191
|
+
if (!paths.some(fileutils_1.directoryExists)) {
|
|
192
|
+
depLibsToBuildFirst.push(dep);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return depLibsToBuildFirst;
|
|
196
|
+
}
|
|
197
|
+
exports.findMissingBuildDependencies = findMissingBuildDependencies;
|
|
198
|
+
function updatePaths(dependencies, paths) {
|
|
199
|
+
const pathsKeys = Object.keys(paths);
|
|
200
|
+
// For each registered dependency
|
|
201
|
+
dependencies.forEach((dep) => {
|
|
202
|
+
var _a;
|
|
203
|
+
// If there are outputs
|
|
204
|
+
if (dep.outputs && dep.outputs.length > 0) {
|
|
205
|
+
// Directly map the dependency name to the output paths (dist/packages/..., etc.)
|
|
206
|
+
paths[dep.name] = dep.outputs;
|
|
207
|
+
// check for secondary entrypoints
|
|
208
|
+
// For each registered path
|
|
209
|
+
for (const path of pathsKeys) {
|
|
210
|
+
const nestedName = `${dep.name}/`;
|
|
211
|
+
// If the path points to the current dependency and is nested (/)
|
|
212
|
+
if (path.startsWith(nestedName)) {
|
|
213
|
+
const nestedPart = path.slice(nestedName.length);
|
|
214
|
+
// Bind secondary endpoints for ng-packagr projects
|
|
215
|
+
let mappedPaths = dep.outputs.map((output) => `${output}/${nestedPart}`);
|
|
216
|
+
// Get the dependency's package name
|
|
217
|
+
const { root } = (((_a = dep.node) === null || _a === void 0 ? void 0 : _a.data) || {});
|
|
218
|
+
if (root) {
|
|
219
|
+
// Update nested mappings to point to the dependency's output paths
|
|
220
|
+
mappedPaths = mappedPaths.concat(paths[path].flatMap((path) => dep.outputs.map((output) => path.replace(root, output))));
|
|
221
|
+
}
|
|
222
|
+
paths[path] = mappedPaths;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
exports.updatePaths = updatePaths;
|
|
229
|
+
/**
|
|
230
|
+
* Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
|
|
231
|
+
* the proper dependency and version
|
|
232
|
+
*/
|
|
233
|
+
function updateBuildableProjectPackageJsonDependencies(root, projectName, targetName, configurationName, node, dependencies, typeOfDependency = 'dependencies') {
|
|
234
|
+
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
235
|
+
overrides: {},
|
|
236
|
+
target: {
|
|
237
|
+
project: projectName,
|
|
238
|
+
target: targetName,
|
|
239
|
+
configuration: configurationName,
|
|
240
|
+
},
|
|
241
|
+
}, node);
|
|
242
|
+
const packageJsonPath = `${outputs[0]}/package.json`;
|
|
243
|
+
let packageJson;
|
|
244
|
+
let workspacePackageJson;
|
|
245
|
+
try {
|
|
246
|
+
packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
247
|
+
workspacePackageJson = (0, devkit_1.readJsonFile)(`${root}/package.json`);
|
|
248
|
+
}
|
|
249
|
+
catch (e) {
|
|
250
|
+
// cannot find or invalid package.json
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
packageJson.dependencies = packageJson.dependencies || {};
|
|
254
|
+
packageJson.peerDependencies = packageJson.peerDependencies || {};
|
|
255
|
+
let updatePackageJson = false;
|
|
256
|
+
dependencies.forEach((entry) => {
|
|
257
|
+
var _a;
|
|
258
|
+
const packageName = (0, operators_1.isNpmProject)(entry.node)
|
|
259
|
+
? entry.node.data.packageName
|
|
260
|
+
: entry.name;
|
|
261
|
+
if (!hasDependency(packageJson, 'dependencies', packageName) &&
|
|
262
|
+
!hasDependency(packageJson, 'devDependencies', packageName) &&
|
|
263
|
+
!hasDependency(packageJson, 'peerDependencies', packageName)) {
|
|
264
|
+
try {
|
|
265
|
+
let depVersion;
|
|
266
|
+
if (entry.node.type === 'lib') {
|
|
267
|
+
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
268
|
+
overrides: {},
|
|
269
|
+
target: {
|
|
270
|
+
project: projectName,
|
|
271
|
+
target: targetName,
|
|
272
|
+
configuration: configurationName,
|
|
273
|
+
},
|
|
274
|
+
}, entry.node);
|
|
275
|
+
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
276
|
+
depVersion = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
277
|
+
packageJson[typeOfDependency][packageName] = depVersion;
|
|
278
|
+
}
|
|
279
|
+
else if ((0, operators_1.isNpmProject)(entry.node)) {
|
|
280
|
+
// If an npm dep is part of the workspace devDependencies, do not include it the library
|
|
281
|
+
if (!!((_a = workspacePackageJson.devDependencies) === null || _a === void 0 ? void 0 : _a[entry.node.data.packageName])) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
depVersion = entry.node.data.version;
|
|
285
|
+
packageJson[typeOfDependency][entry.node.data.packageName] =
|
|
286
|
+
depVersion;
|
|
287
|
+
}
|
|
288
|
+
updatePackageJson = true;
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
// skip if cannot find package.json
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
if (updatePackageJson) {
|
|
296
|
+
(0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
exports.updateBuildableProjectPackageJsonDependencies = updateBuildableProjectPackageJsonDependencies;
|
|
300
|
+
// verify whether the package.json already specifies the dep
|
|
301
|
+
function hasDependency(outputJson, depConfigName, packageName) {
|
|
302
|
+
if (outputJson[depConfigName]) {
|
|
303
|
+
return outputJson[depConfigName][packageName];
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=buildable-libs-utils.js.map
|