@nestjs/cli 11.0.16 → 12.0.0-alpha.0

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.
Files changed (182) hide show
  1. package/actions/abstract.action.d.ts +1 -2
  2. package/actions/abstract.action.js +1 -5
  3. package/actions/add.action.d.ts +3 -4
  4. package/actions/add.action.js +38 -52
  5. package/actions/build.action.d.ts +11 -10
  6. package/actions/build.action.js +85 -72
  7. package/actions/generate.action.d.ts +3 -3
  8. package/actions/generate.action.js +56 -59
  9. package/actions/index.d.ts +7 -7
  10. package/actions/index.js +7 -23
  11. package/actions/info.action.d.ts +12 -28
  12. package/actions/info.action.js +47 -55
  13. package/actions/new.action.d.ts +3 -3
  14. package/actions/new.action.js +75 -105
  15. package/actions/start.action.d.ts +4 -7
  16. package/actions/start.action.js +36 -46
  17. package/bin/nest.js +14 -10
  18. package/commands/abstract.command.d.ts +3 -3
  19. package/commands/abstract.command.js +2 -5
  20. package/commands/add.command.d.ts +3 -3
  21. package/commands/add.command.js +13 -20
  22. package/commands/build.command.d.ts +3 -3
  23. package/commands/build.command.js +25 -54
  24. package/commands/command.input.js +1 -2
  25. package/commands/command.loader.d.ts +2 -2
  26. package/commands/command.loader.js +18 -22
  27. package/commands/context/add.context.d.ts +7 -0
  28. package/commands/context/add.context.js +1 -0
  29. package/commands/context/build.context.d.ts +13 -0
  30. package/commands/context/build.context.js +1 -0
  31. package/commands/context/generate.context.d.ts +15 -0
  32. package/commands/context/generate.context.js +1 -0
  33. package/commands/context/index.d.ts +5 -0
  34. package/commands/context/index.js +5 -0
  35. package/commands/context/new.context.d.ts +11 -0
  36. package/commands/context/new.context.js +1 -0
  37. package/commands/context/start.context.d.ts +19 -0
  38. package/commands/context/start.context.js +1 -0
  39. package/commands/generate.command.d.ts +3 -3
  40. package/commands/generate.command.js +26 -54
  41. package/commands/index.d.ts +3 -2
  42. package/commands/index.js +3 -18
  43. package/commands/info.command.d.ts +3 -3
  44. package/commands/info.command.js +2 -6
  45. package/commands/new.command.d.ts +3 -3
  46. package/commands/new.command.js +24 -33
  47. package/commands/start.command.d.ts +3 -3
  48. package/commands/start.command.js +34 -71
  49. package/lib/compiler/assets-manager.d.ts +1 -1
  50. package/lib/compiler/assets-manager.js +27 -33
  51. package/lib/compiler/base-compiler.d.ts +5 -5
  52. package/lib/compiler/base-compiler.js +10 -13
  53. package/lib/compiler/compiler.d.ts +6 -6
  54. package/lib/compiler/compiler.js +7 -9
  55. package/lib/compiler/defaults/rspack-defaults.d.ts +2 -0
  56. package/lib/compiler/defaults/rspack-defaults.js +117 -0
  57. package/lib/compiler/defaults/swc-defaults.d.ts +1 -1
  58. package/lib/compiler/defaults/swc-defaults.js +1 -5
  59. package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
  60. package/lib/compiler/defaults/webpack-defaults.js +13 -16
  61. package/lib/compiler/helpers/append-extension.js +3 -6
  62. package/lib/compiler/helpers/copy-path-resolve.js +2 -5
  63. package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
  64. package/lib/compiler/helpers/delete-out-dir.js +5 -8
  65. package/lib/compiler/helpers/get-builder.d.ts +9 -7
  66. package/lib/compiler/helpers/get-builder.js +3 -6
  67. package/lib/compiler/helpers/get-rspack-config-path.d.ts +9 -0
  68. package/lib/compiler/helpers/get-rspack-config-path.js +15 -0
  69. package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
  70. package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
  71. package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
  72. package/lib/compiler/helpers/get-value-or-default.js +3 -8
  73. package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
  74. package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
  75. package/lib/compiler/helpers/manual-restart.js +4 -8
  76. package/lib/compiler/helpers/tsconfig-provider.d.ts +1 -1
  77. package/lib/compiler/helpers/tsconfig-provider.js +8 -11
  78. package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
  79. package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
  80. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +1 -1
  81. package/lib/compiler/plugins/plugin-metadata-generator.js +10 -13
  82. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
  83. package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
  84. package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
  85. package/lib/compiler/plugins/plugins-loader.js +13 -13
  86. package/lib/compiler/rspack-compiler.d.ts +19 -0
  87. package/lib/compiler/rspack-compiler.js +97 -0
  88. package/lib/compiler/swc/constants.d.ts +0 -1
  89. package/lib/compiler/swc/constants.js +9 -13
  90. package/lib/compiler/swc/forked-type-checker.js +13 -18
  91. package/lib/compiler/swc/swc-compiler.d.ts +4 -4
  92. package/lib/compiler/swc/swc-compiler.js +41 -39
  93. package/lib/compiler/swc/type-checker-host.js +12 -18
  94. package/lib/compiler/typescript-loader.js +5 -7
  95. package/lib/compiler/watch-compiler.d.ts +5 -5
  96. package/lib/compiler/watch-compiler.js +14 -18
  97. package/lib/compiler/webpack-compiler.d.ts +6 -7
  98. package/lib/compiler/webpack-compiler.js +14 -18
  99. package/lib/configuration/configuration.d.ts +9 -4
  100. package/lib/configuration/configuration.js +1 -2
  101. package/lib/configuration/configuration.loader.d.ts +1 -1
  102. package/lib/configuration/configuration.loader.js +1 -2
  103. package/lib/configuration/defaults.d.ts +2 -1
  104. package/lib/configuration/defaults.js +8 -10
  105. package/lib/configuration/index.d.ts +3 -3
  106. package/lib/configuration/index.js +3 -19
  107. package/lib/configuration/nest-configuration.loader.d.ts +3 -3
  108. package/lib/configuration/nest-configuration.loader.js +11 -20
  109. package/lib/package-managers/abstract.package-manager.d.ts +4 -4
  110. package/lib/package-managers/abstract.package-manager.js +19 -30
  111. package/lib/package-managers/index.d.ts +8 -8
  112. package/lib/package-managers/index.js +8 -24
  113. package/lib/package-managers/npm.package-manager.d.ts +2 -2
  114. package/lib/package-managers/npm.package-manager.js +6 -10
  115. package/lib/package-managers/package-manager-commands.js +1 -2
  116. package/lib/package-managers/package-manager.factory.d.ts +2 -2
  117. package/lib/package-managers/package-manager.factory.js +16 -20
  118. package/lib/package-managers/package-manager.js +2 -5
  119. package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
  120. package/lib/package-managers/pnpm.package-manager.js +6 -10
  121. package/lib/package-managers/project.dependency.js +1 -2
  122. package/lib/package-managers/yarn.package-manager.d.ts +2 -2
  123. package/lib/package-managers/yarn.package-manager.js +6 -10
  124. package/lib/questions/questions.d.ts +5 -1
  125. package/lib/questions/questions.js +2 -7
  126. package/lib/readers/file-system.reader.d.ts +1 -1
  127. package/lib/readers/file-system.reader.js +6 -9
  128. package/lib/readers/index.d.ts +2 -2
  129. package/lib/readers/index.js +2 -18
  130. package/lib/readers/reader.js +3 -5
  131. package/lib/runners/abstract.runner.js +10 -12
  132. package/lib/runners/git.runner.d.ts +1 -1
  133. package/lib/runners/git.runner.js +2 -6
  134. package/lib/runners/index.d.ts +3 -3
  135. package/lib/runners/index.js +3 -19
  136. package/lib/runners/npm.runner.d.ts +1 -1
  137. package/lib/runners/npm.runner.js +2 -6
  138. package/lib/runners/pnpm.runner.d.ts +1 -1
  139. package/lib/runners/pnpm.runner.js +2 -6
  140. package/lib/runners/runner.factory.d.ts +6 -6
  141. package/lib/runners/runner.factory.js +15 -20
  142. package/lib/runners/runner.js +2 -5
  143. package/lib/runners/schematic.runner.d.ts +1 -1
  144. package/lib/runners/schematic.runner.js +5 -7
  145. package/lib/runners/yarn.runner.d.ts +1 -1
  146. package/lib/runners/yarn.runner.js +2 -6
  147. package/lib/schematics/abstract.collection.d.ts +3 -3
  148. package/lib/schematics/abstract.collection.js +3 -5
  149. package/lib/schematics/collection.factory.d.ts +2 -2
  150. package/lib/schematics/collection.factory.js +9 -13
  151. package/lib/schematics/collection.js +2 -5
  152. package/lib/schematics/custom.collection.d.ts +2 -2
  153. package/lib/schematics/custom.collection.js +4 -8
  154. package/lib/schematics/index.d.ts +4 -4
  155. package/lib/schematics/index.js +4 -20
  156. package/lib/schematics/nest.collection.d.ts +3 -3
  157. package/lib/schematics/nest.collection.js +104 -108
  158. package/lib/schematics/schematic.option.js +7 -9
  159. package/lib/ui/banner.js +1 -4
  160. package/lib/ui/emojis.d.ts +17 -17
  161. package/lib/ui/emojis.js +19 -22
  162. package/lib/ui/errors.js +1 -5
  163. package/lib/ui/index.d.ts +5 -5
  164. package/lib/ui/index.js +5 -21
  165. package/lib/ui/messages.js +15 -19
  166. package/lib/ui/prefixes.js +3 -6
  167. package/lib/utils/formatting.js +1 -4
  168. package/lib/utils/get-default-tsconfig-path.js +4 -7
  169. package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
  170. package/lib/utils/is-module-available.js +3 -4
  171. package/lib/utils/load-configuration.d.ts +1 -1
  172. package/lib/utils/load-configuration.js +4 -7
  173. package/lib/utils/local-binaries.d.ts +1 -1
  174. package/lib/utils/local-binaries.js +8 -11
  175. package/lib/utils/os-info.utils.js +1 -4
  176. package/lib/utils/project-utils.d.ts +1 -3
  177. package/lib/utils/project-utils.js +16 -28
  178. package/lib/utils/remaining-flags.d.ts +2 -2
  179. package/lib/utils/remaining-flags.js +2 -5
  180. package/lib/utils/tree-kill.js +7 -10
  181. package/lib/utils/type-assertions.js +1 -4
  182. package/package.json +31 -33
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Compiler = void 0;
4
- const ts = require("typescript");
5
- const base_compiler_1 = require("./base-compiler");
6
- const tsconfig_paths_hook_1 = require("./hooks/tsconfig-paths.hook");
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 = (0, tsconfig_paths_hook_1.tsconfigPathsBeforeHookFactory)(options);
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) => Record<string, any>;
@@ -0,0 +1,117 @@
1
+ import { createRequire } from 'module';
2
+ import { join } from 'path';
3
+ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
4
+ import { defaultTsconfigFilename } from '../../configuration/defaults.js';
5
+ import { appendTsExtension } from '../helpers/append-extension.js';
6
+ import nodeExternals from 'webpack-node-externals';
7
+ const require = createRequire(import.meta.url);
8
+ export const rspackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaultTsconfigFilename, plugins) => {
9
+ const isPluginRegistered = isAnyPluginRegistered(plugins);
10
+ const rspackConfiguration = {
11
+ entry: appendTsExtension(join(sourceRoot, entryFilename)),
12
+ devtool: isDebugEnabled ? 'inline-source-map' : false,
13
+ target: 'node',
14
+ output: {
15
+ filename: join(relativeSourceRoot, `${entryFilename}.js`),
16
+ },
17
+ ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
18
+ externals: [nodeExternals()],
19
+ externalsPresets: { node: true },
20
+ module: {
21
+ rules: [
22
+ {
23
+ test: /\.tsx?$/,
24
+ use: [
25
+ {
26
+ loader: 'builtin:swc-loader',
27
+ options: {
28
+ jsc: {
29
+ parser: {
30
+ syntax: 'typescript',
31
+ decorators: true,
32
+ },
33
+ transform: {
34
+ legacyDecorator: true,
35
+ decoratorMetadata: true,
36
+ },
37
+ target: 'es2021',
38
+ },
39
+ sourceMaps: isDebugEnabled,
40
+ },
41
+ },
42
+ ],
43
+ exclude: /node_modules/,
44
+ },
45
+ ],
46
+ },
47
+ resolve: {
48
+ extensions: ['.tsx', '.ts', '.js'],
49
+ tsConfig: tsConfigFile,
50
+ plugins: [
51
+ new TsconfigPathsPlugin({
52
+ configFile: tsConfigFile,
53
+ }),
54
+ ],
55
+ },
56
+ mode: 'none',
57
+ optimization: {
58
+ nodeEnv: false,
59
+ },
60
+ node: {
61
+ __filename: false,
62
+ __dirname: false,
63
+ },
64
+ plugins: [],
65
+ };
66
+ // rspack has built-in IgnorePlugin (compatible with webpack's)
67
+ try {
68
+ const rspack = require('@rspack/core');
69
+ rspackConfiguration.plugins.push(new rspack.IgnorePlugin({
70
+ checkResource(resource) {
71
+ const lazyImports = [
72
+ '@nestjs/microservices',
73
+ '@nestjs/microservices/microservices-module',
74
+ '@nestjs/websockets/socket-module',
75
+ 'class-validator',
76
+ 'class-transformer',
77
+ 'class-transformer/storage',
78
+ ];
79
+ if (!lazyImports.includes(resource)) {
80
+ return false;
81
+ }
82
+ try {
83
+ require.resolve(resource, {
84
+ paths: [process.cwd()],
85
+ });
86
+ }
87
+ catch {
88
+ return true;
89
+ }
90
+ return false;
91
+ },
92
+ }));
93
+ }
94
+ catch {
95
+ // @rspack/core not available, skip IgnorePlugin
96
+ }
97
+ if (!isPluginRegistered) {
98
+ try {
99
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
100
+ rspackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
101
+ typescript: {
102
+ configFile: tsConfigFile,
103
+ },
104
+ }));
105
+ }
106
+ catch {
107
+ // fork-ts-checker-webpack-plugin not available, skip
108
+ }
109
+ }
110
+ return rspackConfiguration;
111
+ };
112
+ function isAnyPluginRegistered(plugins) {
113
+ return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
114
+ (plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
115
+ (plugins.afterDeclarationsHooks &&
116
+ plugins.afterDeclarationsHooks.length > 0));
117
+ }
@@ -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
- "use strict";
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 = require('webpack');
1
+ import { MultiNestCompilerPlugins } from '../plugins/plugins-loader.js';
2
+ import webpack from 'webpack';
3
3
  export declare const webpackDefaultsFactory: (sourceRoot: string, relativeSourceRoot: string, entryFilename: string, isDebugEnabled: boolean | undefined, tsConfigFile: string | undefined, plugins: MultiNestCompilerPlugins) => webpack.Configuration;
