@shuvi/service 1.0.20 → 1.0.22

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.
@@ -261,7 +261,7 @@ class WebpackBundler {
261
261
  return issues;
262
262
  });
263
263
  }
264
- compiler.hooks.beforeCompile.tap('beforeCompile', () => {
264
+ compiler.hooks.invalid.tap('invalid', () => {
265
265
  if (this._startTime === null) {
266
266
  this._startTime = performance.now();
267
267
  }
@@ -27,15 +27,14 @@ function createWebpackConfig({ mode, assetPublicPath, paths, config }, _a) {
27
27
  : paths.buildDir;
28
28
  const cacheDir = paths.cacheDir;
29
29
  const publicPath = assetPublicPath;
30
- const env = config.env;
31
30
  const include = [
32
31
  paths.srcDir,
33
32
  paths.appDir,
34
33
  AppSourceRegexp,
35
34
  ...(opts.include || [])
36
35
  ];
37
- const lightningCss = !!config.experimental.lightningCss;
38
- const experimental = config.experimental;
36
+ const { env, analyze, experimental } = config;
37
+ const lightningCss = !!experimental.lightningCss;
39
38
  const jsConfig = (0, typescript_1.getJavaScriptInfo)();
40
39
  const compiler = Object.assign(Object.assign({}, config.compiler), { modularizeImports: experimental.modularizeImports, swcPlugins: experimental.swcPlugins, experimentalDecorators: Boolean((_b = jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.experimentalDecorators), emitDecoratorMetadata: Boolean((_c = jsConfig === null || jsConfig === void 0 ? void 0 : jsConfig.compilerOptions) === null || _c === void 0 ? void 0 : _c.emitDecoratorMetadata) });
41
40
  if (opts.node) {
@@ -50,7 +49,8 @@ function createWebpackConfig({ mode, assetPublicPath, paths, config }, _a) {
50
49
  compiler,
51
50
  jsConfig,
52
51
  include,
53
- env
52
+ env,
53
+ analyze
54
54
  });
55
55
  }
56
56
  else {
@@ -66,7 +66,7 @@ function createWebpackConfig({ mode, assetPublicPath, paths, config }, _a) {
66
66
  jsConfig,
67
67
  include,
68
68
  env,
69
- analyze: config.analyze
69
+ analyze
70
70
  });
71
71
  }
72
72
  chain.name(opts.name);
@@ -1,7 +1,12 @@
1
1
  import { ShuviConfig } from '../core';
2
2
  export interface LoadConfigOptions {
3
3
  rootDir?: string;
4
- filepath?: string;
4
+ filepath?: string | false;
5
5
  forceReloadEnv?: boolean;
6
6
  }
7
+ /**
8
+ * when filePath is false, do not read config file
9
+ * when filePath is '' or undefined, read default config file (shuvi.config.*)
10
+ * when filePath is non-null string, read from filePath
11
+ */
7
12
  export declare function loadConfig({ rootDir, filepath, forceReloadEnv }?: LoadConfigOptions): Promise<ShuviConfig>;
@@ -21,12 +21,20 @@ const logger_1 = __importDefault(require("@shuvi/utils/logger"));
21
21
  const constants_1 = require("../constants");
22
22
  const env_1 = require("./env");
23
23
  const validExts = ['.ts', '.tsx', '.js', '.jsx', '.cjs', '.mjs'];
24
+ /**
25
+ * when filePath is false, do not read config file
26
+ * when filePath is '' or undefined, read default config file (shuvi.config.*)
27
+ * when filePath is non-null string, read from filePath
28
+ */
24
29
  function loadConfig({ rootDir = '.', filepath = '', forceReloadEnv = false } = {}) {
25
30
  return __awaiter(this, void 0, void 0, function* () {
26
31
  rootDir = path_1.default.resolve(rootDir);
27
32
  // read dotenv so we can get env in shuvi.config.js
28
33
  (0, env_1.loadDotenvConfig)({ rootDir, forceReloadEnv });
29
34
  let configFilePath;
35
+ if (filepath === false) {
36
+ return {};
37
+ }
30
38
  if (filepath) {
31
39
  configFilePath = path_1.default.resolve(rootDir, filepath);
32
40
  if (!fs_1.default.existsSync(configFilePath)) {
package/lib/core/api.d.ts CHANGED
@@ -8,7 +8,7 @@ interface IApiOPtions {
8
8
  mode: IServiceMode;
9
9
  phase: IServicePhase;
10
10
  config?: ShuviConfig;
11
- configFile?: string;
11
+ configFile?: string | false;
12
12
  platform?: IPlatform;
13
13
  plugins?: IPluginConfig[];
14
14
  presets?: IPresetConfig[];
package/lib/core/api.js CHANGED
@@ -397,6 +397,7 @@ function getApi(options = {}) {
397
397
  mode,
398
398
  phase,
399
399
  config: options.config,
400
+ configFile: options.configFile,
400
401
  platform: options.platform,
401
402
  presets: options.presets,
402
403
  plugins: options.plugins,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/service",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -29,15 +29,15 @@
29
29
  "@babel/generator": "7.14.5",
30
30
  "@babel/parser": "7.14.7",
31
31
  "@babel/traverse": "7.14.7",
32
- "@shuvi/hook": "1.0.20",
33
- "@shuvi/router": "1.0.20",
34
- "@shuvi/runtime": "1.0.20",
35
- "@shuvi/shared": "1.0.20",
36
- "@shuvi/toolpack": "1.0.20",
37
- "@shuvi/utils": "1.0.20",
38
- "@shuvi/error-overlay": "1.0.20",
39
- "@shuvi/telemetry": "1.0.20",
40
- "@shuvi/trace": "1.0.20",
32
+ "@shuvi/hook": "1.0.22",
33
+ "@shuvi/router": "1.0.22",
34
+ "@shuvi/runtime": "1.0.22",
35
+ "@shuvi/shared": "1.0.22",
36
+ "@shuvi/toolpack": "1.0.22",
37
+ "@shuvi/utils": "1.0.22",
38
+ "@shuvi/error-overlay": "1.0.22",
39
+ "@shuvi/telemetry": "1.0.22",
40
+ "@shuvi/trace": "1.0.22",
41
41
  "commander": "5.1.0",
42
42
  "comment-json": "4.2.2",
43
43
  "cross-spawn": "7.0.3",