@nestjs/cli 11.0.16 → 12.0.0-alpha.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/actions/abstract.action.d.ts +1 -2
- package/actions/abstract.action.js +1 -5
- package/actions/add.action.d.ts +3 -4
- package/actions/add.action.js +38 -52
- package/actions/build.action.d.ts +11 -10
- package/actions/build.action.js +85 -72
- package/actions/generate.action.d.ts +3 -3
- package/actions/generate.action.js +56 -59
- package/actions/index.d.ts +7 -7
- package/actions/index.js +7 -23
- package/actions/info.action.d.ts +12 -28
- package/actions/info.action.js +47 -55
- package/actions/new.action.d.ts +3 -3
- package/actions/new.action.js +75 -105
- package/actions/start.action.d.ts +4 -7
- package/actions/start.action.js +36 -46
- package/bin/nest.js +14 -10
- package/commands/abstract.command.d.ts +3 -3
- package/commands/abstract.command.js +2 -5
- package/commands/add.command.d.ts +3 -3
- package/commands/add.command.js +13 -20
- package/commands/build.command.d.ts +3 -3
- package/commands/build.command.js +25 -54
- package/commands/command.input.js +1 -2
- package/commands/command.loader.d.ts +2 -2
- package/commands/command.loader.js +18 -22
- package/commands/context/add.context.d.ts +7 -0
- package/commands/context/add.context.js +1 -0
- package/commands/context/build.context.d.ts +13 -0
- package/commands/context/build.context.js +1 -0
- package/commands/context/generate.context.d.ts +15 -0
- package/commands/context/generate.context.js +1 -0
- package/commands/context/index.d.ts +5 -0
- package/commands/context/index.js +5 -0
- package/commands/context/new.context.d.ts +11 -0
- package/commands/context/new.context.js +1 -0
- package/commands/context/start.context.d.ts +19 -0
- package/commands/context/start.context.js +1 -0
- package/commands/generate.command.d.ts +3 -3
- package/commands/generate.command.js +26 -54
- package/commands/index.d.ts +3 -2
- package/commands/index.js +3 -18
- package/commands/info.command.d.ts +3 -3
- package/commands/info.command.js +2 -6
- package/commands/new.command.d.ts +3 -3
- package/commands/new.command.js +24 -33
- package/commands/start.command.d.ts +3 -3
- package/commands/start.command.js +34 -71
- package/lib/compiler/assets-manager.d.ts +1 -1
- package/lib/compiler/assets-manager.js +27 -33
- package/lib/compiler/base-compiler.d.ts +5 -5
- package/lib/compiler/base-compiler.js +10 -13
- package/lib/compiler/compiler.d.ts +6 -6
- package/lib/compiler/compiler.js +7 -9
- package/lib/compiler/defaults/rspack-defaults.d.ts +2 -0
- package/lib/compiler/defaults/rspack-defaults.js +138 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +1 -1
- package/lib/compiler/defaults/swc-defaults.js +1 -5
- package/lib/compiler/defaults/webpack-defaults.d.ts +3 -3
- package/lib/compiler/defaults/webpack-defaults.js +36 -18
- package/lib/compiler/helpers/append-extension.js +3 -6
- package/lib/compiler/helpers/copy-path-resolve.js +2 -5
- package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
- package/lib/compiler/helpers/delete-out-dir.js +5 -8
- package/lib/compiler/helpers/get-builder.d.ts +9 -7
- package/lib/compiler/helpers/get-builder.js +3 -6
- package/lib/compiler/helpers/get-rspack-config-path.d.ts +9 -0
- package/lib/compiler/helpers/get-rspack-config-path.js +15 -0
- package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
- package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
- package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
- package/lib/compiler/helpers/get-value-or-default.js +3 -8
- package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
- package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
- package/lib/compiler/helpers/manual-restart.js +4 -8
- package/lib/compiler/helpers/tsconfig-provider.d.ts +1 -1
- package/lib/compiler/helpers/tsconfig-provider.js +8 -11
- package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
- package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
- package/lib/compiler/plugins/plugin-metadata-generator.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-generator.js +10 -13
- package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
- package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
- package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
- package/lib/compiler/plugins/plugins-loader.js +13 -13
- package/lib/compiler/rspack-compiler.d.ts +19 -0
- package/lib/compiler/rspack-compiler.js +105 -0
- package/lib/compiler/swc/constants.d.ts +0 -1
- package/lib/compiler/swc/constants.js +9 -13
- package/lib/compiler/swc/forked-type-checker.js +13 -18
- package/lib/compiler/swc/swc-compiler.d.ts +4 -4
- package/lib/compiler/swc/swc-compiler.js +41 -39
- package/lib/compiler/swc/type-checker-host.js +12 -18
- package/lib/compiler/typescript-loader.js +5 -7
- package/lib/compiler/watch-compiler.d.ts +5 -5
- package/lib/compiler/watch-compiler.js +14 -18
- package/lib/compiler/webpack-compiler.d.ts +6 -7
- package/lib/compiler/webpack-compiler.js +30 -22
- package/lib/configuration/configuration.d.ts +9 -4
- package/lib/configuration/configuration.js +1 -2
- package/lib/configuration/configuration.loader.d.ts +1 -1
- package/lib/configuration/configuration.loader.js +1 -2
- package/lib/configuration/defaults.d.ts +2 -1
- package/lib/configuration/defaults.js +8 -10
- package/lib/configuration/index.d.ts +3 -3
- package/lib/configuration/index.js +3 -19
- package/lib/configuration/nest-configuration.loader.d.ts +3 -3
- package/lib/configuration/nest-configuration.loader.js +11 -20
- package/lib/package-managers/abstract.package-manager.d.ts +4 -4
- package/lib/package-managers/abstract.package-manager.js +19 -30
- package/lib/package-managers/index.d.ts +8 -8
- package/lib/package-managers/index.js +8 -24
- package/lib/package-managers/npm.package-manager.d.ts +2 -2
- package/lib/package-managers/npm.package-manager.js +6 -10
- package/lib/package-managers/package-manager-commands.js +1 -2
- package/lib/package-managers/package-manager.factory.d.ts +2 -2
- package/lib/package-managers/package-manager.factory.js +16 -20
- package/lib/package-managers/package-manager.js +2 -5
- package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
- package/lib/package-managers/pnpm.package-manager.js +6 -10
- package/lib/package-managers/project.dependency.js +1 -2
- package/lib/package-managers/yarn.package-manager.d.ts +2 -2
- package/lib/package-managers/yarn.package-manager.js +6 -10
- package/lib/questions/questions.d.ts +5 -1
- package/lib/questions/questions.js +2 -7
- package/lib/readers/file-system.reader.d.ts +1 -1
- package/lib/readers/file-system.reader.js +6 -9
- package/lib/readers/index.d.ts +2 -2
- package/lib/readers/index.js +2 -18
- package/lib/readers/reader.js +3 -5
- package/lib/runners/abstract.runner.js +10 -12
- package/lib/runners/git.runner.d.ts +1 -1
- package/lib/runners/git.runner.js +2 -6
- package/lib/runners/index.d.ts +3 -3
- package/lib/runners/index.js +3 -19
- package/lib/runners/npm.runner.d.ts +1 -1
- package/lib/runners/npm.runner.js +2 -6
- package/lib/runners/pnpm.runner.d.ts +1 -1
- package/lib/runners/pnpm.runner.js +2 -6
- package/lib/runners/runner.factory.d.ts +6 -6
- package/lib/runners/runner.factory.js +15 -20
- package/lib/runners/runner.js +2 -5
- package/lib/runners/schematic.runner.d.ts +1 -1
- package/lib/runners/schematic.runner.js +5 -7
- package/lib/runners/yarn.runner.d.ts +1 -1
- package/lib/runners/yarn.runner.js +2 -6
- package/lib/schematics/abstract.collection.d.ts +3 -3
- package/lib/schematics/abstract.collection.js +3 -5
- package/lib/schematics/collection.factory.d.ts +2 -2
- package/lib/schematics/collection.factory.js +9 -13
- package/lib/schematics/collection.js +2 -5
- package/lib/schematics/custom.collection.d.ts +2 -2
- package/lib/schematics/custom.collection.js +4 -8
- package/lib/schematics/index.d.ts +4 -4
- package/lib/schematics/index.js +4 -20
- package/lib/schematics/nest.collection.d.ts +3 -3
- package/lib/schematics/nest.collection.js +104 -108
- package/lib/schematics/schematic.option.js +7 -9
- package/lib/ui/banner.js +1 -4
- package/lib/ui/emojis.d.ts +17 -17
- package/lib/ui/emojis.js +19 -22
- package/lib/ui/errors.js +1 -5
- package/lib/ui/index.d.ts +5 -5
- package/lib/ui/index.js +5 -21
- package/lib/ui/messages.js +15 -19
- package/lib/ui/prefixes.js +3 -6
- package/lib/utils/formatting.js +1 -4
- package/lib/utils/get-default-tsconfig-path.js +4 -7
- package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
- package/lib/utils/is-esm-project.d.ts +5 -0
- package/lib/utils/is-esm-project.js +16 -0
- package/lib/utils/is-module-available.js +3 -4
- package/lib/utils/load-configuration.d.ts +1 -1
- package/lib/utils/load-configuration.js +4 -7
- package/lib/utils/local-binaries.d.ts +1 -1
- package/lib/utils/local-binaries.js +8 -11
- package/lib/utils/os-info.utils.js +1 -4
- package/lib/utils/project-utils.d.ts +1 -3
- package/lib/utils/project-utils.js +16 -28
- package/lib/utils/remaining-flags.d.ts +2 -2
- package/lib/utils/remaining-flags.js +2 -5
- package/lib/utils/tree-kill.js +7 -10
- package/lib/utils/type-assertions.js +1 -4
- package/package.json +59 -38
package/lib/compiler/compiler.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class Compiler extends base_compiler_1.BaseCompiler {
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { BaseCompiler } from './base-compiler.js';
|
|
3
|
+
import { tsconfigPathsBeforeHookFactory } from './hooks/tsconfig-paths.hook.js';
|
|
4
|
+
export class Compiler extends BaseCompiler {
|
|
5
|
+
tsConfigProvider;
|
|
6
|
+
typescriptLoader;
|
|
8
7
|
constructor(pluginsLoader, tsConfigProvider, typescriptLoader) {
|
|
9
8
|
super(pluginsLoader);
|
|
10
9
|
this.tsConfigProvider = tsConfigProvider;
|
|
@@ -25,7 +24,7 @@ class Compiler extends base_compiler_1.BaseCompiler {
|
|
|
25
24
|
options,
|
|
26
25
|
});
|
|
27
26
|
const plugins = this.loadPlugins(configuration, tsConfigPath, appName);
|
|
28
|
-
const tsconfigPathsPlugin =
|
|
27
|
+
const tsconfigPathsPlugin = tsconfigPathsBeforeHookFactory(options);
|
|
29
28
|
const programRef = program.getProgram
|
|
30
29
|
? program.getProgram()
|
|
31
30
|
: program;
|
|
@@ -58,4 +57,3 @@ class Compiler extends base_compiler_1.BaseCompiler {
|
|
|
58
57
|
return diagnostics.length;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
exports.Compiler = Compiler;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { MultiNestCompilerPlugins } from '../plugins/plugins-loader.js';
|
|
2
|
+
export declare const rspackDefaultsFactory: (sourceRoot: string, relativeSourceRoot: string, entryFilename: string, isDebugEnabled: boolean | undefined, tsConfigFile: string | undefined, plugins: MultiNestCompilerPlugins, isEsm?: boolean) => Record<string, any>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { defaultTsconfigFilename } from '../../configuration/defaults.js';
|
|
4
|
+
import { appendTsExtension } from '../helpers/append-extension.js';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
function loadRspackDeps() {
|
|
7
|
+
try {
|
|
8
|
+
const externals = require('webpack-node-externals');
|
|
9
|
+
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
|
|
10
|
+
return { nodeExternals: externals, TsconfigPathsPlugin };
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
const pkg = e?.message?.match?.(/Cannot find.*'([^']+)'/)?.[1] ?? 'webpack-node-externals';
|
|
14
|
+
throw new Error(`The "${pkg}" package is required when using the rspack compiler but could not be found. ` +
|
|
15
|
+
`Please install it:\n\n npm install --save-dev @rspack/core webpack-node-externals tsconfig-paths-webpack-plugin\n`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const rspackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaultTsconfigFilename, plugins, isEsm = false) => {
|
|
19
|
+
const { nodeExternals: externals, TsconfigPathsPlugin } = loadRspackDeps();
|
|
20
|
+
const isPluginRegistered = isAnyPluginRegistered(plugins);
|
|
21
|
+
const rspackConfiguration = {
|
|
22
|
+
entry: appendTsExtension(join(sourceRoot, entryFilename)),
|
|
23
|
+
devtool: isDebugEnabled ? 'inline-source-map' : false,
|
|
24
|
+
target: 'node',
|
|
25
|
+
output: {
|
|
26
|
+
filename: join(relativeSourceRoot, `${entryFilename}.js`),
|
|
27
|
+
...(isEsm && {
|
|
28
|
+
module: true,
|
|
29
|
+
library: { type: 'module' },
|
|
30
|
+
chunkFormat: 'module',
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
...(isEsm && {
|
|
34
|
+
experiments: { outputModule: true },
|
|
35
|
+
}),
|
|
36
|
+
ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
|
|
37
|
+
externals: [
|
|
38
|
+
externals(isEsm ? { importType: 'module' } : {}),
|
|
39
|
+
],
|
|
40
|
+
externalsPresets: { node: true },
|
|
41
|
+
module: {
|
|
42
|
+
rules: [
|
|
43
|
+
{
|
|
44
|
+
test: /\.tsx?$/,
|
|
45
|
+
use: [
|
|
46
|
+
{
|
|
47
|
+
loader: 'builtin:swc-loader',
|
|
48
|
+
options: {
|
|
49
|
+
jsc: {
|
|
50
|
+
parser: {
|
|
51
|
+
syntax: 'typescript',
|
|
52
|
+
decorators: true,
|
|
53
|
+
},
|
|
54
|
+
transform: {
|
|
55
|
+
legacyDecorator: true,
|
|
56
|
+
decoratorMetadata: true,
|
|
57
|
+
},
|
|
58
|
+
target: 'es2021',
|
|
59
|
+
},
|
|
60
|
+
sourceMaps: isDebugEnabled,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
exclude: /node_modules/,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
resolve: {
|
|
69
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
70
|
+
tsConfig: tsConfigFile,
|
|
71
|
+
plugins: [
|
|
72
|
+
new TsconfigPathsPlugin({
|
|
73
|
+
configFile: tsConfigFile,
|
|
74
|
+
}),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
mode: 'none',
|
|
78
|
+
optimization: {
|
|
79
|
+
nodeEnv: false,
|
|
80
|
+
},
|
|
81
|
+
node: {
|
|
82
|
+
__filename: false,
|
|
83
|
+
__dirname: false,
|
|
84
|
+
},
|
|
85
|
+
plugins: [],
|
|
86
|
+
};
|
|
87
|
+
// rspack has built-in IgnorePlugin (compatible with webpack's)
|
|
88
|
+
try {
|
|
89
|
+
const rspack = require('@rspack/core');
|
|
90
|
+
rspackConfiguration.plugins.push(new rspack.IgnorePlugin({
|
|
91
|
+
checkResource(resource) {
|
|
92
|
+
const lazyImports = [
|
|
93
|
+
'@nestjs/microservices',
|
|
94
|
+
'@nestjs/microservices/microservices-module',
|
|
95
|
+
'@nestjs/websockets/socket-module',
|
|
96
|
+
'class-validator',
|
|
97
|
+
'class-transformer',
|
|
98
|
+
'class-transformer/storage',
|
|
99
|
+
];
|
|
100
|
+
if (!lazyImports.includes(resource)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
require.resolve(resource, {
|
|
105
|
+
paths: [process.cwd()],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
},
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// @rspack/core not available, skip IgnorePlugin
|
|
117
|
+
}
|
|
118
|
+
if (!isPluginRegistered) {
|
|
119
|
+
try {
|
|
120
|
+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
121
|
+
rspackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
122
|
+
typescript: {
|
|
123
|
+
configFile: tsConfigFile,
|
|
124
|
+
},
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// fork-ts-checker-webpack-plugin not available, skip
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return rspackConfiguration;
|
|
132
|
+
};
|
|
133
|
+
function isAnyPluginRegistered(plugins) {
|
|
134
|
+
return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
|
|
135
|
+
(plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
|
|
136
|
+
(plugins.afterDeclarationsHooks &&
|
|
137
|
+
plugins.afterDeclarationsHooks.length > 0));
|
|
138
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { Configuration } from '../../configuration';
|
|
2
|
+
import { Configuration } from '../../configuration/index.js';
|
|
3
3
|
export declare const swcDefaultsFactory: (tsOptions?: ts.CompilerOptions, configuration?: Configuration) => {
|
|
4
4
|
swcOptions: {
|
|
5
5
|
sourceMaps: string | boolean | undefined;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.swcDefaultsFactory = void 0;
|
|
4
|
-
const swcDefaultsFactory = (tsOptions, configuration) => {
|
|
1
|
+
export const swcDefaultsFactory = (tsOptions, configuration) => {
|
|
5
2
|
const builderOptions = typeof configuration?.compilerOptions?.builder !== 'string'
|
|
6
3
|
? configuration?.compilerOptions?.builder?.options
|
|
7
4
|
: {};
|
|
@@ -44,7 +41,6 @@ const swcDefaultsFactory = (tsOptions, configuration) => {
|
|
|
44
41
|
},
|
|
45
42
|
};
|
|
46
43
|
};
|
|
47
|
-
exports.swcDefaultsFactory = swcDefaultsFactory;
|
|
48
44
|
/**
|
|
49
45
|
* Converts Windows specific file paths to posix
|
|
50
46
|
* @param windowsPath
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { MultiNestCompilerPlugins } from '../plugins/plugins-loader';
|
|
2
|
-
import webpack
|
|
3
|
-
export declare const webpackDefaultsFactory: (sourceRoot: string, relativeSourceRoot: string, entryFilename: string, isDebugEnabled: boolean | undefined, tsConfigFile: string | undefined, plugins: MultiNestCompilerPlugins) => webpack.Configuration;
|
|
1
|
+
import { MultiNestCompilerPlugins } from '../plugins/plugins-loader.js';
|
|
2
|
+
import type webpack from 'webpack';
|
|
3
|
+
export declare const webpackDefaultsFactory: (sourceRoot: string, relativeSourceRoot: string, entryFilename: string, isDebugEnabled: boolean | undefined, tsConfigFile: string | undefined, plugins: MultiNestCompilerPlugins, isEsm?: boolean) => webpack.Configuration;
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { defaultTsconfigFilename } from '../../configuration/defaults.js';
|
|
4
|
+
import { appendTsExtension } from '../helpers/append-extension.js';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
function loadWebpackDeps() {
|
|
7
|
+
try {
|
|
8
|
+
const wp = require('webpack');
|
|
9
|
+
const externals = require('webpack-node-externals');
|
|
10
|
+
const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
|
|
11
|
+
return { webpack: wp, nodeExternals: externals, TsconfigPathsPlugin };
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
const pkg = e?.message?.match?.(/Cannot find.*'([^']+)'/)?.[1] ?? 'webpack';
|
|
15
|
+
throw new Error(`The "${pkg}" package is required when using the webpack compiler but could not be found. ` +
|
|
16
|
+
`Please install it:\n\n npm install --save-dev webpack webpack-node-externals tsconfig-paths-webpack-plugin ts-loader fork-ts-checker-webpack-plugin\n`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaultTsconfigFilename, plugins, isEsm = false) => {
|
|
20
|
+
const { webpack: wp, nodeExternals: externals, TsconfigPathsPlugin } = loadWebpackDeps();
|
|
11
21
|
const isPluginRegistered = isAnyPluginRegistered(plugins);
|
|
12
22
|
const webpackConfiguration = {
|
|
13
|
-
entry:
|
|
23
|
+
entry: appendTsExtension(join(sourceRoot, entryFilename)),
|
|
14
24
|
devtool: isDebugEnabled ? 'inline-source-map' : false,
|
|
15
25
|
target: 'node',
|
|
16
26
|
output: {
|
|
17
|
-
filename:
|
|
27
|
+
filename: join(relativeSourceRoot, `${entryFilename}.js`),
|
|
28
|
+
...(isEsm && {
|
|
29
|
+
module: true,
|
|
30
|
+
library: { type: 'module' },
|
|
31
|
+
chunkFormat: 'module',
|
|
32
|
+
}),
|
|
18
33
|
},
|
|
34
|
+
...(isEsm && {
|
|
35
|
+
experiments: { outputModule: true },
|
|
36
|
+
}),
|
|
19
37
|
ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
|
|
20
|
-
externals: [
|
|
38
|
+
externals: [
|
|
39
|
+
externals(isEsm ? { importType: 'module' } : {}),
|
|
40
|
+
],
|
|
21
41
|
externalsPresets: { node: true },
|
|
22
42
|
module: {
|
|
23
43
|
rules: [
|
|
@@ -44,7 +64,7 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
|
|
|
44
64
|
resolve: {
|
|
45
65
|
extensions: ['.tsx', '.ts', '.js'],
|
|
46
66
|
plugins: [
|
|
47
|
-
new
|
|
67
|
+
new TsconfigPathsPlugin({
|
|
48
68
|
configFile: tsConfigFile,
|
|
49
69
|
}),
|
|
50
70
|
],
|
|
@@ -58,7 +78,7 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
|
|
|
58
78
|
__dirname: false,
|
|
59
79
|
},
|
|
60
80
|
plugins: [
|
|
61
|
-
new
|
|
81
|
+
new wp.IgnorePlugin({
|
|
62
82
|
checkResource(resource) {
|
|
63
83
|
const lazyImports = [
|
|
64
84
|
'@nestjs/microservices',
|
|
@@ -76,7 +96,7 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
|
|
|
76
96
|
paths: [process.cwd()],
|
|
77
97
|
});
|
|
78
98
|
}
|
|
79
|
-
catch
|
|
99
|
+
catch {
|
|
80
100
|
return true;
|
|
81
101
|
}
|
|
82
102
|
return false;
|
|
@@ -85,7 +105,6 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
|
|
|
85
105
|
],
|
|
86
106
|
};
|
|
87
107
|
if (!isPluginRegistered) {
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
89
108
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
90
109
|
webpackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
|
|
91
110
|
typescript: {
|
|
@@ -95,7 +114,6 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
|
|
|
95
114
|
}
|
|
96
115
|
return webpackConfiguration;
|
|
97
116
|
};
|
|
98
|
-
exports.webpackDefaultsFactory = webpackDefaultsFactory;
|
|
99
117
|
function isAnyPluginRegistered(plugins) {
|
|
100
118
|
return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
|
|
101
119
|
(plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
function appendTsExtension(path) {
|
|
6
|
-
return (0, path_1.extname)(path) === '.ts' ? path : path + '.ts';
|
|
1
|
+
import { extname } from 'path';
|
|
2
|
+
export function appendTsExtension(path) {
|
|
3
|
+
return extname(path) === '.ts' ? path : path + '.ts';
|
|
7
4
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyPathResolve = copyPathResolve;
|
|
4
|
-
const path = require("path");
|
|
1
|
+
import * as path from 'path';
|
|
5
2
|
/**
|
|
6
3
|
* Helper function for returning a copy destination filename
|
|
7
4
|
*
|
|
8
5
|
* @description used in `assets-manager.ts` (copy from `copyfiles`)
|
|
9
6
|
* @see https://github.com/calvinmetcalf/copyfiles/blob/master/index.js#L22
|
|
10
7
|
*/
|
|
11
|
-
function copyPathResolve(filePath, outDir, up) {
|
|
8
|
+
export function copyPathResolve(filePath, outDir, up) {
|
|
12
9
|
return path.join(outDir, dealWith(filePath, up));
|
|
13
10
|
}
|
|
14
11
|
function dealWith(inPath, up) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Configuration } from '../../configuration';
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
2
2
|
export declare function deleteOutDirIfEnabled(configuration: Required<Configuration>, appName: string | undefined, dirPath: string): Promise<void>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const get_value_or_default_1 = require("./get-value-or-default");
|
|
6
|
-
async function deleteOutDirIfEnabled(configuration, appName, dirPath) {
|
|
7
|
-
const isDeleteEnabled = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.deleteOutDir', appName);
|
|
1
|
+
import { rm } from 'fs/promises';
|
|
2
|
+
import { getValueOrDefault } from './get-value-or-default.js';
|
|
3
|
+
export async function deleteOutDirIfEnabled(configuration, appName, dirPath) {
|
|
4
|
+
const isDeleteEnabled = getValueOrDefault(configuration, 'compilerOptions.deleteOutDir', appName);
|
|
8
5
|
if (!isDeleteEnabled) {
|
|
9
6
|
return;
|
|
10
7
|
}
|
|
11
|
-
await
|
|
8
|
+
await rm(dirPath, { recursive: true, force: true });
|
|
12
9
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Configuration } from '../../configuration';
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Returns the builder to use for the given application.
|
|
5
4
|
* @param configuration Configuration object.
|
|
@@ -7,15 +6,18 @@ import { Configuration } from '../../configuration';
|
|
|
7
6
|
* @param appName Application name.
|
|
8
7
|
* @returns The builder to use.
|
|
9
8
|
*/
|
|
10
|
-
export declare function getBuilder(configuration: Required<Configuration>, cmdOptions:
|
|
9
|
+
export declare function getBuilder(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): {
|
|
11
10
|
type: "webpack";
|
|
12
|
-
options?: import("../../configuration").WebpackBuilderOptions;
|
|
11
|
+
options?: import("../../configuration/configuration.js").WebpackBuilderOptions;
|
|
12
|
+
} | {
|
|
13
|
+
type: "rspack";
|
|
14
|
+
options?: import("../../configuration/configuration.js").RspackBuilderOptions;
|
|
13
15
|
} | {
|
|
14
16
|
type: "swc";
|
|
15
|
-
options?: import("../../configuration").SwcBuilderOptions;
|
|
17
|
+
options?: import("../../configuration/configuration.js").SwcBuilderOptions;
|
|
16
18
|
} | {
|
|
17
19
|
type: "tsc";
|
|
18
|
-
options?: import("../../configuration").TscBuilderOptions;
|
|
20
|
+
options?: import("../../configuration/configuration.js").TscBuilderOptions;
|
|
19
21
|
} | {
|
|
20
|
-
type: import("../../configuration").BuilderVariant;
|
|
22
|
+
type: import("../../configuration/configuration.js").BuilderVariant;
|
|
21
23
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBuilder = getBuilder;
|
|
4
|
-
const get_value_or_default_1 = require("./get-value-or-default");
|
|
1
|
+
import { getValueOrDefault } from './get-value-or-default.js';
|
|
5
2
|
/**
|
|
6
3
|
* Returns the builder to use for the given application.
|
|
7
4
|
* @param configuration Configuration object.
|
|
@@ -9,8 +6,8 @@ const get_value_or_default_1 = require("./get-value-or-default");
|
|
|
9
6
|
* @param appName Application name.
|
|
10
7
|
* @returns The builder to use.
|
|
11
8
|
*/
|
|
12
|
-
function getBuilder(configuration, cmdOptions, appName) {
|
|
13
|
-
const builderValue =
|
|
9
|
+
export function getBuilder(configuration, cmdOptions, appName) {
|
|
10
|
+
const builderValue = getValueOrDefault(configuration, 'compilerOptions.builder', appName, 'builder', cmdOptions, 'tsc');
|
|
14
11
|
return typeof builderValue === 'string'
|
|
15
12
|
? {
|
|
16
13
|
type: builderValue,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the path to the rspack configuration file to use for the given application.
|
|
4
|
+
* @param configuration Configuration object.
|
|
5
|
+
* @param cmdOptions Command line options.
|
|
6
|
+
* @param appName Application name.
|
|
7
|
+
* @returns The path to the rspack configuration file to use.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getRspackConfigPath(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getValueOrDefault } from './get-value-or-default.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the path to the rspack configuration file to use for the given application.
|
|
4
|
+
* @param configuration Configuration object.
|
|
5
|
+
* @param cmdOptions Command line options.
|
|
6
|
+
* @param appName Application name.
|
|
7
|
+
* @returns The path to the rspack configuration file to use.
|
|
8
|
+
*/
|
|
9
|
+
export function getRspackConfigPath(configuration, cmdOptions, appName) {
|
|
10
|
+
const builder = getValueOrDefault(configuration, 'compilerOptions.builder', appName);
|
|
11
|
+
const rspackPath = typeof builder === 'object' && builder?.type === 'rspack'
|
|
12
|
+
? builder.options?.configPath
|
|
13
|
+
: undefined;
|
|
14
|
+
return rspackPath;
|
|
15
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Configuration } from '../../configuration';
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Returns the path to the tsc configuration file to use for the given application.
|
|
5
4
|
* @param configuration Configuration object.
|
|
@@ -7,4 +6,4 @@ import { Configuration } from '../../configuration';
|
|
|
7
6
|
* @param appName Application name.
|
|
8
7
|
* @returns The path to the tsc configuration file to use.
|
|
9
8
|
*/
|
|
10
|
-
export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions:
|
|
9
|
+
export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getTscConfigPath = getTscConfigPath;
|
|
4
|
-
const get_default_tsconfig_path_1 = require("../../utils/get-default-tsconfig-path");
|
|
5
|
-
const get_value_or_default_1 = require("./get-value-or-default");
|
|
1
|
+
import { getDefaultTsconfigPath } from '../../utils/get-default-tsconfig-path.js';
|
|
2
|
+
import { getValueOrDefault } from './get-value-or-default.js';
|
|
6
3
|
/**
|
|
7
4
|
* Returns the path to the tsc configuration file to use for the given application.
|
|
8
5
|
* @param configuration Configuration object.
|
|
@@ -10,15 +7,15 @@ const get_value_or_default_1 = require("./get-value-or-default");
|
|
|
10
7
|
* @param appName Application name.
|
|
11
8
|
* @returns The path to the tsc configuration file to use.
|
|
12
9
|
*/
|
|
13
|
-
function getTscConfigPath(configuration, cmdOptions, appName) {
|
|
14
|
-
let tsconfigPath =
|
|
10
|
+
export function getTscConfigPath(configuration, cmdOptions, appName) {
|
|
11
|
+
let tsconfigPath = getValueOrDefault(configuration, 'compilerOptions.tsConfigPath', appName, 'path', cmdOptions);
|
|
15
12
|
if (tsconfigPath) {
|
|
16
13
|
return tsconfigPath;
|
|
17
14
|
}
|
|
18
|
-
const builder =
|
|
15
|
+
const builder = getValueOrDefault(configuration, 'compilerOptions.builder', appName);
|
|
19
16
|
tsconfigPath =
|
|
20
17
|
typeof builder === 'object' && builder?.type === 'tsc'
|
|
21
18
|
? builder.options?.configPath
|
|
22
19
|
: undefined;
|
|
23
|
-
return tsconfigPath ??
|
|
20
|
+
return tsconfigPath ?? getDefaultTsconfigPath();
|
|
24
21
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function getValueOrDefault<T = any>(configuration: Required<Configuration>, propertyPath: string, appName: string | undefined, key?: 'path' | 'webpack' | 'webpackPath' | 'entryFile' | 'sourceRoot' | 'exec' | 'builder' | 'typeCheck', options?: Input[], defaultValue?: T): T;
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
2
|
+
export declare function getValueOrDefault<T = any>(configuration: Required<Configuration>, propertyPath: string, appName: string | undefined, key?: 'path' | 'webpack' | 'webpackPath' | 'entryFile' | 'sourceRoot' | 'exec' | 'builder' | 'typeCheck', options?: Record<string, any>, defaultValue?: T): T;
|
|
4
3
|
export declare function getValueOfPath<T = any>(object: Record<string, any>, propertyPath: string): T;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getValueOrDefault = getValueOrDefault;
|
|
4
|
-
exports.getValueOfPath = getValueOfPath;
|
|
5
|
-
function getValueOrDefault(configuration, propertyPath, appName, key, options = [], defaultValue) {
|
|
6
|
-
const item = options.find((option) => option.name === key);
|
|
7
|
-
const origValue = item && item.value;
|
|
1
|
+
export function getValueOrDefault(configuration, propertyPath, appName, key, options = {}, defaultValue) {
|
|
2
|
+
const origValue = key != null ? options[key] : undefined;
|
|
8
3
|
if (origValue !== undefined && origValue !== null) {
|
|
9
4
|
return origValue;
|
|
10
5
|
}
|
|
@@ -23,7 +18,7 @@ function getValueOrDefault(configuration, propertyPath, appName, key, options =
|
|
|
23
18
|
}
|
|
24
19
|
return value;
|
|
25
20
|
}
|
|
26
|
-
function getValueOfPath(object, propertyPath) {
|
|
21
|
+
export function getValueOfPath(object, propertyPath) {
|
|
27
22
|
const fragments = propertyPath.split('.');
|
|
28
23
|
let propertyValue = object;
|
|
29
24
|
let isConcatInProgress = false;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Configuration } from '../../configuration';
|
|
1
|
+
import { Configuration } from '../../configuration/index.js';
|
|
3
2
|
/**
|
|
4
3
|
* Returns the path to the webpack configuration file to use for the given application.
|
|
5
4
|
* @param configuration Configuration object.
|
|
@@ -7,4 +6,4 @@ import { Configuration } from '../../configuration';
|
|
|
7
6
|
* @param appName Application name.
|
|
8
7
|
* @returns The path to the webpack configuration file to use.
|
|
9
8
|
*/
|
|
10
|
-
export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions:
|
|
9
|
+
export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): string | undefined;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWebpackConfigPath = getWebpackConfigPath;
|
|
4
|
-
const get_value_or_default_1 = require("./get-value-or-default");
|
|
1
|
+
import { getValueOrDefault } from './get-value-or-default.js';
|
|
5
2
|
/**
|
|
6
3
|
* Returns the path to the webpack configuration file to use for the given application.
|
|
7
4
|
* @param configuration Configuration object.
|
|
@@ -9,12 +6,12 @@ const get_value_or_default_1 = require("./get-value-or-default");
|
|
|
9
6
|
* @param appName Application name.
|
|
10
7
|
* @returns The path to the webpack configuration file to use.
|
|
11
8
|
*/
|
|
12
|
-
function getWebpackConfigPath(configuration, cmdOptions, appName) {
|
|
13
|
-
let webpackPath =
|
|
9
|
+
export function getWebpackConfigPath(configuration, cmdOptions, appName) {
|
|
10
|
+
let webpackPath = getValueOrDefault(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', cmdOptions);
|
|
14
11
|
if (webpackPath) {
|
|
15
12
|
return webpackPath;
|
|
16
13
|
}
|
|
17
|
-
const builder =
|
|
14
|
+
const builder = getValueOrDefault(configuration, 'compilerOptions.builder', appName);
|
|
18
15
|
webpackPath =
|
|
19
16
|
typeof builder === 'object' && builder?.type === 'webpack'
|
|
20
17
|
? builder.options?.configPath
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.listenForManualRestart = listenForManualRestart;
|
|
4
|
-
exports.displayManualRestartTip = displayManualRestartTip;
|
|
5
|
-
const ansis_1 = require("ansis");
|
|
6
|
-
function listenForManualRestart(callback) {
|
|
1
|
+
import { gray } from 'ansis';
|
|
2
|
+
export function listenForManualRestart(callback) {
|
|
7
3
|
const stdinListener = (data) => {
|
|
8
4
|
if (data.toString().trim() === 'rs') {
|
|
9
5
|
process.stdin.removeListener('data', stdinListener);
|
|
@@ -12,6 +8,6 @@ function listenForManualRestart(callback) {
|
|
|
12
8
|
};
|
|
13
9
|
process.stdin.on('data', stdinListener);
|
|
14
10
|
}
|
|
15
|
-
function displayManualRestartTip() {
|
|
16
|
-
console.log(`To restart at any time, enter ${
|
|
11
|
+
export function displayManualRestartTip() {
|
|
12
|
+
console.log(`To restart at any time, enter ${gray `rs`}.\n`);
|
|
17
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as ts from 'typescript';
|
|
2
|
-
import { TypeScriptBinaryLoader } from '../typescript-loader';
|
|
2
|
+
import { TypeScriptBinaryLoader } from '../typescript-loader.js';
|
|
3
3
|
export declare class TsConfigProvider {
|
|
4
4
|
private readonly typescriptLoader;
|
|
5
5
|
constructor(typescriptLoader: TypeScriptBinaryLoader);
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ui_1 = require("../../ui");
|
|
7
|
-
class TsConfigProvider {
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { CLI_ERRORS } from '../../ui/index.js';
|
|
4
|
+
export class TsConfigProvider {
|
|
5
|
+
typescriptLoader;
|
|
8
6
|
constructor(typescriptLoader) {
|
|
9
7
|
this.typescriptLoader = typescriptLoader;
|
|
10
8
|
}
|
|
11
9
|
getByConfigFilename(configFilename) {
|
|
12
|
-
const configPath =
|
|
13
|
-
if (!
|
|
14
|
-
throw new Error(
|
|
10
|
+
const configPath = join(process.cwd(), configFilename);
|
|
11
|
+
if (!existsSync(configPath)) {
|
|
12
|
+
throw new Error(CLI_ERRORS.MISSING_TYPESCRIPT(configFilename));
|
|
15
13
|
}
|
|
16
14
|
const tsBinary = this.typescriptLoader.load();
|
|
17
15
|
const parsedCmd = tsBinary.getParsedCommandLineOfConfigFile(configPath, undefined, tsBinary.sys);
|
|
@@ -19,4 +17,3 @@ class TsConfigProvider {
|
|
|
19
17
|
return { options, fileNames, projectReferences };
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
exports.TsConfigProvider = TsConfigProvider;
|