@shuvi/service 1.0.21 → 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.
@@ -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.21",
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.21",
33
- "@shuvi/router": "1.0.21",
34
- "@shuvi/runtime": "1.0.21",
35
- "@shuvi/shared": "1.0.21",
36
- "@shuvi/toolpack": "1.0.21",
37
- "@shuvi/utils": "1.0.21",
38
- "@shuvi/error-overlay": "1.0.21",
39
- "@shuvi/telemetry": "1.0.21",
40
- "@shuvi/trace": "1.0.21",
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",