@nx/js 16.0.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 +8 -0
- package/LICENSE +22 -0
- package/README.md +63 -0
- package/babel.d.ts +10 -0
- package/babel.js +89 -0
- package/babel.js.map +1 -0
- package/executors.json +37 -0
- package/generators.json +52 -0
- package/migrations.json +60 -0
- package/package.json +64 -0
- package/src/executors/node/compat.d.ts +2 -0
- package/src/executors/node/compat.js +6 -0
- package/src/executors/node/compat.js.map +1 -0
- package/src/executors/node/node-with-require-overrides.d.ts +5 -0
- package/src/executors/node/node-with-require-overrides.js +20 -0
- package/src/executors/node/node-with-require-overrides.js.map +1 -0
- package/src/executors/node/node.impl.d.ts +8 -0
- package/src/executors/node/node.impl.js +184 -0
- package/src/executors/node/node.impl.js.map +1 -0
- package/src/executors/node/schema.d.ts +16 -0
- package/src/executors/node/schema.json +74 -0
- package/src/executors/swc/compat.d.ts +2 -0
- package/src/executors/swc/compat.js +6 -0
- package/src/executors/swc/compat.js.map +1 -0
- package/src/executors/swc/schema.json +147 -0
- package/src/executors/swc/swc.impl.d.ts +11 -0
- package/src/executors/swc/swc.impl.js +126 -0
- package/src/executors/swc/swc.impl.js.map +1 -0
- package/src/executors/tsc/compat.d.ts +2 -0
- package/src/executors/tsc/compat.js +6 -0
- package/src/executors/tsc/compat.js.map +1 -0
- package/src/executors/tsc/schema.json +156 -0
- package/src/executors/tsc/tsc.impl.d.ts +7 -0
- package/src/executors/tsc/tsc.impl.js +106 -0
- package/src/executors/tsc/tsc.impl.js.map +1 -0
- package/src/generators/convert-to-swc/convert-to-swc.d.ts +5 -0
- package/src/generators/convert-to-swc/convert-to-swc.js +62 -0
- package/src/generators/convert-to-swc/convert-to-swc.js.map +1 -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 +5 -0
- package/src/generators/init/init.js +67 -0
- package/src/generators/init/init.js.map +1 -0
- package/src/generators/init/schema.d.ts +6 -0
- package/src/generators/init/schema.json +30 -0
- package/src/generators/library/files/jest-config/jest.config.__ext__ +24 -0
- package/src/generators/library/files/lib/README.md +19 -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.json__tmpl__ +14 -0
- package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +10 -0
- package/src/generators/library/library.d.ts +15 -0
- package/src/generators/library/library.js +388 -0
- package/src/generators/library/library.js.map +1 -0
- package/src/generators/library/schema.json +134 -0
- package/src/index.d.ts +15 -0
- package/src/index.js +24 -0
- package/src/index.js.map +1 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.d.ts +2 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js +32 -0
- package/src/migrations/update-13-10-1/update-lib-swcrc-exclude.js.map +1 -0
- package/src/migrations/update-13-8-5/update-node-executor.d.ts +2 -0
- package/src/migrations/update-13-8-5/update-node-executor.js +28 -0
- package/src/migrations/update-13-8-5/update-node-executor.js.map +1 -0
- package/src/migrations/update-13-8-5/update-swcrc.d.ts +2 -0
- package/src/migrations/update-13-8-5/update-swcrc.js +35 -0
- package/src/migrations/update-13-8-5/update-swcrc.js.map +1 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.d.ts +3 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js +27 -0
- package/src/migrations/update-14-0-0/exclude-jest-config-swcrc.js.map +1 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.d.ts +3 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.js +30 -0
- package/src/migrations/update-14-1-5/update-swcrc-path.js.map +1 -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 +81 -0
- package/src/migrations/update-15-8-0/rename-swcrc-config.js.map +1 -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 +13 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
- package/src/utils/add-babel-inputs.d.ts +2 -0
- package/src/utils/add-babel-inputs.js +23 -0
- package/src/utils/add-babel-inputs.js.map +1 -0
- package/src/utils/assets/assets.d.ts +10 -0
- package/src/utils/assets/assets.js +38 -0
- package/src/utils/assets/assets.js.map +1 -0
- package/src/utils/assets/copy-assets-handler.d.ts +28 -0
- package/src/utils/assets/copy-assets-handler.js +155 -0
- package/src/utils/assets/copy-assets-handler.js.map +1 -0
- package/src/utils/assets/index.d.ts +16 -0
- package/src/utils/assets/index.js +31 -0
- package/src/utils/assets/index.js.map +1 -0
- 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 +8 -0
- package/src/utils/check-dependencies.js +24 -0
- package/src/utils/check-dependencies.js.map +1 -0
- package/src/utils/code-frames/highlight.d.ts +1 -0
- package/src/utils/code-frames/highlight.js +87 -0
- package/src/utils/code-frames/highlight.js.map +1 -0
- package/src/utils/code-frames/identifiers.d.ts +5 -0
- package/src/utils/code-frames/identifiers.js +53 -0
- package/src/utils/code-frames/identifiers.js.map +1 -0
- package/src/utils/compiler-helper-dependency.d.ts +17 -0
- package/src/utils/compiler-helper-dependency.js +111 -0
- package/src/utils/compiler-helper-dependency.js.map +1 -0
- 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 +211 -0
- package/src/utils/inline.js.map +1 -0
- package/src/utils/minimal-publish-script.d.ts +2 -0
- package/src/utils/minimal-publish-script.js +76 -0
- package/src/utils/minimal-publish-script.js.map +1 -0
- package/src/utils/package-json/index.d.ts +13 -0
- package/src/utils/package-json/index.js +34 -0
- package/src/utils/package-json/index.js.map +1 -0
- package/src/utils/package-json/update-package-json.d.ts +20 -0
- package/src/utils/package-json/update-package-json.js +142 -0
- package/src/utils/package-json/update-package-json.js.map +1 -0
- 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 +81 -0
- package/src/utils/swc/add-swc-config.d.ts +3 -0
- package/src/utils/swc/add-swc-config.js +44 -0
- package/src/utils/swc/add-swc-config.js.map +1 -0
- package/src/utils/swc/add-swc-dependencies.d.ts +2 -0
- package/src/utils/swc/add-swc-dependencies.js +15 -0
- package/src/utils/swc/add-swc-dependencies.js.map +1 -0
- package/src/utils/swc/compile-swc.d.ts +13 -0
- package/src/utils/swc/compile-swc.js +161 -0
- package/src/utils/swc/compile-swc.js.map +1 -0
- package/src/utils/swc/get-swcrc-path.d.ts +2 -0
- package/src/utils/swc/get-swcrc-path.js +14 -0
- package/src/utils/swc/get-swcrc-path.js.map +1 -0
- 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/__mocks__/plugin-a.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-a.js +6 -0
- package/src/utils/typescript/__mocks__/plugin-a.js.map +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.d.ts +1 -0
- package/src/utils/typescript/__mocks__/plugin-b.js +6 -0
- package/src/utils/typescript/__mocks__/plugin-b.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 +10 -0
- package/src/utils/typescript/compile-typescript-files.js +45 -0
- package/src/utils/typescript/compile-typescript-files.js.map +1 -0
- 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/load-ts-transformers.d.ts +5 -0
- package/src/utils/typescript/load-ts-transformers.js +63 -0
- package/src/utils/typescript/load-ts-transformers.js.map +1 -0
- package/src/utils/typescript/print-diagnostics.d.ts +1 -0
- package/src/utils/typescript/print-diagnostics.js +22 -0
- package/src/utils/typescript/print-diagnostics.js.map +1 -0
- package/src/utils/typescript/run-type-check.d.ts +32 -0
- package/src/utils/typescript/run-type-check.js +125 -0
- package/src/utils/typescript/run-type-check.js.map +1 -0
- package/src/utils/typescript/ts-config.d.ts +6 -0
- package/src/utils/typescript/ts-config.js +50 -0
- package/src/utils/typescript/ts-config.js.map +1 -0
- package/src/utils/typescript/types.d.ts +18 -0
- package/src/utils/typescript/types.js +3 -0
- package/src/utils/typescript/types.js.map +1 -0
- package/src/utils/versions.d.ts +8 -0
- package/src/utils/versions.js +13 -0
- package/src/utils/versions.js.map +1 -0
- package/src/utils/watch-for-single-file-changes.d.ts +1 -0
- package/src/utils/watch-for-single-file-changes.js +27 -0
- package/src/utils/watch-for-single-file-changes.js.map +1 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2023 Narwhal Technologies Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
2
|
+
|
|
3
|
+
<div style="text-align: center;">
|
|
4
|
+
|
|
5
|
+
[](https://circleci.com/gh/nrwl/nx)
|
|
6
|
+
[]()
|
|
7
|
+
[](https://www.npmjs.com/@nrwl/workspace)
|
|
8
|
+
[]()
|
|
9
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
10
|
+
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
11
|
+
[](https://join.slack.com/t/nrwlcommunity/shared_invite/enQtNzU5MTE4OTQwOTk0LTgxY2E0ZWYzMWE0YzA5ZDA2MWM1NDVhNmI2ZWMyYmZhNWJiODk3MjkxZjY3MzU5ZjRmM2NmNWU1OTgyZmE4Mzc)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<hr>
|
|
17
|
+
|
|
18
|
+
# Nx: Smart, Fast and Extensible Build System
|
|
19
|
+
|
|
20
|
+
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
21
|
+
|
|
22
|
+
This package is a [JavaScript/TypeScript plugin for Nx](https://nx.dev/js/overview).
|
|
23
|
+
|
|
24
|
+
## Getting Started
|
|
25
|
+
|
|
26
|
+
### Creating an Nx Workspace
|
|
27
|
+
|
|
28
|
+
**Using `npx`**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx create-nx-workspace
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Using `npm init`**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm init nx-workspace
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Using `yarn create`**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
yarn create nx-workspace
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Adding Nx to an Existing Repository
|
|
47
|
+
|
|
48
|
+
Run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx nx@latest init
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Documentation & Resources
|
|
55
|
+
|
|
56
|
+
- [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
|
|
57
|
+
- [Intro to Nx](https://nx.dev/getting-started/intro)
|
|
58
|
+
- [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
|
|
59
|
+
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
60
|
+
|
|
61
|
+
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
62
|
+
width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
|
|
63
|
+
|
package/babel.d.ts
ADDED
package/babel.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
module.exports = function (api, options = {}) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
api.assertVersion(7);
|
|
7
|
+
const isModern = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.isModern);
|
|
8
|
+
// This is set by `@nrwl/web:rollup` executor
|
|
9
|
+
const isNxPackage = api.caller((caller) => caller === null || caller === void 0 ? void 0 : caller.isNxPackage);
|
|
10
|
+
const emitDecoratorMetadata = api.caller((caller) => { var _a; return (_a = caller === null || caller === void 0 ? void 0 : caller.emitDecoratorMetadata) !== null && _a !== void 0 ? _a : true; });
|
|
11
|
+
// Determine settings for `@babel/plugin-proposal-class-properties`,
|
|
12
|
+
// so that we can sync the `loose` option with `@babel/preset-env`.
|
|
13
|
+
const classProperties = (_a = options.classProperties) !== null && _a !== void 0 ? _a : { loose: true };
|
|
14
|
+
return {
|
|
15
|
+
presets: [
|
|
16
|
+
// Support module/nomodule pattern.
|
|
17
|
+
[
|
|
18
|
+
require.resolve('@babel/preset-env'),
|
|
19
|
+
// For Jest tests, NODE_ENV is set as 'test' and we only want to set target as Node.
|
|
20
|
+
// All other options will fail in Jest since Node does not support some ES features
|
|
21
|
+
// such as import syntax.
|
|
22
|
+
process.env.NODE_ENV === 'test'
|
|
23
|
+
? { targets: { node: 'current' }, loose: true }
|
|
24
|
+
: {
|
|
25
|
+
// Allow importing core-js in entrypoint and use browserslist to select polyfills.
|
|
26
|
+
useBuiltIns: (_b = options.useBuiltIns) !== null && _b !== void 0 ? _b : 'entry',
|
|
27
|
+
corejs: 3,
|
|
28
|
+
// Do not transform modules to CJS
|
|
29
|
+
modules: false,
|
|
30
|
+
targets: isModern ? { esmodules: 'intersect' } : undefined,
|
|
31
|
+
bugfixes: true,
|
|
32
|
+
// Exclude transforms that make all code slower
|
|
33
|
+
exclude: ['transform-typeof-symbol'],
|
|
34
|
+
// This must match the setting for `@babel/plugin-proposal-class-properties`
|
|
35
|
+
loose: classProperties.loose,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
require.resolve('@babel/preset-typescript'),
|
|
40
|
+
{
|
|
41
|
+
allowDeclareFields: true,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
],
|
|
45
|
+
plugins: [
|
|
46
|
+
!isNxPackage
|
|
47
|
+
? [
|
|
48
|
+
require.resolve('@babel/plugin-transform-runtime'),
|
|
49
|
+
{
|
|
50
|
+
corejs: false,
|
|
51
|
+
helpers: true,
|
|
52
|
+
regenerator: true,
|
|
53
|
+
useESModules: isModern,
|
|
54
|
+
absoluteRuntime: (0, path_1.dirname)(require.resolve('@babel/runtime/package.json')),
|
|
55
|
+
},
|
|
56
|
+
]
|
|
57
|
+
: null,
|
|
58
|
+
require.resolve('babel-plugin-macros'),
|
|
59
|
+
emitDecoratorMetadata
|
|
60
|
+
? require.resolve('babel-plugin-transform-typescript-metadata')
|
|
61
|
+
: undefined,
|
|
62
|
+
// Must use legacy decorators to remain compatible with TypeScript.
|
|
63
|
+
[
|
|
64
|
+
require.resolve('@babel/plugin-proposal-decorators'),
|
|
65
|
+
(_c = options.decorators) !== null && _c !== void 0 ? _c : { legacy: true },
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
require.resolve('@babel/plugin-proposal-class-properties'),
|
|
69
|
+
classProperties,
|
|
70
|
+
],
|
|
71
|
+
].filter(Boolean),
|
|
72
|
+
overrides: [
|
|
73
|
+
// Convert `const enum` to `enum`. The former cannot be supported by babel
|
|
74
|
+
// but at least we can get it to not error out.
|
|
75
|
+
{
|
|
76
|
+
test: /\.tsx?$/,
|
|
77
|
+
plugins: [
|
|
78
|
+
[
|
|
79
|
+
require.resolve('babel-plugin-const-enum'),
|
|
80
|
+
{
|
|
81
|
+
transform: 'removeConst',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=babel.js.map
|
package/babel.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel.js","sourceRoot":"","sources":["../../../packages/js/babel.ts"],"names":[],"mappings":"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"}
|
package/executors.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"executors": {
|
|
4
|
+
"tsc": {
|
|
5
|
+
"implementation": "./src/executors/tsc/tsc.impl",
|
|
6
|
+
"schema": "./src/executors/tsc/schema.json",
|
|
7
|
+
"description": "Build a project using TypeScript."
|
|
8
|
+
},
|
|
9
|
+
"swc": {
|
|
10
|
+
"implementation": "./src/executors/swc/swc.impl",
|
|
11
|
+
"schema": "./src/executors/swc/schema.json",
|
|
12
|
+
"description": "Build a project using SWC."
|
|
13
|
+
},
|
|
14
|
+
"node": {
|
|
15
|
+
"implementation": "./src/executors/node/node.impl",
|
|
16
|
+
"schema": "./src/executors/node/schema.json",
|
|
17
|
+
"description": "Execute a Node application."
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"builders": {
|
|
21
|
+
"tsc": {
|
|
22
|
+
"implementation": "./src/executors/tsc/compat",
|
|
23
|
+
"schema": "./src/executors/tsc/schema.json",
|
|
24
|
+
"description": "Build a project using TypeScript."
|
|
25
|
+
},
|
|
26
|
+
"swc": {
|
|
27
|
+
"implementation": "./src/executors/swc/compat",
|
|
28
|
+
"schema": "./src/executors/swc/schema.json",
|
|
29
|
+
"description": "Build a project using SWC."
|
|
30
|
+
},
|
|
31
|
+
"node": {
|
|
32
|
+
"implementation": "./src/executors/node/compat",
|
|
33
|
+
"schema": "./src/executors/node/schema.json",
|
|
34
|
+
"description": "Execute a Node application."
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/generators.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nx/js",
|
|
3
|
+
"version": "0.1",
|
|
4
|
+
"schematics": {
|
|
5
|
+
"library": {
|
|
6
|
+
"factory": "./src/generators/library/library#librarySchematic",
|
|
7
|
+
"schema": "./src/generators/library/schema.json",
|
|
8
|
+
"aliases": ["lib"],
|
|
9
|
+
"x-type": "library",
|
|
10
|
+
"description": "Create a library."
|
|
11
|
+
},
|
|
12
|
+
"init": {
|
|
13
|
+
"factory": "./src/generators/init/init#initSchematic",
|
|
14
|
+
"schema": "./src/generators/init/schema.json",
|
|
15
|
+
"aliases": ["lib"],
|
|
16
|
+
"x-type": "init",
|
|
17
|
+
"description": "Initialize a TS/JS workspace.",
|
|
18
|
+
"hidden": true
|
|
19
|
+
},
|
|
20
|
+
"convert-to-swc": {
|
|
21
|
+
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcSchematic",
|
|
22
|
+
"schema": "./src/generators/convert-to-swc/schema.json",
|
|
23
|
+
"aliases": ["swc"],
|
|
24
|
+
"x-type": "library",
|
|
25
|
+
"description": "Convert a TypeScript library to compile with SWC."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"generators": {
|
|
29
|
+
"library": {
|
|
30
|
+
"factory": "./src/generators/library/library#libraryGenerator",
|
|
31
|
+
"schema": "./src/generators/library/schema.json",
|
|
32
|
+
"aliases": ["lib"],
|
|
33
|
+
"x-type": "library",
|
|
34
|
+
"description": "Create a library"
|
|
35
|
+
},
|
|
36
|
+
"init": {
|
|
37
|
+
"factory": "./src/generators/init/init#initGenerator",
|
|
38
|
+
"schema": "./src/generators/init/schema.json",
|
|
39
|
+
"aliases": ["lib"],
|
|
40
|
+
"x-type": "init",
|
|
41
|
+
"description": "Initialize a TS/JS workspace.",
|
|
42
|
+
"hidden": true
|
|
43
|
+
},
|
|
44
|
+
"convert-to-swc": {
|
|
45
|
+
"factory": "./src/generators/convert-to-swc/convert-to-swc#convertToSwcGenerator",
|
|
46
|
+
"schema": "./src/generators/convert-to-swc/schema.json",
|
|
47
|
+
"aliases": ["swc"],
|
|
48
|
+
"x-type": "library",
|
|
49
|
+
"description": "Convert a TypeScript library to compile with SWC."
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
package/migrations.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generators": {
|
|
3
|
+
"update-node-executor": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "13.8.5-beta.1",
|
|
6
|
+
"description": "Renames @nrwl/js:node to @nrwl/node:node",
|
|
7
|
+
"factory": "./src/migrations/update-13-8-5/update-node-executor"
|
|
8
|
+
},
|
|
9
|
+
"update-swcrc": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "13.8.5-beta.1",
|
|
12
|
+
"description": "Adjust .swcrc to .lib.swcrc",
|
|
13
|
+
"factory": "./src/migrations/update-13-8-5/update-swcrc"
|
|
14
|
+
},
|
|
15
|
+
"update-swcrc-exclude": {
|
|
16
|
+
"cli": "nx",
|
|
17
|
+
"version": "13.10.1-beta.1",
|
|
18
|
+
"description": "Update .lib.swcrc to exclude missing test files",
|
|
19
|
+
"factory": "./src/migrations/update-13-10-1/update-lib-swcrc-exclude"
|
|
20
|
+
},
|
|
21
|
+
"exclude-jest-config-swcrc": {
|
|
22
|
+
"cli": "nx",
|
|
23
|
+
"version": "14.0.0-beta.2",
|
|
24
|
+
"description": "Exclude jest config from .lib.swcrc",
|
|
25
|
+
"factory": "./src/migrations/update-14-0-0/exclude-jest-config-swcrc"
|
|
26
|
+
},
|
|
27
|
+
"update-swcrc-path": {
|
|
28
|
+
"cli": "nx",
|
|
29
|
+
"version": "14.1.5-beta.0",
|
|
30
|
+
"description": "Rename option swcrcPath to swcrc, and resolve relative to workspace root",
|
|
31
|
+
"factory": "./src/migrations/update-14-1-5/update-swcrc-path"
|
|
32
|
+
},
|
|
33
|
+
"rename-swcrc-config": {
|
|
34
|
+
"cli": "nx",
|
|
35
|
+
"version": "15.8.0-beta.0",
|
|
36
|
+
"description": "Rename .lib.swcrc to .swcrc for better SWC support throughout the workspace",
|
|
37
|
+
"factory": "./src/migrations/update-15-8-0/rename-swcrc-config"
|
|
38
|
+
},
|
|
39
|
+
"update-16-0-0-add-nx-packages": {
|
|
40
|
+
"cli": "nx",
|
|
41
|
+
"version": "16.0.0-beta.1",
|
|
42
|
+
"description": "Replace @nrwl/js with @nx/js",
|
|
43
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"packageJsonUpdates": {
|
|
47
|
+
"15.8.0": {
|
|
48
|
+
"version": "15.8.0-beta.2",
|
|
49
|
+
"x-prompt": "Do you want to update to TypeScript v4.9?",
|
|
50
|
+
"requires": {
|
|
51
|
+
"typescript": ">=4.8.2 <4.9.0"
|
|
52
|
+
},
|
|
53
|
+
"packages": {
|
|
54
|
+
"typescript": {
|
|
55
|
+
"version": "~4.9.5"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nx/js",
|
|
3
|
+
"version": "16.0.0-beta.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/nrwl/nx.git",
|
|
9
|
+
"directory": "packages/js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"Monorepo",
|
|
13
|
+
"Web",
|
|
14
|
+
"Node",
|
|
15
|
+
"Swc",
|
|
16
|
+
"Tsc",
|
|
17
|
+
"CLI"
|
|
18
|
+
],
|
|
19
|
+
"main": "src/index.js",
|
|
20
|
+
"typings": "src/index.d.ts",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/nrwl/nx/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://nx.dev",
|
|
26
|
+
"ng-update": {
|
|
27
|
+
"requirements": {},
|
|
28
|
+
"migrations": "./migrations.json"
|
|
29
|
+
},
|
|
30
|
+
"generators": "./generators.json",
|
|
31
|
+
"schematics": "./generators.json",
|
|
32
|
+
"executors": "./executors.json",
|
|
33
|
+
"builders": "./executors.json",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@babel/core": "^7.15.0",
|
|
36
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
37
|
+
"@babel/plugin-proposal-decorators": "^7.14.5",
|
|
38
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
39
|
+
"@babel/preset-env": "^7.15.0",
|
|
40
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
41
|
+
"@babel/runtime": "^7.14.8",
|
|
42
|
+
"@nrwl/js": "16.0.0-beta.1",
|
|
43
|
+
"@nx/devkit": "16.0.0-beta.1",
|
|
44
|
+
"@nx/workspace": "16.0.0-beta.1",
|
|
45
|
+
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
46
|
+
"babel-plugin-const-enum": "^1.0.1",
|
|
47
|
+
"babel-plugin-macros": "^2.8.0",
|
|
48
|
+
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
|
49
|
+
"chalk": "^4.1.0",
|
|
50
|
+
"fast-glob": "3.2.7",
|
|
51
|
+
"fs-extra": "^11.1.0",
|
|
52
|
+
"ignore": "^5.0.4",
|
|
53
|
+
"js-tokens": "^4.0.0",
|
|
54
|
+
"minimatch": "3.0.5",
|
|
55
|
+
"source-map-support": "0.5.19",
|
|
56
|
+
"tree-kill": "1.2.2",
|
|
57
|
+
"tslib": "^2.3.0"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"types": "./src/index.d.ts",
|
|
63
|
+
"gitHead": "abf534c265f5aa3aac146e55bb31de598ea281d7"
|
|
64
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const node_impl_1 = require("./node.impl");
|
|
5
|
+
exports.default = (0, devkit_1.convertNxExecutor)(node_impl_1.default);
|
|
6
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/compat.ts"],"names":[],"mappings":";;AAAA,uCAA+C;AAC/C,2CAAuC;AAEvC,kBAAe,IAAA,0BAAiB,EAAC,mBAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const Module = require('module');
|
|
2
|
+
const originalLoader = Module._load;
|
|
3
|
+
const mappings = JSON.parse(process.env.NX_MAPPINGS);
|
|
4
|
+
const keys = Object.keys(mappings);
|
|
5
|
+
const fileToRun = process.env.NX_FILE_TO_RUN;
|
|
6
|
+
Module._load = function (request, parent) {
|
|
7
|
+
if (!parent)
|
|
8
|
+
return originalLoader.apply(this, arguments);
|
|
9
|
+
const match = keys.find((k) => request === k);
|
|
10
|
+
if (match) {
|
|
11
|
+
const newArguments = [...arguments];
|
|
12
|
+
newArguments[0] = mappings[match];
|
|
13
|
+
return originalLoader.apply(this, newArguments);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return originalLoader.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
require(fileToRun);
|
|
20
|
+
//# sourceMappingURL=node-with-require-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-with-require-overrides.js","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node-with-require-overrides.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;AAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AACrD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAE7C,MAAM,CAAC,KAAK,GAAG,UAAU,OAAO,EAAE,MAAM;IACtC,IAAI,CAAC,MAAM;QAAE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC;IAC9C,IAAI,KAAK,EAAE;QACT,MAAM,YAAY,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;QACpC,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;KACjD;SAAM;QACL,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;KAC9C;AACH,CAAC,CAAC;AAEF,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { NodeExecutorOptions } from './schema';
|
|
3
|
+
export interface ExecutorEvent {
|
|
4
|
+
outfile: string;
|
|
5
|
+
success: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function nodeExecutor(options: NodeExecutorOptions, context: ExecutorContext): AsyncGenerator<ExecutorEvent, void, unknown>;
|
|
8
|
+
export default nodeExecutor;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeExecutor = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const buildable_libs_utils_1 = require("../../utils/buildable-libs-utils");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
const hashing_impl_1 = require("nx/src/hasher/hashing-impl");
|
|
10
|
+
const treeKill = require("tree-kill");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const hasher = new hashing_impl_1.HashingImpl();
|
|
13
|
+
const processMap = new Map();
|
|
14
|
+
const hashedMap = new Map();
|
|
15
|
+
function nodeExecutor(options, context) {
|
|
16
|
+
return tslib_1.__asyncGenerator(this, arguments, function* nodeExecutor_1() {
|
|
17
|
+
var _a, e_1, _b, _c;
|
|
18
|
+
const uniqueKey = (0, crypto_1.randomUUID)();
|
|
19
|
+
process.on('SIGTERM', () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
yield killCurrentProcess(uniqueKey, options, 'SIGTERM');
|
|
21
|
+
process.exit(128 + 15);
|
|
22
|
+
}));
|
|
23
|
+
process.on('SIGINT', () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
yield killCurrentProcess(uniqueKey, options, 'SIGINT');
|
|
25
|
+
process.exit(128 + 2);
|
|
26
|
+
}));
|
|
27
|
+
process.on('SIGHUP', () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
yield killCurrentProcess(uniqueKey, options, 'SIGHUP');
|
|
29
|
+
process.exit(128 + 1);
|
|
30
|
+
}));
|
|
31
|
+
if (options.waitUntilTargets && options.waitUntilTargets.length > 0) {
|
|
32
|
+
const results = yield tslib_1.__await(runWaitUntilTargets(options, context));
|
|
33
|
+
for (const [i, result] of results.entries()) {
|
|
34
|
+
if (!result.success) {
|
|
35
|
+
throw new Error(`Wait until target failed: ${options.waitUntilTargets[i]}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const mappings = calculateResolveMappings(context, options);
|
|
40
|
+
try {
|
|
41
|
+
for (var _d = true, _e = tslib_1.__asyncValues(startBuild(options, context)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a;) {
|
|
42
|
+
_c = _f.value;
|
|
43
|
+
_d = false;
|
|
44
|
+
try {
|
|
45
|
+
const event = _c;
|
|
46
|
+
if (!event.success) {
|
|
47
|
+
devkit_1.logger.error('There was an error with the build. See above.');
|
|
48
|
+
devkit_1.logger.info(`${event.outfile} was not restarted.`);
|
|
49
|
+
}
|
|
50
|
+
yield tslib_1.__await(handleBuildEvent(uniqueKey, event, options, mappings));
|
|
51
|
+
yield yield tslib_1.__await(event);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
_d = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
|
|
62
|
+
}
|
|
63
|
+
finally { if (e_1) throw e_1.error; }
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.nodeExecutor = nodeExecutor;
|
|
68
|
+
function calculateResolveMappings(context, options) {
|
|
69
|
+
const parsed = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
|
|
70
|
+
const { dependencies } = (0, buildable_libs_utils_1.calculateProjectDependencies)(context.projectGraph, context.root, parsed.project, parsed.target, parsed.configuration);
|
|
71
|
+
return dependencies.reduce((m, c) => {
|
|
72
|
+
if (c.node.type !== 'npm' && c.outputs[0] != null) {
|
|
73
|
+
m[c.name] = (0, devkit_1.joinPathFragments)(context.root, c.outputs[0]);
|
|
74
|
+
}
|
|
75
|
+
return m;
|
|
76
|
+
}, {});
|
|
77
|
+
}
|
|
78
|
+
function runProcess(uniqueKey, event, options, mappings) {
|
|
79
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const execArgv = getExecArgv(options);
|
|
81
|
+
const hashedKey = JSON.stringify([uniqueKey, ...options.args]);
|
|
82
|
+
const hashed = hasher.hashArray(execArgv.concat(hashedKey));
|
|
83
|
+
hashedMap.set(hashedKey, hashed);
|
|
84
|
+
const subProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, 'node-with-require-overrides'), options.args, {
|
|
85
|
+
execArgv,
|
|
86
|
+
stdio: 'inherit',
|
|
87
|
+
env: Object.assign(Object.assign({}, process.env), { NX_FILE_TO_RUN: event.outfile, NX_MAPPINGS: JSON.stringify(mappings) }),
|
|
88
|
+
});
|
|
89
|
+
processMap.set(hashed, subProcess);
|
|
90
|
+
if (!options.watch) {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
subProcess.on('exit', (code) => {
|
|
93
|
+
if (code === 0) {
|
|
94
|
+
resolve(undefined);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
reject();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function getExecArgv(options) {
|
|
105
|
+
const args = [
|
|
106
|
+
'-r',
|
|
107
|
+
require.resolve('source-map-support/register'),
|
|
108
|
+
...options.runtimeArgs,
|
|
109
|
+
];
|
|
110
|
+
if (options.inspect === true) {
|
|
111
|
+
options.inspect = "inspect" /* InspectType.Inspect */;
|
|
112
|
+
}
|
|
113
|
+
if (options.inspect) {
|
|
114
|
+
args.push(`--${options.inspect}=${options.host}:${options.port}`);
|
|
115
|
+
}
|
|
116
|
+
return args;
|
|
117
|
+
}
|
|
118
|
+
function handleBuildEvent(uniqueKey, event, options, mappings) {
|
|
119
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
// Don't kill previous run unless new build is successful.
|
|
121
|
+
if (options.watch && event.success) {
|
|
122
|
+
yield killCurrentProcess(uniqueKey, options);
|
|
123
|
+
}
|
|
124
|
+
if (event.success) {
|
|
125
|
+
yield runProcess(uniqueKey, event, options, mappings);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const promisifiedTreeKill = (0, util_1.promisify)(treeKill);
|
|
130
|
+
function killCurrentProcess(uniqueKey, options, signal = 'SIGTERM') {
|
|
131
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const hashedKey = JSON.stringify([uniqueKey, ...options.args]);
|
|
133
|
+
const currentProcessKey = hashedMap.get(hashedKey);
|
|
134
|
+
if (!currentProcessKey)
|
|
135
|
+
return;
|
|
136
|
+
const currentProcess = processMap.get(currentProcessKey);
|
|
137
|
+
if (!currentProcess)
|
|
138
|
+
return;
|
|
139
|
+
try {
|
|
140
|
+
yield promisifiedTreeKill(currentProcess.pid, signal);
|
|
141
|
+
// if the currentProcess.killed is false, invoke kill()
|
|
142
|
+
// to properly send the signal to the process
|
|
143
|
+
if (!currentProcess.killed) {
|
|
144
|
+
currentProcess.kill(signal);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (Array.isArray(err) && err[0] && err[2]) {
|
|
149
|
+
const errorMessage = err[2];
|
|
150
|
+
devkit_1.logger.error(errorMessage);
|
|
151
|
+
}
|
|
152
|
+
else if (err.message) {
|
|
153
|
+
devkit_1.logger.error(err.message);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
processMap.delete(currentProcessKey);
|
|
158
|
+
hashedMap.delete(hashedKey);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function startBuild(options, context) {
|
|
163
|
+
return tslib_1.__asyncGenerator(this, arguments, function* startBuild_1() {
|
|
164
|
+
const buildTarget = (0, devkit_1.parseTargetString)(options.buildTarget, context.projectGraph);
|
|
165
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(yield tslib_1.__await((0, devkit_1.runExecutor)(buildTarget, Object.assign(Object.assign({}, options.buildTargetOptions), { watch: options.watch }), context)))));
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function runWaitUntilTargets(options, context) {
|
|
169
|
+
return Promise.all(options.waitUntilTargets.map((waitUntilTarget) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
const target = (0, devkit_1.parseTargetString)(waitUntilTarget, context.projectGraph);
|
|
171
|
+
const output = yield (0, devkit_1.runExecutor)(target, {}, context);
|
|
172
|
+
return new Promise((resolve) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
let event = yield output.next();
|
|
174
|
+
// Resolve after first event
|
|
175
|
+
resolve(event.value);
|
|
176
|
+
// Continue iterating
|
|
177
|
+
while (!event.done) {
|
|
178
|
+
event = yield output.next();
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
})));
|
|
182
|
+
}
|
|
183
|
+
exports.default = nodeExecutor;
|
|
184
|
+
//# sourceMappingURL=node.impl.js.map
|