@@ -1,20 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.webpackDefaultsFactory = void 0;
4
- const path_1 = require("path");
5
- const tsconfig_paths_webpack_plugin_1 = require("tsconfig-paths-webpack-plugin");
6
- const defaults_1 = require("../../configuration/defaults");
7
- const append_extension_1 = require("../helpers/append-extension");
8
- const webpack = require("webpack");
9
- const nodeExternals = require("webpack-node-externals");
10
- const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaults_1.defaultTsconfigFilename, plugins) => {
1
+ import { createRequire } from 'module';
2
+ import { join } from 'path';
3
+ import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
4
+ import { defaultTsconfigFilename } from '../../configuration/defaults.js';
5
+ import { appendTsExtension } from '../helpers/append-extension.js';
6
+ import webpack from 'webpack';
7
+ import nodeExternals from 'webpack-node-externals';
8
+ const require = createRequire(import.meta.url);
9
+ export const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, isDebugEnabled = false, tsConfigFile = defaultTsconfigFilename, plugins) => {
11
10
  const isPluginRegistered = isAnyPluginRegistered(plugins);
12
11
  const webpackConfiguration = {
13
- entry: (0, append_extension_1.appendTsExtension)((0, path_1.join)(sourceRoot, entryFilename)),
12
+ entry: appendTsExtension(join(sourceRoot, entryFilename)),
14
13
  devtool: isDebugEnabled ? 'inline-source-map' : false,
15
14
  target: 'node',
16
15
  output: {
17
- filename: (0, path_1.join)(relativeSourceRoot, `${entryFilename}.js`),
16
+ filename: join(relativeSourceRoot, `${entryFilename}.js`),
18
17
  },
19
18
  ignoreWarnings: [/^(?!CriticalDependenciesWarning$)/],
20
19
  externals: [nodeExternals()],
@@ -44,7 +43,7 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
44
43
  resolve: {
45
44
  extensions: ['.tsx', '.ts', '.js'],
46
45
  plugins: [
47
- new tsconfig_paths_webpack_plugin_1.TsconfigPathsPlugin({
46
+ new TsconfigPathsPlugin({
48
47
  configFile: tsConfigFile,
49
48
  }),
50
49
  ],
@@ -76,7 +75,7 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
76
75
  paths: [process.cwd()],
77
76
  });
78
77
  }
79
- catch (err) {
78
+ catch {
80
79
  return true;
81
80
  }
82
81
  return false;
@@ -85,7 +84,6 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
85
84
  ],
86
85
  };
87
86
  if (!isPluginRegistered) {
88
- // eslint-disable-next-line @typescript-eslint/no-var-requires
89
87
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
90
88
  webpackConfiguration.plugins.push(new ForkTsCheckerWebpackPlugin({
91
89
  typescript: {
@@ -95,7 +93,6 @@ const webpackDefaultsFactory = (sourceRoot, relativeSourceRoot, entryFilename, i
95
93
  }
96
94
  return webpackConfiguration;
97
95
  };
98
- exports.webpackDefaultsFactory = webpackDefaultsFactory;
99
96
  function isAnyPluginRegistered(plugins) {
100
97
  return ((plugins.afterHooks && plugins.afterHooks.length > 0) ||
101
98
  (plugins.beforeHooks && plugins.beforeHooks.length > 0) ||
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appendTsExtension = appendTsExtension;
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
- "use strict";
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteOutDirIfEnabled = deleteOutDirIfEnabled;
4
- const promises_1 = require("fs/promises");
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 (0, promises_1.rm)(dirPath, { recursive: true, force: true });
8
+ await rm(dirPath, { recursive: true, force: true });
12
9
  }
@@ -1,5 +1,4 @@
1
- import { Input } from '../../../commands';
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: Input[], appName: string | undefined): {
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
- "use strict";
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 = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName, 'builder', cmdOptions, 'tsc');
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 { Input } from '../../../commands';
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: Input[], appName: string | undefined): string;
9
+ export declare function getTscConfigPath(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): string;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.tsConfigPath', appName, 'path', cmdOptions);
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 = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName);
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 ?? (0, get_default_tsconfig_path_1.getDefaultTsconfigPath)();
20
+ return tsconfigPath ?? getDefaultTsconfigPath();
24
21
  }
@@ -1,4 +1,3 @@
1
- import { Input } from '../../../commands';
2
- import { Configuration } from '../../configuration';
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 { Input } from '../../../commands';
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: Input[], appName: string | undefined): string | undefined;
9
+ export declare function getWebpackConfigPath(configuration: Required<Configuration>, cmdOptions: Record<string, any>, appName: string | undefined): string | undefined;
@@ -1,7 +1,4 @@
1
- "use strict";
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 = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.webpackConfigPath', appName, 'webpackPath', cmdOptions);
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 = (0, get_value_or_default_1.getValueOrDefault)(configuration, 'compilerOptions.builder', appName);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 ${(0, ansis_1.gray) `rs`}.\n`);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TsConfigProvider = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
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 = (0, path_1.join)(process.cwd(), configFilename);
13
- if (!(0, fs_1.existsSync)(configPath)) {
14
- throw new Error(ui_1.CLI_ERRORS.MISSING_TYPESCRIPT(configFilename));
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;
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tsconfigPathsBeforeHookFactory = tsconfigPathsBeforeHookFactory;
4
- const os = require("os");
5
- const path_1 = require("path");
6
- const typescript_loader_1 = require("../typescript-loader");
7
- const tsPaths = require("tsconfig-paths");
8
- function tsconfigPathsBeforeHookFactory(compilerOptions) {
9
- const tsBinary = new typescript_loader_1.TypeScriptBinaryLoader().load();
1
+ import { createRequire } from 'module';
2
+ import { dirname, posix } from 'path';
3
+ import * as tsPaths from 'tsconfig-paths';
4
+ import { TypeScriptBinaryLoader } from '../typescript-loader.js';
5
+ const require = createRequire(import.meta.url);
6
+ export function tsconfigPathsBeforeHookFactory(compilerOptions) {
7
+ const tsBinary = new TypeScriptBinaryLoader().load();
10
8
  const { paths = {}, baseUrl = './' } = compilerOptions;
11
9
  const matcher = tsPaths.createMatchPath(baseUrl, paths, ['main']);
12
10
  return (ctx) => {
@@ -57,20 +55,22 @@ function getNotAliasedPath(sf, matcher, text) {
57
55
  if (!result) {
58
56
  return;
59
57
  }
60
- if (os.platform() === 'win32') {
58
+ if (process.platform === 'win32') {
61
59
  result = result.replace(/\\/g, '/');
62
60
  }
63
61
  try {
64
62
  // Installed packages (node modules) should take precedence over root files with the same name.
65
63
  // Ref: https://github.com/nestjs/nest-cli/issues/838
66
64
  const packagePath = require.resolve(text, {
67
- paths: [process.cwd(), ...module.paths],
65
+ paths: [process.cwd(), ...(require.resolve.paths(text) ?? [])],
68
66
  });
69
67
  if (packagePath) {
70
68
  return text;
71
69
  }
72
70
  }
73
- catch { }
74
- const resolvedPath = path_1.posix.relative((0, path_1.dirname)(sf.fileName), result) || './';
71
+ catch {
72
+ // package resolution failed, fall through to relative path
73
+ }
74
+ const resolvedPath = posix.relative(dirname(sf.fileName), result) || './';
75
75
  return resolvedPath[0] === '.' ? resolvedPath : './' + resolvedPath;
76
76
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript';
2
- import { ReadonlyVisitor } from '../interfaces/readonly-visitor.interface';
2
+ import { ReadonlyVisitor } from '../interfaces/readonly-visitor.interface.js';
3
3
  export interface PluginMetadataGenerateOptions {
4
4
  /**
5
5
  * The visitors to use to generate the metadata.