@nestjs/cli 10.0.1 → 10.0.3
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/.circleci/config.yml +2 -2
- package/actions/build.action.js +1 -0
- package/lib/compiler/interfaces/readonly-visitor.interface.d.ts +1 -0
- package/lib/compiler/plugins/plugin-metadata-generator.js +6 -1
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +5 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +17 -2
- package/lib/compiler/swc/swc-compiler.d.ts +2 -0
- package/lib/compiler/swc/swc-compiler.js +6 -1
- package/package.json +1 -1
package/.circleci/config.yml
CHANGED
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
build:
|
|
22
22
|
working_directory: ~/nest
|
|
23
23
|
docker:
|
|
24
|
-
- image: cimg/node:20.
|
|
24
|
+
- image: cimg/node:20.2
|
|
25
25
|
steps:
|
|
26
26
|
- checkout
|
|
27
27
|
- run:
|
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
unit_tests:
|
|
44
44
|
working_directory: ~/nest
|
|
45
45
|
docker:
|
|
46
|
-
- image: cimg/node:20.
|
|
46
|
+
- image: cimg/node:20.2
|
|
47
47
|
steps:
|
|
48
48
|
- checkout
|
|
49
49
|
- *restore-cache
|
package/actions/build.action.js
CHANGED
|
@@ -76,6 +76,7 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
76
76
|
await swc.run(configuration, pathToTsconfig, appName, {
|
|
77
77
|
watch: watchMode,
|
|
78
78
|
typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
|
|
79
|
+
assetsManager: this.assetsManager,
|
|
79
80
|
}, onSuccess);
|
|
80
81
|
}
|
|
81
82
|
runWebpack(configuration, appName, inputs, pathToTsconfig, debug, watchMode, onSuccess) {
|
|
@@ -4,6 +4,7 @@ export type DeepPluginMeta = ts.ObjectLiteralExpression | {
|
|
|
4
4
|
};
|
|
5
5
|
export interface ReadonlyVisitor {
|
|
6
6
|
key: string;
|
|
7
|
+
typeImports: Record<string, string>;
|
|
7
8
|
visit(program: ts.Program, sf: ts.SourceFile): void;
|
|
8
9
|
collect(): Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>;
|
|
9
10
|
}
|
|
@@ -65,11 +65,16 @@ class PluginMetadataGenerator {
|
|
|
65
65
|
visitors.forEach((visitor) => visitor.visit(programRef, sourceFile));
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
let typeImports = {};
|
|
68
69
|
const collectedMetadata = {};
|
|
69
70
|
visitors.forEach((visitor) => {
|
|
70
71
|
collectedMetadata[visitor.key] = visitor.collect();
|
|
72
|
+
typeImports = {
|
|
73
|
+
...typeImports,
|
|
74
|
+
...visitor.typeImports,
|
|
75
|
+
};
|
|
71
76
|
});
|
|
72
|
-
this.pluginMetadataPrinter.print(collectedMetadata, {
|
|
77
|
+
this.pluginMetadataPrinter.print(collectedMetadata, typeImports, {
|
|
73
78
|
outputDir,
|
|
74
79
|
filename,
|
|
75
80
|
});
|
|
@@ -4,10 +4,14 @@ export interface PluginMetadataPrintOptions {
|
|
|
4
4
|
outputDir: string;
|
|
5
5
|
filename?: string;
|
|
6
6
|
}
|
|
7
|
+
type ComposedPluginMeta = Record<string, Record<string, Array<[ts.CallExpression, DeepPluginMeta]>>>;
|
|
7
8
|
/**
|
|
8
9
|
* Prints the metadata to a file.
|
|
9
10
|
*/
|
|
10
11
|
export declare class PluginMetadataPrinter {
|
|
11
|
-
print(metadata:
|
|
12
|
+
print(metadata: ComposedPluginMeta, typeImports: Record<string, string>, options: PluginMetadataPrintOptions): void;
|
|
12
13
|
private recursivelyCreatePropertyAssignment;
|
|
14
|
+
private createTypeImportVariableStatement;
|
|
15
|
+
private createPropertyAssignment;
|
|
13
16
|
}
|
|
17
|
+
export {};
|
|
@@ -5,13 +5,17 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const ts = require("typescript");
|
|
7
7
|
const SERIALIZED_METADATA_FILENAME = 'metadata.ts';
|
|
8
|
+
const TYPE_IMPORT_VARIABLE_NAME = 't';
|
|
8
9
|
/**
|
|
9
10
|
* Prints the metadata to a file.
|
|
10
11
|
*/
|
|
11
12
|
class PluginMetadataPrinter {
|
|
12
|
-
print(metadata, options) {
|
|
13
|
+
print(metadata, typeImports, options) {
|
|
13
14
|
const objectLiteralExpr = ts.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key])));
|
|
14
|
-
const exportAssignment = ts.factory.createExportAssignment(undefined, undefined,
|
|
15
|
+
const exportAssignment = ts.factory.createExportAssignment(undefined, undefined, ts.factory.createArrowFunction([ts.factory.createToken(ts.SyntaxKind.AsyncKeyword)], undefined, [], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createBlock([
|
|
16
|
+
this.createTypeImportVariableStatement(typeImports),
|
|
17
|
+
ts.factory.createReturnStatement(objectLiteralExpr),
|
|
18
|
+
], true)));
|
|
15
19
|
const printer = ts.createPrinter({
|
|
16
20
|
newLine: ts.NewLineKind.LineFeed,
|
|
17
21
|
});
|
|
@@ -33,5 +37,16 @@ class PluginMetadataPrinter {
|
|
|
33
37
|
? meta
|
|
34
38
|
: ts.factory.createObjectLiteralExpression(Object.keys(meta).map((key) => this.recursivelyCreatePropertyAssignment(key, meta[key]))));
|
|
35
39
|
}
|
|
40
|
+
createTypeImportVariableStatement(typeImports) {
|
|
41
|
+
return ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
|
|
42
|
+
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(TYPE_IMPORT_VARIABLE_NAME), undefined, undefined, ts.factory.createObjectLiteralExpression(Object.keys(typeImports).map((ti) => this.createPropertyAssignment(ti, typeImports[ti])), true)),
|
|
43
|
+
], ts.NodeFlags.Const |
|
|
44
|
+
ts.NodeFlags.AwaitContext |
|
|
45
|
+
ts.NodeFlags.ContextFlags |
|
|
46
|
+
ts.NodeFlags.TypeExcludesFlags));
|
|
47
|
+
}
|
|
48
|
+
createPropertyAssignment(identifier, target) {
|
|
49
|
+
return ts.factory.createPropertyAssignment(ts.factory.createComputedPropertyName(ts.factory.createStringLiteral(identifier)), ts.factory.createIdentifier(target));
|
|
50
|
+
}
|
|
36
51
|
}
|
|
37
52
|
exports.PluginMetadataPrinter = PluginMetadataPrinter;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Configuration } from '../../configuration';
|
|
2
|
+
import { AssetsManager } from '../assets-manager';
|
|
2
3
|
import { BaseCompiler } from '../base-compiler';
|
|
3
4
|
import { PluginsLoader } from '../plugins/plugins-loader';
|
|
4
5
|
export type SwcCompilerExtras = {
|
|
5
6
|
watch: boolean;
|
|
6
7
|
typeCheck: boolean;
|
|
8
|
+
assetsManager: AssetsManager;
|
|
7
9
|
};
|
|
8
10
|
export declare class SwcCompiler extends BaseCompiler {
|
|
9
11
|
private readonly pluginMetadataGenerator;
|
|
@@ -38,7 +38,12 @@ class SwcCompiler extends base_compiler_1.BaseCompiler {
|
|
|
38
38
|
await this.runTypeChecker(configuration, tsConfigPath, appName, extras);
|
|
39
39
|
}
|
|
40
40
|
await this.runSwc(swcOptions, extras);
|
|
41
|
-
onSuccess
|
|
41
|
+
if (onSuccess) {
|
|
42
|
+
onSuccess();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
extras.assetsManager?.closeWatchers();
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
}
|
|
44
49
|
runTypeChecker(configuration, tsConfigPath, appName, extras) {
|