@depup/nestjs__cli 11.0.24-depup.7 → 12.0.0-depup.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 (220) hide show
  1. package/README.md +7 -15
  2. package/actions/abstract.action.d.ts +1 -2
  3. package/actions/abstract.action.js +1 -5
  4. package/actions/add.action.d.ts +3 -4
  5. package/actions/add.action.js +44 -53
  6. package/actions/build.action.d.ts +18 -11
  7. package/actions/build.action.js +172 -79
  8. package/actions/deploy.action.d.ts +6 -0
  9. package/actions/deploy.action.js +51 -0
  10. package/actions/generate.action.d.ts +3 -3
  11. package/actions/generate.action.js +61 -59
  12. package/actions/index.d.ts +9 -7
  13. package/actions/index.js +9 -23
  14. package/actions/info.action.d.ts +18 -28
  15. package/actions/info.action.js +80 -60
  16. package/actions/new.action.d.ts +3 -3
  17. package/actions/new.action.js +108 -104
  18. package/actions/start.action.d.ts +4 -7
  19. package/actions/start.action.js +40 -47
  20. package/actions/upgrade.action.d.ts +6 -0
  21. package/actions/upgrade.action.js +53 -0
  22. package/bin/nest.js +11 -10
  23. package/changes.json +9 -41
  24. package/commands/abstract.command.d.ts +3 -3
  25. package/commands/abstract.command.js +2 -5
  26. package/commands/add.command.d.ts +3 -3
  27. package/commands/add.command.js +17 -20
  28. package/commands/build.command.d.ts +3 -3
  29. package/commands/build.command.js +52 -56
  30. package/commands/command.input.js +1 -2
  31. package/commands/command.loader.d.ts +2 -2
  32. package/commands/command.loader.js +29 -22
  33. package/commands/context/add.context.d.ts +7 -0
  34. package/commands/context/add.context.js +1 -0
  35. package/commands/context/build.context.d.ts +17 -0
  36. package/commands/context/build.context.js +1 -0
  37. package/commands/context/deploy.context.d.ts +7 -0
  38. package/commands/context/deploy.context.js +1 -0
  39. package/commands/context/generate.context.d.ts +18 -0
  40. package/commands/context/generate.context.js +1 -0
  41. package/commands/context/index.d.ts +7 -0
  42. package/commands/context/index.js +7 -0
  43. package/commands/context/new.context.d.ts +19 -0
  44. package/commands/context/new.context.js +1 -0
  45. package/commands/context/start.context.d.ts +22 -0
  46. package/commands/context/start.context.js +1 -0
  47. package/commands/context/upgrade.context.d.ts +11 -0
  48. package/commands/context/upgrade.context.js +1 -0
  49. package/commands/deploy.command.d.ts +5 -0
  50. package/commands/deploy.command.js +22 -0
  51. package/commands/generate.command.d.ts +3 -3
  52. package/commands/generate.command.js +35 -66
  53. package/commands/index.d.ts +3 -2
  54. package/commands/index.js +3 -18
  55. package/commands/info.command.d.ts +3 -3
  56. package/commands/info.command.js +4 -8
  57. package/commands/new.command.d.ts +3 -3
  58. package/commands/new.command.js +34 -36
  59. package/commands/start.command.d.ts +3 -3
  60. package/commands/start.command.js +48 -73
  61. package/commands/upgrade.command.d.ts +5 -0
  62. package/commands/upgrade.command.js +32 -0
  63. package/lib/compiler/assets-manager.d.ts +20 -8
  64. package/lib/compiler/assets-manager.js +199 -63
  65. package/lib/compiler/base-compiler.d.ts +5 -5
  66. package/lib/compiler/base-compiler.js +10 -13
  67. package/lib/compiler/compiler.d.ts +6 -6
  68. package/lib/compiler/compiler.js +7 -9
  69. package/lib/compiler/defaults/rspack-defaults.d.ts +3 -0
  70. package/lib/compiler/defaults/rspack-defaults.js +179 -0
  71. package/lib/compiler/defaults/swc-defaults.d.ts +5 -2
  72. package/lib/compiler/defaults/swc-defaults.js +22 -6
  73. package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
  74. package/lib/compiler/defaults/webpack-defaults.js +59 -19
  75. package/lib/compiler/helpers/append-extension.js +3 -6
  76. package/lib/compiler/helpers/copy-path-resolve.js +2 -5
  77. package/lib/compiler/helpers/delete-out-dir.d.ts +1 -1
  78. package/lib/compiler/helpers/delete-out-dir.js +45 -10
  79. package/lib/compiler/helpers/get-builder.d.ts +9 -7
  80. package/lib/compiler/helpers/get-builder.js +3 -6
  81. package/lib/compiler/helpers/get-effective-root-dir.d.ts +16 -0
  82. package/lib/compiler/helpers/get-effective-root-dir.js +56 -0
  83. package/lib/compiler/helpers/get-rspack-config-path.d.ts +10 -0
  84. package/lib/compiler/helpers/get-rspack-config-path.js +19 -0
  85. package/lib/compiler/helpers/get-tsc-config.path.d.ts +2 -3
  86. package/lib/compiler/helpers/get-tsc-config.path.js +6 -9
  87. package/lib/compiler/helpers/get-value-or-default.d.ts +2 -3
  88. package/lib/compiler/helpers/get-value-or-default.js +3 -8
  89. package/lib/compiler/helpers/get-webpack-config-path.d.ts +2 -3
  90. package/lib/compiler/helpers/get-webpack-config-path.js +4 -7
  91. package/lib/compiler/helpers/glob.d.ts +19 -0
  92. package/lib/compiler/helpers/glob.js +185 -0
  93. package/lib/compiler/helpers/manual-restart.js +4 -8
  94. package/lib/compiler/helpers/path-confinement.d.ts +33 -0
  95. package/lib/compiler/helpers/path-confinement.js +63 -0
  96. package/lib/compiler/helpers/tsconfig-provider.d.ts +7 -6
  97. package/lib/compiler/helpers/tsconfig-provider.js +32 -13
  98. package/lib/compiler/hooks/tsconfig-paths.hook.js +13 -13
  99. package/lib/compiler/interfaces/readonly-visitor.interface.js +1 -2
  100. package/lib/compiler/plugins/plugin-metadata-generator.d.ts +37 -1
  101. package/lib/compiler/plugins/plugin-metadata-generator.js +113 -13
  102. package/lib/compiler/plugins/plugin-metadata-printer.d.ts +1 -1
  103. package/lib/compiler/plugins/plugin-metadata-printer.js +5 -9
  104. package/lib/compiler/plugins/plugins-loader.d.ts +2 -2
  105. package/lib/compiler/plugins/plugins-loader.js +12 -12
  106. package/lib/compiler/rspack-compiler.d.ts +21 -0
  107. package/lib/compiler/rspack-compiler.js +111 -0
  108. package/lib/compiler/swc/constants.d.ts +0 -1
  109. package/lib/compiler/swc/constants.js +9 -13
  110. package/lib/compiler/swc/forked-type-checker.js +13 -18
  111. package/lib/compiler/swc/swc-compiler.d.ts +13 -6
  112. package/lib/compiler/swc/swc-compiler.js +116 -70
  113. package/lib/compiler/swc/type-checker-host.js +31 -24
  114. package/lib/compiler/typescript-loader.js +7 -9
  115. package/lib/compiler/watch-compiler.d.ts +5 -5
  116. package/lib/compiler/watch-compiler.js +13 -15
  117. package/lib/compiler/watchers/recursive-directory-watcher.d.ts +37 -0
  118. package/lib/compiler/watchers/recursive-directory-watcher.js +334 -0
  119. package/lib/compiler/webpack-compiler.d.ts +6 -7
  120. package/lib/compiler/webpack-compiler.js +46 -23
  121. package/lib/configuration/configuration.d.ts +16 -3
  122. package/lib/configuration/configuration.js +1 -2
  123. package/lib/configuration/configuration.loader.d.ts +1 -1
  124. package/lib/configuration/configuration.loader.js +1 -2
  125. package/lib/configuration/defaults.d.ts +2 -1
  126. package/lib/configuration/defaults.js +8 -10
  127. package/lib/configuration/index.d.ts +3 -3
  128. package/lib/configuration/index.js +3 -19
  129. package/lib/configuration/nest-configuration.loader.d.ts +3 -3
  130. package/lib/configuration/nest-configuration.loader.js +28 -29
  131. package/lib/package-managers/abstract.package-manager.d.ts +4 -4
  132. package/lib/package-managers/abstract.package-manager.js +21 -32
  133. package/lib/package-managers/bun.package-manager.d.ts +7 -0
  134. package/lib/package-managers/bun.package-manager.js +22 -0
  135. package/lib/package-managers/index.d.ts +9 -8
  136. package/lib/package-managers/index.js +9 -24
  137. package/lib/package-managers/npm.package-manager.d.ts +2 -2
  138. package/lib/package-managers/npm.package-manager.js +6 -10
  139. package/lib/package-managers/package-manager-commands.js +1 -2
  140. package/lib/package-managers/package-manager.d.ts +2 -1
  141. package/lib/package-managers/package-manager.factory.d.ts +2 -2
  142. package/lib/package-managers/package-manager.factory.js +23 -20
  143. package/lib/package-managers/package-manager.js +3 -5
  144. package/lib/package-managers/pnpm.package-manager.d.ts +2 -2
  145. package/lib/package-managers/pnpm.package-manager.js +6 -10
  146. package/lib/package-managers/project.dependency.js +1 -2
  147. package/lib/package-managers/yarn.package-manager.d.ts +2 -2
  148. package/lib/package-managers/yarn.package-manager.js +6 -10
  149. package/lib/questions/questions.d.ts +5 -1
  150. package/lib/questions/questions.js +2 -7
  151. package/lib/readers/file-system.reader.d.ts +1 -1
  152. package/lib/readers/file-system.reader.js +6 -9
  153. package/lib/readers/index.d.ts +2 -2
  154. package/lib/readers/index.js +2 -18
  155. package/lib/readers/reader.js +3 -5
  156. package/lib/runners/abstract.runner.js +40 -21
  157. package/lib/runners/bun.runner.d.ts +4 -0
  158. package/lib/runners/bun.runner.js +6 -0
  159. package/lib/runners/git.runner.d.ts +1 -1
  160. package/lib/runners/git.runner.js +2 -6
  161. package/lib/runners/index.d.ts +3 -3
  162. package/lib/runners/index.js +3 -19
  163. package/lib/runners/mau.runner.d.ts +8 -0
  164. package/lib/runners/mau.runner.js +10 -0
  165. package/lib/runners/npm.runner.d.ts +1 -1
  166. package/lib/runners/npm.runner.js +2 -6
  167. package/lib/runners/pnpm.runner.d.ts +1 -1
  168. package/lib/runners/pnpm.runner.js +2 -6
  169. package/lib/runners/runner.d.ts +2 -1
  170. package/lib/runners/runner.factory.d.ts +7 -6
  171. package/lib/runners/runner.factory.js +18 -20
  172. package/lib/runners/runner.js +3 -5
  173. package/lib/runners/schematic.runner.d.ts +1 -1
  174. package/lib/runners/schematic.runner.js +5 -7
  175. package/lib/runners/yarn.runner.d.ts +1 -1
  176. package/lib/runners/yarn.runner.js +2 -6
  177. package/lib/schematics/abstract.collection.d.ts +3 -3
  178. package/lib/schematics/abstract.collection.js +3 -5
  179. package/lib/schematics/collection.factory.d.ts +2 -2
  180. package/lib/schematics/collection.factory.js +9 -13
  181. package/lib/schematics/collection.js +2 -5
  182. package/lib/schematics/custom.collection.d.ts +2 -2
  183. package/lib/schematics/custom.collection.js +4 -8
  184. package/lib/schematics/index.d.ts +4 -4
  185. package/lib/schematics/index.js +4 -20
  186. package/lib/schematics/nest.collection.d.ts +3 -3
  187. package/lib/schematics/nest.collection.js +113 -109
  188. package/lib/schematics/schematic.option.js +10 -9
  189. package/lib/ui/banner.js +1 -4
  190. package/lib/ui/emojis.d.ts +17 -17
  191. package/lib/ui/emojis.js +19 -22
  192. package/lib/ui/errors.js +1 -4
  193. package/lib/ui/index.d.ts +5 -5
  194. package/lib/ui/index.js +5 -21
  195. package/lib/ui/messages.d.ts +8 -0
  196. package/lib/ui/messages.js +23 -18
  197. package/lib/ui/prefixes.js +3 -6
  198. package/lib/utils/extra-args-warning.js +3 -6
  199. package/lib/utils/formatting.js +1 -4
  200. package/lib/utils/get-default-tsconfig-path.js +4 -7
  201. package/lib/utils/gracefully-exit-on-prompt-error.js +1 -4
  202. package/lib/utils/is-esm-project.d.ts +5 -0
  203. package/lib/utils/is-esm-project.js +16 -0
  204. package/lib/utils/is-interactive.d.ts +8 -0
  205. package/lib/utils/is-interactive.js +10 -0
  206. package/lib/utils/is-module-available.js +3 -4
  207. package/lib/utils/load-configuration.d.ts +1 -1
  208. package/lib/utils/load-configuration.js +4 -7
  209. package/lib/utils/local-binaries.d.ts +2 -2
  210. package/lib/utils/local-binaries.js +8 -11
  211. package/lib/utils/mau.d.ts +14 -0
  212. package/lib/utils/mau.js +46 -0
  213. package/lib/utils/os-info.utils.js +1 -4
  214. package/lib/utils/project-utils.d.ts +1 -3
  215. package/lib/utils/project-utils.js +16 -28
  216. package/lib/utils/remaining-flags.d.ts +2 -2
  217. package/lib/utils/remaining-flags.js +13 -8
  218. package/lib/utils/tree-kill.js +7 -10
  219. package/lib/utils/type-assertions.js +1 -4
  220. package/package.json +70 -83
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PluginMetadataPrinter = void 0;
4
- const fs_1 = require("fs");
5
- const path_1 = require("path");
1
+ import { writeFileSync } from 'fs';
2
+ import { join } from 'path';
6
3
  const SERIALIZED_METADATA_FILENAME = 'metadata.ts';
