@nestjs/cli 11.0.0-next.0 → 11.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 +28 -53
- package/commands/start.command.js +1 -0
- package/package.json +1 -1
package/actions/build.action.js
CHANGED
|
@@ -49,10 +49,10 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
49
49
|
async runBuild(commandInputs, commandOptions, watchMode, watchAssetsMode, isDebugEnabled = false, onSuccess) {
|
|
50
50
|
const configFileName = commandOptions.find((option) => option.name === 'config').value;
|
|
51
51
|
const configuration = await this.loader.load(configFileName);
|
|
52
|
-
const buildAll = commandOptions.find((opt) => opt.name === 'all')
|
|
53
|
-
.value;
|
|
52
|
+
const buildAll = commandOptions.find((opt) => opt.name === 'all')?.value;
|
|
54
53
|
let appNames;
|
|
55
54
|
if (buildAll) {
|
|
55
|
+
// If the "all" flag is set, we need to build all projects in a monorepo.
|
|
56
56
|
appNames = [];
|
|
57
57
|
if (configuration.projects) {
|
|
58
58
|
appNames.push(...Object.keys(configuration.projects));
|
|
@@ -63,6 +63,10 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
63
63
|
.filter((input) => input.name === 'app')
|
|
64
64
|
.map((input) => input.value);
|
|
65
65
|
}
|
|
66
|
+
if (appNames.length === 0) {
|
|
67
|
+
// If there are no projects, use "undefined" to build the default project.
|
|
68
|
+
appNames.push(undefined);
|
|
69
|
+
}
|
|
66
70
|
for (const appName of appNames) {
|
|
67
71
|
const pathToTsconfig = (0, get_tsc_config_path_1.getTscConfigPath)(configuration, commandOptions, appName);
|
|
68
72
|
const { options: tsOptions } = this.tsConfigProvider.getByConfigFilename(pathToTsconfig);
|
|
@@ -80,82 +84,53 @@ class BuildAction extends abstract_action_1.AbstractAction {
|
|
|
80
84
|
}
|
|
81
85
|
switch (builder.type) {
|
|
82
86
|
case 'tsc':
|
|
83
|
-
await this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName);
|
|
87
|
+
await this.runTsc(watchMode, commandOptions, configuration, pathToTsconfig, appName, onSuccess);
|
|
84
88
|
break;
|
|
85
89
|
case 'webpack':
|
|
86
|
-
await this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode);
|
|
90
|
+
await this.runWebpack(configuration, appName, commandOptions, pathToTsconfig, isDebugEnabled, watchMode, onSuccess);
|
|
87
91
|
break;
|
|
88
92
|
case 'swc':
|
|
89
|
-
await this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions);
|
|
93
|
+
await this.runSwc(configuration, appName, pathToTsconfig, watchMode, commandOptions, tsOptions, onSuccess);
|
|
90
94
|
break;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
|
-
onSuccess?.();
|
|
94
97
|
}
|
|
95
|
-
async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions) {
|
|
98
|
+
async runSwc(configuration, appName, pathToTsconfig, watchMode, options, tsOptions, onSuccess) {
|
|
96
99
|
const { SwcCompiler } = await Promise.resolve().then(() => require('../lib/compiler/swc/swc-compiler'));
|
|
97
100
|
const swc = new SwcCompiler(this.pluginsLoader);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
assetsManager: this.assetsManager,
|
|
105
|
-
}, onSuccess);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
onError(error);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
101
|
+
await swc.run(configuration, pathToTsconfig, appName, {
|
|
102
|
+
watch: watchMode,
|
|
103
|
+
typeCheck: (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.typeCheck', appName, 'typeCheck', options),
|
|
104
|
+
tsOptions,
|
|
105
|
+
assetsManager: this.assetsManager,
|
|
106
|
+
}, onSuccess);
|
|
111
107
|
}
|
|
112
|
-
async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode) {
|
|
108
|
+
async runWebpack(configuration, appName, commandOptions, pathToTsconfig, debug, watchMode, onSuccess) {
|
|
113
109
|
const { WebpackCompiler } = await Promise.resolve().then(() => require('../lib/compiler/webpack-compiler'));
|
|
114
110
|
const webpackCompiler = new WebpackCompiler(this.pluginsLoader);
|
|
115
111
|
const webpackPath = (0, get_webpack_config_path_1.getWebpackConfigPath)(configuration, commandOptions, appName) ??
|
|
116
112
|
defaults_1.defaultWebpackConfigFilename;
|
|
117
113
|
const webpackConfigFactoryOrConfig = this.getWebpackConfigFactoryByPath(webpackPath, defaults_1.defaultWebpackConfigFilename);
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
assetsManager: this.assetsManager,
|
|
126
|
-
}, onSuccess);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
onError(error);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
114
|
+
return webpackCompiler.run(configuration, pathToTsconfig, appName, {
|
|
115
|
+
inputs: commandOptions,
|
|
116
|
+
webpackConfigFactoryOrConfig,
|
|
117
|
+
debug,
|
|
118
|
+
watchMode,
|
|
119
|
+
assetsManager: this.assetsManager,
|
|
120
|
+
}, onSuccess);
|
|
132
121
|
}
|
|
133
|
-
async runTsc(watchMode, options, configuration, pathToTsconfig, appName) {
|
|
122
|
+
async runTsc(watchMode, options, configuration, pathToTsconfig, appName, onSuccess) {
|
|
134
123
|
if (watchMode) {
|
|
135
124
|
const { WatchCompiler } = await Promise.resolve().then(() => require('../lib/compiler/watch-compiler'));
|
|
136
125
|
const watchCompiler = new WatchCompiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
|
|
137
126
|
const isPreserveWatchOutputEnabled = options.find((option) => option.name === 'preserveWatchOutput' && option.value === true)?.value;
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
onError(error);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
127
|
+
watchCompiler.run(configuration, pathToTsconfig, appName, { preserveWatchOutput: isPreserveWatchOutputEnabled }, onSuccess);
|
|
146
128
|
}
|
|
147
129
|
else {
|
|
148
130
|
const { Compiler } = await Promise.resolve().then(() => require('../lib/compiler/compiler'));
|
|
149
131
|
const compiler = new Compiler(this.pluginsLoader, this.tsConfigProvider, this.tsLoader);
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
|
|
153
|
-
this.assetsManager.closeWatchers();
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
onError(error);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
132
|
+
compiler.run(configuration, pathToTsconfig, appName, undefined, onSuccess);
|
|
133
|
+
this.assetsManager.closeWatchers();
|
|
159
134
|
}
|
|
160
135
|
}
|
|
161
136
|
getWebpackConfigFactoryByPath(webpackPath, defaultPath) {
|
|
@@ -24,6 +24,7 @@ class StartCommand extends abstract_command_1.AbstractCommand {
|
|
|
24
24
|
.option('-e, --exec [binary]', 'Binary to run (default: "node").')
|
|
25
25
|
.option('--preserveWatchOutput', 'Use "preserveWatchOutput" option when using tsc watch mode.')
|
|
26
26
|
.option('--shell', "Spawn child processes within a shell (see node's child_process.spawn() method docs). Default: true.", true)
|
|
27
|
+
.option('--no-shell', 'Do not spawn child processes within a shell.')
|
|
27
28
|
.description('Run Nest application.')
|
|
28
29
|
.action(async (app, command) => {
|
|
29
30
|
const options = [];
|