@rspack/cli 0.2.8 → 0.2.9-canary-b13dc30-20230725112333

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.
@@ -98,6 +98,8 @@ class BuildCommand {
98
98
  callback(err, Stats);
99
99
  };
100
100
  const compiler = await cli.createCompiler(rspackOptions, "build", errorHandler);
101
+ if (!compiler)
102
+ return;
101
103
  if (cli.isWatch(compiler)) {
102
104
  return;
103
105
  }
@@ -30,6 +30,8 @@ class PreviewCommand {
30
30
  config = config.find(item => item.devServer) || config[0];
31
31
  const devServerOptions = config.devServer;
32
32
  let compiler = (0, core_1.rspack)({ entry: {} });
33
+ if (!compiler)
34
+ return;
33
35
  try {
34
36
  const server = new dev_server_1.RspackDevServer(devServerOptions, compiler);
35
37
  await server.start();
@@ -15,6 +15,8 @@ class ServeCommand {
15
15
  }
16
16
  };
17
17
  const compiler = await cli.createCompiler(rspackOptions, "serve");
18
+ if (!compiler)
19
+ return;
18
20
  const compilers = cli.isMultipleCompiler(compiler)
19
21
  ? compiler.compilers
20
22
  : [compiler];
@@ -7,7 +7,7 @@ export declare class RspackCLI {
7
7
  colors: RspackCLIColors;
8
8
  program: yargs.Argv<{}>;
9
9
  constructor();
10
- createCompiler(options: RspackBuildCLIOptions, rspackCommand: Command, callback?: (e: Error, res?: Stats | MultiStats) => void): Promise<Compiler | MultiCompiler>;
10
+ createCompiler(options: RspackBuildCLIOptions, rspackCommand: Command, callback?: (e: Error, res?: Stats | MultiStats) => void): Promise<MultiCompiler | Compiler | null>;
11
11
  createColors(useColor?: boolean): RspackCLIColors;
12
12
  getLogger(): RspackCLILogger;
13
13
  run(argv: string[]): Promise<void>;
@@ -38,8 +38,7 @@ class RspackCLI {
38
38
  const isWatch = Array.isArray(config)
39
39
  ? config.some(i => i.watch)
40
40
  : config.watch;
41
- const compiler = (0, core_1.rspack)(config, isWatch ? callback : undefined);
42
- return compiler;
41
+ return (0, core_1.rspack)(config, isWatch ? callback : undefined);
43
42
  }
44
43
  createColors(useColor) {
45
44
  const { createColors, isColorSupported } = require("colorette");
@@ -66,6 +65,7 @@ class RspackCLI {
66
65
  };
67
66
  }
68
67
  async run(argv) {
68
+ // @ts-expect-error
69
69
  if (semver_1.default.lt(semver_1.default.clean(process.version), "14.0.0")) {
70
70
  this.getLogger().warn(`Minimum recommended Node.js version is 14.0.0, current version is ${process.version}`);
71
71
  }
@@ -206,12 +206,14 @@ class RspackCLI {
206
206
  }
207
207
  }
208
208
  if (typeof loadedConfig === "function") {
209
+ // @ts-expect-error
209
210
  loadedConfig = loadedConfig((_a = options.argv) === null || _a === void 0 ? void 0 : _a.env, options.argv);
210
211
  // if return promise we should await its result
211
212
  if (typeof loadedConfig.then === "function") {
212
213
  loadedConfig = await loadedConfig;
213
214
  }
214
215
  }
216
+ // @ts-expect-error
215
217
  return loadedConfig;
216
218
  }
217
219
  isMultipleCompiler(compiler) {
package/dist/types.d.ts CHANGED
@@ -37,7 +37,7 @@ export interface RspackPreviewCLIOptions extends RspackCLIOptions {
37
37
  host?: string;
38
38
  open?: boolean;
39
39
  server?: string;
40
- publicPath: string;
40
+ publicPath?: string;
41
41
  }
42
42
  export interface RspackCommand {
43
43
  apply(cli: RspackCLI): Promise<void>;
@@ -41,7 +41,7 @@ export declare const commonOptions: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.
41
41
  };
42
42
  }>>;
43
43
  export declare const previewOptions: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{
44
- dir: string;
44
+ dir: string | undefined;
45
45
  }, "port" | "host" | "open" | "server" | "publicPath" | "config" | "configName"> & yargs.InferredOptionTypes<{
46
46
  publicPath: {
47
47
  type: "string";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/cli",
3
- "version": "0.2.8",
3
+ "version": "0.2.9-canary-b13dc30-20230725112333",
4
4
  "license": "MIT",
5
5
  "description": "CLI for rspack",
6
6
  "bin": {
@@ -36,8 +36,8 @@
36
36
  "semver": "6.3.0",
37
37
  "webpack-bundle-analyzer": "4.6.1",
38
38
  "yargs": "17.6.2",
39
- "@rspack/core": "0.2.8",
40
- "@rspack/dev-server": "0.2.8"
39
+ "@rspack/core": "0.2.9-canary-b13dc30-20230725112333",
40
+ "@rspack/dev-server": "0.2.9-canary-b13dc30-20230725112333"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "rimraf dist/ && tsc -b ./tsconfig.build.json --force",