7
4
  const TYPE_IMPORT_VARIABLE_NAME = 't';
8
5
  /**
9
6
  * Prints the metadata to a file.
10
7
  */
11
- class PluginMetadataPrinter {
8
+ export class PluginMetadataPrinter {
12
9
  print(metadata, typeImports, options, tsBinary) {
13
10
  const objectLiteralExpr = tsBinary.factory.createObjectLiteralExpression(Object.keys(metadata).map((key) => this.recursivelyCreatePropertyAssignment(key, metadata[key], tsBinary)));
14
11
  const exportAssignment = tsBinary.factory.createExportAssignment(undefined, undefined, tsBinary.factory.createArrowFunction([tsBinary.factory.createToken(tsBinary.SyntaxKind.AsyncKeyword)], undefined, [], undefined, tsBinary.factory.createToken(tsBinary.SyntaxKind.EqualsGreaterThanToken), tsBinary.factory.createBlock([
@@ -20,9 +17,9 @@ class PluginMetadataPrinter {
20
17
  });
21
18
  const resultFile = tsBinary.createSourceFile('file.ts', '', tsBinary.ScriptTarget.Latest,
22
19
  /*setParentNodes*/ false, tsBinary.ScriptKind.TS);
23
- const filename = (0, path_1.join)(options.outputDir, options.filename ?? SERIALIZED_METADATA_FILENAME);
20
+ const filename = join(options.outputDir, options.filename ?? SERIALIZED_METADATA_FILENAME);
24
21
  const eslintPrefix = `/* eslint-disable */\n`;
25
- (0, fs_1.writeFileSync)(filename, eslintPrefix +
22
+ writeFileSync(filename, eslintPrefix +
26
23
  printer.printNode(tsBinary.EmitHint.Unspecified, exportAssignment, resultFile));
27
24
  }
28
25
  recursivelyCreatePropertyAssignment(identifier, meta, tsBinary) {
@@ -48,4 +45,3 @@ class PluginMetadataPrinter {
48
45
  return tsBinary.factory.createPropertyAssignment(tsBinary.factory.createComputedPropertyName(tsBinary.factory.createStringLiteral(identifier)), tsBinary.factory.createIdentifier(target));
49
46
  }
50
47
  }
51
- exports.PluginMetadataPrinter = PluginMetadataPrinter;
@@ -1,10 +1,10 @@
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
  type Transformer = ts.TransformerFactory<any> | ts.CustomTransformerFactory;
4
4
  type PluginEntry = string | PluginAndOptions;
5
5
  type PluginOptions = Record<string, any>;
6
6
  interface PluginAndOptions {
7
- name: 'string';
7
+ name: string;
8
8
  options: PluginOptions;
9
9
  }
10
10
  export interface NestCompilerPlugin {
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PluginsLoader = void 0;
4
- const path_1 = require("path");
5
- const ui_1 = require("../../ui");
1
+ import { createRequire } from 'module';
2
+ import { join } from 'path';
3
+ import { CLI_ERRORS } from '../../ui/index.js';
4
+ const require = createRequire(import.meta.url);
6
5
  const PLUGIN_ENTRY_FILENAME = 'plugin';
7
- class PluginsLoader {
6
+ export class PluginsLoader {
8
7
  load(plugins = [], extras = {}) {
9
8
  const pluginNames = plugins.map((entry) => typeof entry === 'object'
10
9
  ? entry.name
@@ -18,7 +17,7 @@ class PluginsLoader {
18
17
  };
19
18
  pluginRefs.forEach((plugin, index) => {
20
19
  if (!plugin.before && !plugin.after && !plugin.afterDeclarations) {
21
- throw new Error(ui_1.CLI_ERRORS.WRONG_PLUGIN(pluginNames[index]));
20
+ throw new Error(CLI_ERRORS.WRONG_PLUGIN(pluginNames[index]));
22
21
  }
23
22
  const options = typeof plugins[index] === 'object'
24
23
  ? plugins[index].options || {}
@@ -46,8 +45,8 @@ class PluginsLoader {
46
45
  }
47
46
  resolvePluginReferences(pluginNames) {
48
47
  const nodeModulePaths = [
49
- (0, path_1.join)(process.cwd(), 'node_modules'),
50
- ...module.paths,
48
+ join(process.cwd(), 'node_modules'),
49
+ ...(require.resolve.paths('typescript') ?? []),
51
50
  ];
52
51
  return pluginNames.map((item) => {
53
52
  try {
@@ -57,14 +56,15 @@ class PluginsLoader {
57
56
  });
58
57
  return require(binaryPath);
59
58
  }
60
- catch { }
59
+ catch {
60
+ // entry-point resolution failed, try bare module resolve
61
+ }
61
62
  const binaryPath = require.resolve(item, { paths: nodeModulePaths });
62
63
  return require(binaryPath);
63
64
  }
64
65
  catch (e) {
65
- throw new Error(`"${item}" plugin is not installed.`);
66
+ throw new Error(`"${item}" plugin is not installed.`, { cause: e });
66
67
  }
67
68
  });
68
69
  }
69
70
  }
70
- exports.PluginsLoader = PluginsLoader;
@@ -0,0 +1,21 @@
1
+ import type * as ts from 'typescript';
2
+ import { Configuration } from '../configuration/index.js';
3
+ import { AssetsManager } from './assets-manager.js';
4
+ import { BaseCompiler } from './base-compiler.js';
5
+ import { PluginsLoader } from './plugins/plugins-loader.js';
6
+ type RspackConfigFactory = (config: Record<string, any>, rspackRef: any) => Record<string, any>;
7
+ type RspackConfigFactoryOrConfig = RspackConfigFactory | Record<string, any>;
8
+ type RspackCompilerExtras = {
9
+ options: Record<string, any>;
10
+ assetsManager: AssetsManager;
11
+ rspackConfigFactoryOrConfig: RspackConfigFactoryOrConfig | RspackConfigFactoryOrConfig[];
12
+ debug?: boolean;
13
+ watchMode?: boolean;
14
+ tsOptions?: ts.CompilerOptions;
15
+ };
16
+ export declare class RspackCompiler extends BaseCompiler<RspackCompilerExtras> {
17
+ constructor(pluginsLoader: PluginsLoader);
18
+ run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras: RspackCompilerExtras, onSuccess?: () => void): void;
19
+ private createAfterCallback;
20
+ }
21
+ export {};
@@ -0,0 +1,111 @@
1
+ import { existsSync } from 'fs';
2
+ import { createRequire } from 'module';
3
+ import { join } from 'path';
4
+ import { ERROR_PREFIX, INFO_PREFIX } from '../ui/index.js';
5
+ import { isEsmProject } from '../utils/is-esm-project.js';
6
+ import { BaseCompiler } from './base-compiler.js';
7
+ import { rspackDefaultsFactory } from './defaults/rspack-defaults.js';
8
+ import { getValueOrDefault } from './helpers/get-value-or-default.js';
9
+ const require = createRequire(import.meta.url);
10
+ export class RspackCompiler extends BaseCompiler {
11
+ constructor(pluginsLoader) {
12
+ super(pluginsLoader);
13
+ }
14
+ run(configuration, tsConfigPath, appName, extras, onSuccess) {
15
+ const cwd = process.cwd();
16
+ const configPath = join(cwd, tsConfigPath);
17
+ if (!existsSync(configPath)) {
18
+ throw new Error(`Could not find TypeScript configuration file "${tsConfigPath}".`);
19
+ }
20
+ const plugins = this.loadPlugins(configuration, tsConfigPath, appName);
21
+ const pathToSource = this.getPathToSource(configuration, tsConfigPath, appName);
22
+ const entryFile = getValueOrDefault(configuration, 'entryFile', appName, 'entryFile', extras.options);
23
+ const entryFileRoot = getValueOrDefault(configuration, 'root', appName) || '';
24
+ const defaultOptions = rspackDefaultsFactory(pathToSource, entryFileRoot, entryFile, extras.debug ?? false, tsConfigPath, plugins, isEsmProject(), extras.tsOptions);
25
+ let rspack;
26
+ try {
27
+ rspack = require('@rspack/core');
28
+ }
29
+ catch {
30
+ throw new Error('@rspack/core is not installed. To use the rspack compiler, install the required packages:\n\n' +
31
+ ' npm install --save-dev @rspack/core webpack-node-externals tsconfig-paths-webpack-plugin\n');
32
+ }
33
+ let compiler;
34
+ let watchOptions;
35
+ let watch;
36
+ if (Array.isArray(extras.rspackConfigFactoryOrConfig)) {
37
+ const rspackConfigurations = extras.rspackConfigFactoryOrConfig.map((configOrFactory) => {
38
+ const unwrappedConfig = typeof configOrFactory !== 'function'
39
+ ? configOrFactory
40
+ : configOrFactory(defaultOptions, rspack);
41
+ return {
42
+ ...defaultOptions,
43
+ mode: extras.watchMode ? 'development' : defaultOptions.mode,
44
+ ...unwrappedConfig,
45
+ };
46
+ });
47
+ compiler = rspack.rspack(rspackConfigurations);
48
+ watchOptions = rspackConfigurations.map((config) => config.watchOptions || {});
49
+ watch = rspackConfigurations.some((config) => config.watch);
50
+ }
51
+ else {
52
+ const projectRspackOptions = typeof extras.rspackConfigFactoryOrConfig !== 'function'
53
+ ? extras.rspackConfigFactoryOrConfig
54
+ : extras.rspackConfigFactoryOrConfig(defaultOptions, rspack);
55
+ const rspackConfiguration = {
56
+ ...defaultOptions,
57
+ mode: extras.watchMode ? 'development' : defaultOptions.mode,
58
+ ...projectRspackOptions,
59
+ };
60
+ compiler = rspack.rspack(rspackConfiguration);
61
+ watchOptions = rspackConfiguration.watchOptions;
62
+ watch = rspackConfiguration.watch;
63
+ }
64
+ const afterCallback = this.createAfterCallback(onSuccess, extras.assetsManager, extras.watchMode ?? false, watch);
65
+ if (extras.watchMode || watch) {
66
+ compiler.hooks.watchRun.tapAsync('Rebuild info', (params, callback) => {
67
+ console.log(`\n${INFO_PREFIX} Rspack is building your sources...\n`);
68
+ callback();
69
+ });
70
+ compiler.watch(watchOptions || {}, afterCallback);
71
+ }
72
+ else {
73
+ compiler.run(afterCallback);
74
+ }
75
+ }
76
+ createAfterCallback(onSuccess, assetsManager, watchMode, watch) {
77
+ return (err, stats) => {
78
+ if (err && stats === undefined) {
79
+ // Could not complete the compilation
80
+ // The error caught is most likely thrown by underlying tasks
81
+ console.log(err);
82
+ return process.exit(1);
83
+ }
84
+ const statsOutput = stats.toString({
85
+ chunks: false,
86
+ colors: true,
87
+ modules: false,
88
+ assets: false,
89
+ });
90
+ if (!err && !stats.hasErrors()) {
91
+ if (!onSuccess) {
92
+ // rspack ignores whatever this callback returns, so the close is
93
+ // handled here rather than awaited — but its rejection still has to
94
+ // be caught or it terminates the CLI after a successful compile.
95
+ assetsManager.closeWatchers().catch((error) => {
96
+ console.error(`${ERROR_PREFIX} Failed to close asset watchers. ` +
97
+ `${error instanceof Error ? error.message : String(error)}`);
98
+ });
99
+ }
100
+ else {
101
+ onSuccess();
102
+ }
103
+ }
104
+ else if (!watchMode && !watch) {
105
+ console.log(statsOutput);
106
+ return process.exit(1);
107
+ }
108
+ console.log(statsOutput);
109
+ };
110
+ }
111
+ }
@@ -1,5 +1,4 @@
1
1
  export declare const TSC_NO_ERRORS_MESSAGE = "Found 0 errors. Watching for file changes.";
2
- export declare const TSC_COMPILATION_STARTED_MESSAGE = "Starting compilation in watch mode...";
3
2
  export declare const SWC_LOG_PREFIX: string;
4
3
  export declare const TSC_LOG_PREFIX: string;
5
4
  export declare const TSC_LOG_ERROR_PREFIX: string;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FOUND_NO_ISSUES_GENERATING_METADATA = exports.FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED = exports.INITIALIZING_TYPE_CHECKER = exports.TSC_LOG_SUCCESS_PREFIX = exports.TSC_LOG_ERROR_PREFIX = exports.TSC_LOG_PREFIX = exports.SWC_LOG_PREFIX = exports.TSC_COMPILATION_STARTED_MESSAGE = exports.TSC_NO_ERRORS_MESSAGE = void 0;
4
- const ansis_1 = require("ansis");
5
- exports.TSC_NO_ERRORS_MESSAGE = 'Found 0 errors. Watching for file changes.';
6
- exports.TSC_COMPILATION_STARTED_MESSAGE = 'Starting compilation in watch mode...';
7
- exports.SWC_LOG_PREFIX = (0, ansis_1.cyan)('> ') + ansis_1.bgCyan.bold(' SWC ');
8
- exports.TSC_LOG_PREFIX = (0, ansis_1.cyan)('> ') + ansis_1.bgCyan.bold(' TSC ');
9
- exports.TSC_LOG_ERROR_PREFIX = (0, ansis_1.red)('> ') + ansis_1.bgRed.bold(' TSC ');
10
- exports.TSC_LOG_SUCCESS_PREFIX = (0, ansis_1.green)('> ') + ansis_1.bgGreen.bold(' TSC ');
11
- exports.INITIALIZING_TYPE_CHECKER = ansis_1.bgCyan.bold(' TSC ') + (0, ansis_1.cyan)(' Initializing type checker...');
12
- exports.FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED = exports.TSC_LOG_SUCCESS_PREFIX + (0, ansis_1.green)(' Found 0 issues.');
13
- exports.FOUND_NO_ISSUES_GENERATING_METADATA = exports.TSC_LOG_SUCCESS_PREFIX + (0, ansis_1.green)(' Found 0 issues. Generating metadata...');
1
+ import { bgCyan, bgGreen, bgRed, cyan, green, red } from 'ansis';
2
+ export const TSC_NO_ERRORS_MESSAGE = 'Found 0 errors. Watching for file changes.';
3
+ export const SWC_LOG_PREFIX = cyan('> ') + bgCyan.bold(' SWC ');
4
+ export const TSC_LOG_PREFIX = cyan('> ') + bgCyan.bold(' TSC ');
5
+ export const TSC_LOG_ERROR_PREFIX = red('> ') + bgRed.bold(' TSC ');
6
+ export const TSC_LOG_SUCCESS_PREFIX = green('> ') + bgGreen.bold(' TSC ');
7
+ export const INITIALIZING_TYPE_CHECKER = bgCyan.bold(' TSC ') + cyan(' Initializing type checker...');
8
+ export const FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED = TSC_LOG_SUCCESS_PREFIX + green(' Found 0 issues.');
9
+ export const FOUND_NO_ISSUES_GENERATING_METADATA = TSC_LOG_SUCCESS_PREFIX + green(' Found 0 issues. Generating metadata...');
@@ -1,25 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ui_1 = require("../../ui");
4
- const base_compiler_1 = require("../base-compiler");
5
- const plugin_metadata_generator_1 = require("../plugins/plugin-metadata-generator");
6
- const plugins_loader_1 = require("../plugins/plugins-loader");
7
- const constants_1 = require("./constants");
8
- const type_checker_host_1 = require("./type-checker-host");
1
+ import { ERROR_PREFIX } from '../../ui/index.js';
2
+ import { BaseCompiler } from '../base-compiler.js';
3
+ import { PluginMetadataGenerator } from '../plugins/plugin-metadata-generator.js';
4
+ import { PluginsLoader } from '../plugins/plugins-loader.js';
5
+ import { FOUND_NO_ISSUES_GENERATING_METADATA, FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED, } from './constants.js';
6
+ import { TypeCheckerHost } from './type-checker-host.js';
9
7
  const [tsConfigPath, appName, sourceRoot, plugins] = process.argv.slice(2);
10
- class ForkedTypeChecker extends base_compiler_1.BaseCompiler {
11
- constructor() {
12
- super(...arguments);
13
- this.pluginMetadataGenerator = new plugin_metadata_generator_1.PluginMetadataGenerator();
14
- this.typeCheckerHost = new type_checker_host_1.TypeCheckerHost();
15
- }
8
+ class ForkedTypeChecker extends BaseCompiler {
9
+ pluginMetadataGenerator = new PluginMetadataGenerator();
10
+ typeCheckerHost = new TypeCheckerHost();
16
11
  async run(configuration, tsConfigPath, appName, extras) {
17
12
  const { readonlyVisitors } = this.loadPlugins(configuration, tsConfigPath, appName);
18
13
  const outputDir = this.getPathToSource(configuration, tsConfigPath, appName);
19
14
  try {
20
15
  const onTypeCheckOrProgramInit = (program) => {
21
16
  if (readonlyVisitors.length > 0) {
22
- console.log(constants_1.FOUND_NO_ISSUES_GENERATING_METADATA);
17
+ console.log(FOUND_NO_ISSUES_GENERATING_METADATA);
23
18
  this.pluginMetadataGenerator.generate({
24
19
  outputDir,
25
20
  visitors: readonlyVisitors,
@@ -27,7 +22,7 @@ class ForkedTypeChecker extends base_compiler_1.BaseCompiler {
27
22
  });
28
23
  }
29
24
  else {
30
- console.log(constants_1.FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED);
25
+ console.log(FOUND_NO_ISSUES_METADATA_GENERATION_SKIPPED);
31
26
  }
32
27
  };
33
28
  this.typeCheckerHost.run(tsConfigPath, {
@@ -37,11 +32,11 @@ class ForkedTypeChecker extends base_compiler_1.BaseCompiler {
37
32
  });
38
33
  }
39
34
  catch (err) {
40
- console.error(ui_1.ERROR_PREFIX, err.message);
35
+ console.error(ERROR_PREFIX, err.message);
41
36
  }
42
37
  }
43
38
  }
44
- const pluginsLoader = new plugins_loader_1.PluginsLoader();
39
+ const pluginsLoader = new PluginsLoader();
45
40
  const forkedTypeChecker = new ForkedTypeChecker(pluginsLoader);
46
41
  const applicationName = appName === 'undefined' ? '' : appName;
47
42
  const options = {
@@ -1,25 +1,32 @@
1
- import * as ts from 'typescript';
2
- import { Configuration } from '../../configuration';
3
- import { AssetsManager } from '../assets-manager';
4
- import { BaseCompiler } from '../base-compiler';
5
- import { PluginsLoader } from '../plugins/plugins-loader';
1
+ import { Configuration } from '../../configuration/index.js';
2
+ import { AssetsManager } from '../assets-manager.js';
3
+ import { BaseCompiler } from '../base-compiler.js';
4
+ import type { TsConfigProviderOutput } from '../helpers/tsconfig-provider.js';
5
+ import { PluginsLoader } from '../plugins/plugins-loader.js';
6
6
  export type SwcCompilerExtras = {
7
7
  watch: boolean;
8
8
  typeCheck: boolean;
9
+ emitDeclarations: boolean;
9
10
  assetsManager: AssetsManager;
10
- tsOptions: ts.CompilerOptions;
11
+ tsOptions: TsConfigProviderOutput['options'];
12
+ tsConfigExclude: string[];
13
+ silent?: boolean;
11
14
  };
12
15
  export declare class SwcCompiler extends BaseCompiler {
13
16
  private readonly pluginMetadataGenerator;
14
17
  private readonly typeCheckerHost;
15
18
  constructor(pluginsLoader: PluginsLoader);
16
19
  run(configuration: Required<Configuration>, tsConfigPath: string, appName: string | undefined, extras: SwcCompilerExtras, onSuccess?: () => void): Promise<void>;
20
+ private emitDeclarations;
17
21
  private runTypeChecker;
18
22
  private runSwc;
23
+ private shouldLogSwcStatus;
19
24
  private loadSwcCliBinary;
20
25
  private getSwcRcFileContentIfExists;
21
26
  private deepMerge;
22
27
  private debounce;
23
28
  private watchFilesInSrcDir;
29
+ private isIgnoredBySwc;
30
+ private normalizeSwcIgnorePath;
24
31
  private watchFilesInOutDir;
25
32
  }