@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.
- package/README.md +7 -15
- 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 +44 -53
- package/actions/build.action.d.ts +18 -11
- package/actions/build.action.js +172 -79
- package/actions/deploy.action.d.ts +6 -0
- package/actions/deploy.action.js +51 -0
- package/actions/generate.action.d.ts +3 -3
- package/actions/generate.action.js +61 -59
- package/actions/index.d.ts +9 -7
- package/actions/index.js +9 -23
- package/actions/info.action.d.ts +18 -28
- package/actions/info.action.js +80 -60
- package/actions/new.action.d.ts +3 -3
- package/actions/new.action.js +108 -104
- package/actions/start.action.d.ts +4 -7
- package/actions/start.action.js +40 -47
- package/actions/upgrade.action.d.ts +6 -0
- package/actions/upgrade.action.js +53 -0
- package/bin/nest.js +11 -10
- package/changes.json +9 -41
- 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 +17 -20
- package/commands/build.command.d.ts +3 -3
- package/commands/build.command.js +52 -56
- package/commands/command.input.js +1 -2
- package/commands/command.loader.d.ts +2 -2
- package/commands/command.loader.js +29 -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 +17 -0
- package/commands/context/build.context.js +1 -0
- package/commands/context/deploy.context.d.ts +7 -0
- package/commands/context/deploy.context.js +1 -0
- package/commands/context/generate.context.d.ts +18 -0
- package/commands/context/generate.context.js +1 -0
- package/commands/context/index.d.ts +7 -0
- package/commands/context/index.js +7 -0
- package/commands/context/new.context.d.ts +19 -0
- package/commands/context/new.context.js +1 -0
- package/commands/context/start.context.d.ts +22 -0
- package/commands/context/start.context.js +1 -0
- package/commands/context/upgrade.context.d.ts +11 -0
- package/commands/context/upgrade.context.js +1 -0
- package/commands/deploy.command.d.ts +5 -0
- package/commands/deploy.command.js +22 -0
- package/commands/generate.command.d.ts +3 -3
- package/commands/generate.command.js +35 -66
- 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 +4 -8
- package/commands/new.command.d.ts +3 -3
- package/commands/new.command.js +34 -36
- package/commands/start.command.d.ts +3 -3
- package/commands/start.command.js +48 -73
- package/commands/upgrade.command.d.ts +5 -0
- package/commands/upgrade.command.js +32 -0
- package/lib/compiler/assets-manager.d.ts +20 -8
- package/lib/compiler/assets-manager.js +199 -63
- 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 +3 -0
- package/lib/compiler/defaults/rspack-defaults.js +179 -0
- package/lib/compiler/defaults/swc-defaults.d.ts +5 -2
- package/lib/compiler/defaults/swc-defaults.js +22 -6
- package/lib/compiler/defaults/webpack-defaults.d.ts +2 -2
- package/lib/compiler/defaults/webpack-defaults.js +59 -19
- 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 +45 -10
- package/lib/compiler/helpers/get-builder.d.ts +9 -7
- package/lib/compiler/helpers/get-builder.js +3 -6
- package/lib/compiler/helpers/get-effective-root-dir.d.ts +16 -0
- package/lib/compiler/helpers/get-effective-root-dir.js +56 -0
- package/lib/compiler/helpers/get-rspack-config-path.d.ts +10 -0
- package/lib/compiler/helpers/get-rspack-config-path.js +19 -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/glob.d.ts +19 -0
- package/lib/compiler/helpers/glob.js +185 -0
- package/lib/compiler/helpers/manual-restart.js +4 -8
- package/lib/compiler/helpers/path-confinement.d.ts +33 -0
- package/lib/compiler/helpers/path-confinement.js +63 -0
- package/lib/compiler/helpers/tsconfig-provider.d.ts +7 -6
- package/lib/compiler/helpers/tsconfig-provider.js +32 -13
- 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 +37 -1
- package/lib/compiler/plugins/plugin-metadata-generator.js +113 -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 +12 -12
- package/lib/compiler/rspack-compiler.d.ts +21 -0
- package/lib/compiler/rspack-compiler.js +111 -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 +13 -6
- package/lib/compiler/swc/swc-compiler.js +116 -70
- package/lib/compiler/swc/type-checker-host.js +31 -24
- package/lib/compiler/typescript-loader.js +7 -9
- package/lib/compiler/watch-compiler.d.ts +5 -5
- package/lib/compiler/watch-compiler.js +13 -15
- package/lib/compiler/watchers/recursive-directory-watcher.d.ts +37 -0
- package/lib/compiler/watchers/recursive-directory-watcher.js +334 -0
- package/lib/compiler/webpack-compiler.d.ts +6 -7
- package/lib/compiler/webpack-compiler.js +46 -23
- package/lib/configuration/configuration.d.ts +16 -3
- 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 +28 -29
- package/lib/package-managers/abstract.package-manager.d.ts +4 -4
- package/lib/package-managers/abstract.package-manager.js +21 -32
- package/lib/package-managers/bun.package-manager.d.ts +7 -0
- package/lib/package-managers/bun.package-manager.js +22 -0
- package/lib/package-managers/index.d.ts +9 -8
- package/lib/package-managers/index.js +9 -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.d.ts +2 -1
- package/lib/package-managers/package-manager.factory.d.ts +2 -2
- package/lib/package-managers/package-manager.factory.js +23 -20
- package/lib/package-managers/package-manager.js +3 -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 +40 -21
- package/lib/runners/bun.runner.d.ts +4 -0
- package/lib/runners/bun.runner.js +6 -0
- 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/mau.runner.d.ts +8 -0
- package/lib/runners/mau.runner.js +10 -0
- 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.d.ts +2 -1
- package/lib/runners/runner.factory.d.ts +7 -6
- package/lib/runners/runner.factory.js +18 -20
- package/lib/runners/runner.js +3 -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 +113 -109
- package/lib/schematics/schematic.option.js +10 -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 -4
- package/lib/ui/index.d.ts +5 -5
- package/lib/ui/index.js +5 -21
- package/lib/ui/messages.d.ts +8 -0
- package/lib/ui/messages.js +23 -18
- package/lib/ui/prefixes.js +3 -6
- package/lib/utils/extra-args-warning.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-interactive.d.ts +8 -0
- package/lib/utils/is-interactive.js +10 -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 +2 -2
- package/lib/utils/local-binaries.js +8 -11
- package/lib/utils/mau.d.ts +14 -0
- package/lib/utils/mau.js +46 -0
- 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 +13 -8
- package/lib/utils/tree-kill.js +7 -10
- package/lib/utils/type-assertions.js +1 -4
- package/package.json +70 -83
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 =
|
|
20
|
+
const filename = join(options.outputDir, options.filename ?? SERIALIZED_METADATA_FILENAME);
|
|
24
21
|
const eslintPrefix = `/* eslint-disable */\n`;
|
|
25
|
-
|
|
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:
|
|
7
|
+
name: string;
|
|
8
8
|
options: PluginOptions;
|
|
9
9
|
}
|
|
10
10
|
export interface NestCompilerPlugin {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
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(
|
|
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
|
-
|
|
50
|
-
...
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
35
|
+
console.error(ERROR_PREFIX, err.message);
|
|
41
36
|
}
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
|
-
const pluginsLoader = new
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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:
|
|
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
|
}
|