@nestjs/cli 10.0.0-next.1 → 10.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/build.action.js +4 -1
- package/lib/compiler/defaults/swc-defaults.d.ts +3 -1
- package/lib/compiler/defaults/swc-defaults.js +9 -17
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +1 -1
- package/lib/compiler/plugins/index.d.ts +1 -0
- package/lib/compiler/plugins/index.js +17 -0
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +1 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +8 -5
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +6 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +9 -2
- package/lib/compiler/swc/swc-compiler.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +17 -0
- package/package.json +7 -2
package/actions/build.action.js
CHANGED
|
@@ -68,7 +68,10 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
68
68
|
const pathToTsconfig = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', options);
|
|
69
69
|
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
70
70
|
const outDir = tsOptions.outDir || defaults_1.defaultOutDir;
|
|
71
|
-
const
|
|
71
|
+
const isWebpackEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpack', appName, 'webpack', options);
|
|
72
|
+
const builder = isWebpackEnabled
|
|
73
|
+
? 'webpack'
|
|
74
|
+
: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', options);
|
|
72
75
|
yield this.workspaceUtils.deleteOutDirIfEnabled(configuration, appName, outDir);
|
|
73
76
|
this.assetsManager.copyAssets(configuration, appName, outDir, watchAssetsMode);
|
|
74
77
|
switch (builder) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare const swcDefaultsFactory: () => {
|
|
2
2
|
swcOptions: {
|
|
3
|
+
module: {
|
|
4
|
+
type: string;
|
|
5
|
+
};
|
|
3
6
|
jsc: {
|
|
4
7
|
target: string;
|
|
5
8
|
parser: {
|
|
@@ -25,7 +28,6 @@ export declare const swcDefaultsFactory: () => {
|
|
|
25
28
|
watch: boolean;
|
|
26
29
|
copyFiles: boolean;
|
|
27
30
|
includeDotfiles: boolean;
|
|
28
|
-
deleteDirOnStart: boolean;
|
|
29
31
|
quiet: boolean;
|
|
30
32
|
};
|
|
31
33
|
};
|
|
@@ -4,16 +4,19 @@ exports.swcDefaultsFactory = void 0;
|
|
|
4
4
|
const swcDefaultsFactory = () => {
|
|
5
5
|
return {
|
|
6
6
|
swcOptions: {
|
|
7
|
+
module: {
|
|
8
|
+
type: 'commonjs',
|
|
9
|
+
},
|
|
7
10
|
jsc: {
|
|
8
11
|
target: 'es2021',
|
|
9
12
|
parser: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
syntax: 'typescript',
|
|
14
|
+
decorators: true,
|
|
15
|
+
dynamicImport: true,
|
|
13
16
|
},
|
|
14
17
|
transform: {
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
legacyDecorator: true,
|
|
19
|
+
decoratorMetadata: true,
|
|
17
20
|
},
|
|
18
21
|
keepClassNames: true,
|
|
19
22
|
baseUrl: './',
|
|
@@ -25,21 +28,10 @@ const swcDefaultsFactory = () => {
|
|
|
25
28
|
outDir: 'dist',
|
|
26
29
|
filenames: ['src'],
|
|
27
30
|
sync: false,
|
|
28
|
-
extensions: [
|
|
29
|
-
'.js',
|
|
30
|
-
'.jsx',
|
|
31
|
-
'.es6',
|
|
32
|
-
'.es',
|
|
33
|
-
'.mjs',
|
|
34
|
-
'.ts',
|
|
35
|
-
'.tsx',
|
|
36
|
-
'.cts',
|
|
37
|
-
'.mts',
|
|
38
|
-
],
|
|
31
|
+
extensions: ['.js', '.ts'],
|
|
39
32
|
watch: false,
|
|
40
33
|
copyFiles: false,
|
|
41
34
|
includeDotfiles: false,
|
|
42
|
-
deleteDirOnStart: true,
|
|
43
35
|
quiet: false,
|
|
44
36
|
},
|
|
45
37
|
};
|
|
@@ -5,5 +5,5 @@ export type DeepPluginMeta = ts.ObjectLiteralExpression | {
|
|
|
5
5
|
export interface ReadonlyVisitor {
|
|
6
6
|
key: string;
|
|
7
7
|
visit(program: ts.Program, sf: ts.SourceFile): void;
|
|
8
|
-
collect():
|
|
8
|
+
collect(): Array<[ts.CallExpression, DeepPluginMeta]>;
|
|
9
9
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugin-metadata-generator';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./plugin-metadata-generator"), exports);
|
|
@@ -9,21 +9,21 @@ class PluginMetadataGenerator {
|
|
|
9
9
|
this.typeCheckerHost = new type_checker_host_1.TypeCheckerHost();
|
|
10
10
|
}
|
|
11
11
|
generate(options) {
|
|
12
|
-
const { tsconfigPath, visitors, tsProgramRef, outputDir, watch } = options;
|
|
12
|
+
const { tsconfigPath, visitors, tsProgramRef, outputDir, watch, filename } = options;
|
|
13
13
|
if (visitors.length === 0) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
if (tsProgramRef) {
|
|
17
|
-
return this.traverseAndPrintMetadata(tsProgramRef, visitors, outputDir);
|
|
17
|
+
return this.traverseAndPrintMetadata(tsProgramRef, visitors, outputDir, filename);
|
|
18
18
|
}
|
|
19
19
|
this.typeCheckerHost.run(tsconfigPath, {
|
|
20
20
|
watch,
|
|
21
21
|
onSuccess: (program) => {
|
|
22
|
-
this.traverseAndPrintMetadata(program, visitors, outputDir);
|
|
22
|
+
this.traverseAndPrintMetadata(program, visitors, outputDir, filename);
|
|
23
23
|
},
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
traverseAndPrintMetadata(programRef, visitors, outputDir) {
|
|
26
|
+
traverseAndPrintMetadata(programRef, visitors, outputDir, filename) {
|
|
27
27
|
for (const sourceFile of programRef.getSourceFiles()) {
|
|
28
28
|
if (!sourceFile.isDeclarationFile) {
|
|
29
29
|
visitors.forEach((visitor) => visitor.visit(programRef, sourceFile));
|
|
@@ -33,7 +33,10 @@ class PluginMetadataGenerator {
|
|
|
33
33
|
visitors.forEach((visitor) => {
|
|
34
34
|
collectedMetadata[visitor.key] = visitor.collect();
|
|
35
35
|
});
|
|
36
|
-
this.pluginMetadataPrinter.print(collectedMetadata,
|
|
36
|
+
this.pluginMetadataPrinter.print(collectedMetadata, {
|
|
37
|
+
outputDir,
|
|
38
|
+
filename,
|
|
39
|
+
});
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
exports.PluginMetadataGenerator = PluginMetadataGenerator;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
1
2
|
import { DeepPluginMeta } from '../interfaces/readonly-visitor.interface';
|
|
3
|
+
export interface PluginMetadataPrintOptions {
|
|
4
|
+
outputDir: string;
|
|
5
|
+
filename?: string;
|
|
6
|
+
}
|
|
2
7
|
export declare class PluginMetadataPrinter {
|
|
3
|
-
print(metadata:
|
|
8
|
+
print(metadata: Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>, options: PluginMetadataPrintOptions): void;
|
|
4
9
|
private recursivelyCreatePropertyAssignment;
|
|
5
10
|
}
|
|
@@ -6,7 +6,8 @@ const path_1 = require("path");
|
|
|
6
6
|
const ts = require("typescript");
|
|
7
7
|
const SERIALIZED_METADATA_FILENAME = 'metadata.ts';
|
|
8
8
|
class PluginMetadataPrinter {
|
|
9
|
-
print(metadata,
|
|
9
|
+
print(metadata, options) {
|
|
10
|
+
var _a;
|
|
10
11
|
const objectLiteralExpr = ts.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key])));
|
|
11
12
|
const metadataCacheVariableStatement = ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
12
13
|
ts.factory.createVariableDeclaration(ts.factory.createIdentifier('metadataCache'), undefined, undefined, objectLiteralExpr),
|
|
@@ -16,12 +17,18 @@ class PluginMetadataPrinter {
|
|
|
16
17
|
});
|
|
17
18
|
const resultFile = ts.createSourceFile('file.ts', '', ts.ScriptTarget.Latest,
|
|
18
19
|
/*setParentNodes*/ false, ts.ScriptKind.TS);
|
|
19
|
-
const filename = (0, path_1.join)(outputDir, SERIALIZED_METADATA_FILENAME);
|
|
20
|
+
const filename = (0, path_1.join)(options.outputDir, (_a = options.filename) !== null && _a !== void 0 ? _a : SERIALIZED_METADATA_FILENAME);
|
|
20
21
|
const eslintPrefix = `/* eslint-disable */\n`;
|
|
21
22
|
(0, fs_1.writeFileSync)(filename, eslintPrefix +
|
|
22
23
|
printer.printNode(ts.EmitHint.Unspecified, metadataCacheVariableStatement, resultFile));
|
|
23
24
|
}
|
|
24
25
|
recursivelyCreatePropertyAssignment(identifier, meta) {
|
|
26
|
+
if (Array.isArray(meta)) {
|
|
27
|
+
return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(identifier), ts.factory.createArrayLiteralExpression(meta.map(([importExpr, meta]) => ts.factory.createArrayLiteralExpression([
|
|
28
|
+
importExpr,
|
|
29
|
+
ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))),
|
|
30
|
+
]))));
|
|
31
|
+
}
|
|
25
32
|
return ts.factory.createPropertyAssignment(ts.factory.createStringLiteral(identifier), ts.isObjectLiteralExpression(meta)
|
|
26
33
|
? meta
|
|
27
34
|
: ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))));
|
|
@@ -115,7 +115,7 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
|
|
|
115
115
|
}
|
|
116
116
|
catch (err) {
|
|
117
117
|
console.error(ui_1.ERROR_PREFIX +
|
|
118
|
-
' Failed to load "@swc/cli"
|
|
118
|
+
' Failed to load "@swc/cli" and "@swc/core" packages. Please, install them by running "npm i -D @swc/cli @swc/core".');
|
|
119
119
|
throw err;
|
|
120
120
|
}
|
|
121
121
|
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './compiler/plugins';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./compiler/plugins"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestjs/cli",
|
|
3
|
-
"version": "10.0.0-next.
|
|
3
|
+
"version": "10.0.0-next.2",
|
|
4
4
|
"description": "Nest - modern, fast, powerful node.js web framework (@cli)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@commitlint/cli": "17.6.3",
|
|
66
66
|
"@commitlint/config-angular": "17.6.3",
|
|
67
67
|
"@swc/cli": "0.1.62",
|
|
68
|
+
"@swc/core": "1.3.62",
|
|
68
69
|
"@types/inquirer": "8.2.6",
|
|
69
70
|
"@types/jest": "29.5.1",
|
|
70
71
|
"@types/node": "18.16.12",
|
|
@@ -90,11 +91,15 @@
|
|
|
90
91
|
"**/*.{ts,json}": []
|
|
91
92
|
},
|
|
92
93
|
"peerDependencies": {
|
|
93
|
-
"@swc/cli": "^0.1.62"
|
|
94
|
+
"@swc/cli": "^0.1.62",
|
|
95
|
+
"@swc/core": "^1.3.62"
|
|
94
96
|
},
|
|
95
97
|
"peerDependenciesMeta": {
|
|
96
98
|
"@swc/cli": {
|
|
97
99
|
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"@swc/core": {
|
|
102
|
+
"optional": true
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
}
|