umi 4.0.0-rc.1 → 4.0.0-rc.4

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/bin/forkedDev.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('v8-compile-cache');
3
+ // require('v8-compile-cache');
4
4
  require('../dist/cli/forkedDev');
package/bin/umi.js CHANGED
@@ -1,6 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('v8-compile-cache');
3
+ // disable since it's conflicted with typescript cjs + dynamic import
4
+ // require('v8-compile-cache');
5
+
6
+ // patch console for debug
7
+ // ref: https://remysharp.com/2014/05/23/where-is-that-console-log
8
+ if (process.env.DEBUG_CONSOLE) {
9
+ ['log', 'warn', 'error'].forEach((method) => {
10
+ const old = console[method];
11
+ console[method] = function () {
12
+ let stack = new Error().stack.split(/\n/);
13
+ // Chrome includes a single "Error" line, FF doesn't.
14
+ if (stack[0].indexOf('Error') === 0) {
15
+ stack = stack.slice(1);
16
+ }
17
+ const args = [].slice.apply(arguments).concat([stack[1].trim()]);
18
+ return old.apply(console, args);
19
+ };
20
+ });
21
+ }
22
+
4
23
  require('../dist/cli/cli')
5
24
  .run()
6
25
  .catch((e) => {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { IServicePluginAPI, PluginAPI } from '@umijs/core';
2
+ export { run } from './cli/cli';
2
3
  export { defineConfig } from './defineConfig';
3
4
  export * from './service/service';
4
5
  export declare type IApi = PluginAPI & IServicePluginAPI;
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -10,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.defineConfig = void 0;
17
+ exports.defineConfig = exports.run = void 0;
18
+ var cli_1 = require("./cli/cli");
19
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return cli_1.run; } });
14
20
  var defineConfig_1 = require("./defineConfig");
15
21
  Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return defineConfig_1.defineConfig; } });
16
22
  __exportStar(require("./service/service"), exports);
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/dist/test.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ import { Config } from '@umijs/test';
2
+ export * from '@umijs/test';
3
+ export declare function configUmiAlias(config: Config.InitialOptions): Promise<Partial<{
4
+ automock: boolean;
5
+ bail: number | boolean;
6
+ cache: boolean;
7
+ cacheDirectory: string;
8
+ ci: boolean;
9
+ clearMocks: boolean;
10
+ changedFilesWithAncestor: boolean;
11
+ changedSince: string;
12
+ collectCoverage: boolean;
13
+ collectCoverageFrom: string[];
14
+ collectCoverageOnlyFrom: {
15
+ [key: string]: boolean;
16
+ };
17
+ coverageDirectory: string;
18
+ coveragePathIgnorePatterns: string[];
19
+ coverageProvider: "babel" | "v8";
20
+ coverageReporters: Config.CoverageReporters;
21
+ coverageThreshold: {
22
+ [path: string]: Config.CoverageThresholdValue;
23
+ global: Config.CoverageThresholdValue;
24
+ };
25
+ dependencyExtractor: string;
26
+ detectLeaks: boolean;
27
+ detectOpenHandles: boolean;
28
+ displayName: string | Config.DisplayName;
29
+ expand: boolean;
30
+ extensionsToTreatAsEsm: string[];
31
+ extraGlobals: string[];
32
+ filter: string;
33
+ findRelatedTests: boolean;
34
+ forceCoverageMatch: string[];
35
+ forceExit: boolean;
36
+ json: boolean;
37
+ globals: Config.ConfigGlobals;
38
+ globalSetup: string | null | undefined;
39
+ globalTeardown: string | null | undefined;
40
+ haste: Config.HasteConfig;
41
+ injectGlobals: boolean;
42
+ reporters: (string | Config.ReporterConfig)[];
43
+ logHeapUsage: boolean;
44
+ lastCommit: boolean;
45
+ listTests: boolean;
46
+ maxConcurrency: number;
47
+ maxWorkers: string | number;
48
+ moduleDirectories: string[];
49
+ moduleFileExtensions: string[];
50
+ moduleLoader: string;
51
+ moduleNameMapper: {
52
+ [key: string]: string | string[];
53
+ };
54
+ modulePathIgnorePatterns: string[];
55
+ modulePaths: string[];
56
+ name: string;
57
+ noStackTrace: boolean;
58
+ notify: boolean;
59
+ notifyMode: string;
60
+ onlyChanged: boolean;
61
+ onlyFailures: boolean;
62
+ outputFile: string;
63
+ passWithNoTests: boolean;
64
+ preprocessorIgnorePatterns: string[];
65
+ preset: string | null | undefined;
66
+ prettierPath: string | null | undefined;
67
+ projects: (string | Config.InitialProjectOptions)[];
68
+ replname: string | null | undefined;
69
+ resetMocks: boolean;
70
+ resetModules: boolean;
71
+ resolver: string | null | undefined;
72
+ restoreMocks: boolean;
73
+ rootDir: string;
74
+ roots: string[];
75
+ runner: string;
76
+ runTestsByPath: boolean;
77
+ scriptPreprocessor: string;
78
+ setupFiles: string[];
79
+ setupTestFrameworkScriptFile: string;
80
+ setupFilesAfterEnv: string[];
81
+ silent: boolean;
82
+ skipFilter: boolean;
83
+ skipNodeResolution: boolean;
84
+ slowTestThreshold: number;
85
+ snapshotResolver: string;
86
+ snapshotSerializers: string[];
87
+ snapshotFormat: Config.PrettyFormatOptions;
88
+ errorOnDeprecated: boolean;
89
+ testEnvironment: string;
90
+ testEnvironmentOptions: Record<string, unknown>;
91
+ testFailureExitCode: string | number;
92
+ testLocationInResults: boolean;
93
+ testMatch: string[];
94
+ testNamePattern: string;
95
+ testPathDirs: string[];
96
+ testPathIgnorePatterns: string[];
97
+ testRegex: string | string[];
98
+ testResultsProcessor: string;
99
+ testRunner: string;
100
+ testSequencer: string;
101
+ testURL: string;
102
+ testTimeout: number;
103
+ timers: "real" | "fake" | "modern" | "legacy";
104
+ transform: {
105
+ [regex: string]: string | Config.TransformerConfig;
106
+ };
107
+ transformIgnorePatterns: string[];
108
+ watchPathIgnorePatterns: string[];
109
+ unmockedModulePathPatterns: string[];
110
+ updateSnapshot: boolean;
111
+ useStderr: boolean;
112
+ verbose?: boolean | undefined;
113
+ watch: boolean;
114
+ watchAll: boolean;
115
+ watchman: boolean;
116
+ watchPlugins: (string | [string, Record<string, unknown>])[];
117
+ }>>;
package/dist/test.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.configUmiAlias = void 0;
27
+ const fs_1 = require("fs");
28
+ const service_1 = require("./service/service");
29
+ __exportStar(require("@umijs/test"), exports);
30
+ function getAliasPathWithKey(alias, key) {
31
+ const thePath = alias[key];
32
+ if (alias[thePath]) {
33
+ return getAliasPathWithKey(alias, thePath);
34
+ }
35
+ return thePath;
36
+ }
37
+ let service;
38
+ function configUmiAlias(config) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (!service) {
41
+ service = new service_1.Service();
42
+ yield service.run2({
43
+ name: 'setup',
44
+ args: { quiet: true },
45
+ });
46
+ }
47
+ config.moduleNameMapper || (config.moduleNameMapper = {});
48
+ const { alias } = service.config;
49
+ for (const key of Object.keys(alias)) {
50
+ const aliasPath = getAliasPathWithKey(alias, key);
51
+ if ((0, fs_1.existsSync)(aliasPath) && (0, fs_1.statSync)(aliasPath).isDirectory()) {
52
+ config.moduleNameMapper[`^${key}/(.*)$`] = `${aliasPath}/$1`;
53
+ config.moduleNameMapper[`^${key}$`] = aliasPath;
54
+ }
55
+ else {
56
+ config.moduleNameMapper[`^${key}$`] = aliasPath;
57
+ }
58
+ }
59
+ return config;
60
+ });
61
+ }
62
+ exports.configUmiAlias = configUmiAlias;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umi",
3
- "version": "4.0.0-rc.1",
3
+ "version": "4.0.0-rc.4",
4
4
  "description": "umi",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "main": "dist/index.js",
13
- "module": "index.esm.js",
14
13
  "types": "index.d.ts",
15
14
  "bin": {
16
15
  "umi": "bin/umi.js"
@@ -23,7 +22,9 @@
23
22
  "bin",
24
23
  "plugin.js",
25
24
  "plugin-utils.d.ts",
26
- "plugin-utils.js"
25
+ "plugin-utils.js",
26
+ "test.d.ts",
27
+ "test.js"
27
28
  ],
28
29
  "scripts": {
29
30
  "build": "pnpm tsc",
@@ -32,11 +33,11 @@
32
33
  "dev": "pnpm build -- --watch"
33
34
  },
34
35
  "dependencies": {
35
- "@umijs/core": "4.0.0-rc.1",
36
- "@umijs/preset-umi": "4.0.0-rc.1",
37
- "@umijs/renderer-react": "4.0.0-rc.1",
38
- "@umijs/utils": "4.0.0-rc.1",
39
- "v8-compile-cache": "2.3.0"
36
+ "@umijs/core": "4.0.0-rc.4",
37
+ "@umijs/preset-umi": "4.0.0-rc.4",
38
+ "@umijs/renderer-react": "4.0.0-rc.4",
39
+ "@umijs/test": "4.0.0-rc.4",
40
+ "@umijs/utils": "4.0.0-rc.4"
40
41
  },
41
42
  "publishConfig": {
42
43
  "access": "public"
package/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/test';
package/test.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/test');