@umijs/bundler-webpack 4.0.0-beta.8 → 4.0.0-canary.20220317.1
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/compiled/autoprefixer/browserslist/index.d.ts +11 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
- package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +36 -2
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +5 -4
- package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/576.index.js +1171 -0
- package/compiled/copy-webpack-plugin/index.js +16 -10
- package/compiled/copy-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
- package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +21 -0
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +48 -0
- package/compiled/fork-ts-checker-webpack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
- package/compiled/http-proxy-middleware/index.js +10 -10
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
- package/compiled/mini-css-extract-plugin/index.js +7970 -7445
- package/compiled/mini-css-extract-plugin/loader.js +179 -54
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +85 -24
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/react-refresh/index.js +3 -3
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
- package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
- package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
- package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
- package/compiled/schema-utils/declarations/validate.d.ts +4 -4
- package/compiled/schema-utils/index.js +8 -2
- package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/style-loader/index.js +1 -1
- package/compiled/terser/index.js +1 -1
- package/compiled/terser-webpack-plugin/index.js +393 -517
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
- package/compiled/terser-webpack-plugin/minify.js +10 -3
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +183 -149
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +10 -15
- package/compiled/terser-webpack-plugin/utils.js +118 -25
- package/compiled/webpack/index.js +11665 -5565
- package/compiled/webpack-dev-middleware/index.js +11 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpack-manifest-plugin/LICENSE +21 -0
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/ws/index.d.ts +1 -2
- package/compiled/ws/index.js +1 -1
- package/dist/build.d.ts +5 -3
- package/dist/build.js +2 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +4 -7
- package/dist/client/client.js +5 -1
- package/dist/config/assetRules.js +6 -2
- package/dist/config/compressPlugin.js +6 -0
- package/dist/config/config.d.ts +7 -2
- package/dist/config/config.js +50 -8
- package/dist/config/cssRules.js +2 -2
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +120 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +75 -0
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +34 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +42 -0
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +33 -25
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +25 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +2 -3
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +12 -11
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/dev.d.ts +4 -3
- package/dist/dev.js +31 -5
- package/dist/index.d.ts +4 -2
- package/dist/index.js +5 -1
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +67 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +79 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
- package/dist/plugins/ProgressPlugin.js +2 -2
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +20 -0
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +17 -9
- package/dist/server/server.js +25 -3
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +13 -16
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +23 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/dist/utils/depMatch.js +1 -1
- package/package.json +64 -63
- package/compiled/@svgr/webpack/.svgo.yml +0 -75
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -343
- package/compiled/@svgr/webpack/package.json +0 -1
- package/compiled/css-loader/LICENSE +0 -20
- package/compiled/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/LICENSE +0 -24
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -338
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
- package/dist/build.d.ts.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/client/client.d.ts.map +0 -1
- package/dist/config/_sampleFeature.d.ts.map +0 -1
- package/dist/config/assetRules.d.ts.map +0 -1
- package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
- package/dist/config/compressPlugin.d.ts.map +0 -1
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/copyPlugin.d.ts.map +0 -1
- package/dist/config/cssRules.d.ts.map +0 -1
- package/dist/config/definePlugin.d.ts.map +0 -1
- package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
- package/dist/config/ignorePlugin.d.ts.map +0 -1
- package/dist/config/javaScriptRules.d.ts.map +0 -1
- package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
- package/dist/config/nodePolyfill.d.ts.map +0 -1
- package/dist/config/progressPlugin.d.ts.map +0 -1
- package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
- package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
- package/dist/config/svgRules.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/dev.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts.map +0 -1
- package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
- package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
- package/dist/requireHook.d.ts.map +0 -1
- package/dist/schema.d.ts.map +0 -1
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/ws.d.ts.map +0 -1
- package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/browsersList.d.ts.map +0 -1
- package/dist/utils/depMatch.d.ts.map +0 -1
- package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
package/dist/config/svgRules.js
CHANGED
|
@@ -13,24 +13,25 @@ exports.addSVGRules = void 0;
|
|
|
13
13
|
function addSVGRules(opts) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
const { config, userConfig } = opts;
|
|
16
|
-
const { svgr, svgo } = userConfig;
|
|
16
|
+
const { svgr, svgo = {} } = userConfig;
|
|
17
17
|
if (svgr) {
|
|
18
|
-
// https://react-svgr.com/docs/webpack/#handle-svg-in-css-sass-or-less
|
|
19
|
-
// https://github.com/gregberge/svgr/issues/551#issuecomment-883073902
|
|
20
|
-
// https://github.com/webpack/webpack/issues/9309
|
|
21
18
|
const svgrRule = config.module.rule('svgr');
|
|
22
19
|
svgrRule
|
|
23
20
|
.test(/\.svg$/)
|
|
24
21
|
.issuer(/\.[jt]sx?$/)
|
|
25
22
|
.type('javascript/auto')
|
|
26
|
-
.use('babel-loader')
|
|
27
|
-
.loader(require.resolve('@umijs/bundler-webpack/compiled/babel-loader'))
|
|
28
|
-
.end()
|
|
29
23
|
.use('svgr-loader')
|
|
30
|
-
.loader(require.resolve('
|
|
31
|
-
.options(Object.assign(Object.assign({ svgoConfig: {
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
.loader(require.resolve('../loader/svgr'))
|
|
25
|
+
.options(Object.assign(Object.assign({ svgoConfig: Object.assign({ plugins: [
|
|
26
|
+
{
|
|
27
|
+
name: 'preset-default',
|
|
28
|
+
params: {
|
|
29
|
+
overrides: {
|
|
30
|
+
removeTitle: false,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
] }, svgo) }, svgr), { svgo: !!svgo }))
|
|
34
35
|
.end()
|
|
35
36
|
.use('url-loader')
|
|
36
37
|
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
|
|
3
|
+
exports.DEFAULT_BROWSER_TARGETS = exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
|
|
4
4
|
exports.DEFAULT_DEVTOOL = 'cheap-module-source-map';
|
|
5
5
|
exports.DEFAULT_OUTPUT_PATH = 'dist';
|
|
6
6
|
exports.MFSU_NAME = 'MFSU';
|
|
@@ -13,3 +13,6 @@ var MESSAGE_TYPE;
|
|
|
13
13
|
MESSAGE_TYPE["stillOk"] = "still-ok";
|
|
14
14
|
MESSAGE_TYPE["invalid"] = "invalid";
|
|
15
15
|
})(MESSAGE_TYPE = exports.MESSAGE_TYPE || (exports.MESSAGE_TYPE = {}));
|
|
16
|
+
exports.DEFAULT_BROWSER_TARGETS = {
|
|
17
|
+
chrome: 80,
|
|
18
|
+
};
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { IOpts as IConfigOpts } from './config/config';
|
|
1
2
|
import { IConfig } from './types';
|
|
2
|
-
|
|
3
|
+
declare type IOpts = {
|
|
3
4
|
afterMiddlewares?: any[];
|
|
4
5
|
beforeMiddlewares?: any[];
|
|
5
6
|
onDevCompileDone?: Function;
|
|
6
7
|
port?: number;
|
|
7
8
|
host?: string;
|
|
9
|
+
babelPreset?: any;
|
|
8
10
|
chainWebpack?: Function;
|
|
9
11
|
modifyWebpackConfig?: Function;
|
|
10
12
|
beforeBabelPlugins?: any[];
|
|
@@ -14,7 +16,6 @@ interface IOpts {
|
|
|
14
16
|
cwd: string;
|
|
15
17
|
config: IConfig;
|
|
16
18
|
entry: Record<string, string>;
|
|
17
|
-
}
|
|
19
|
+
} & Pick<IConfigOpts, 'cache'>;
|
|
18
20
|
export declare function dev(opts: IOpts): Promise<void>;
|
|
19
21
|
export {};
|
|
20
|
-
//# sourceMappingURL=dev.d.ts.map
|
package/dist/dev.js
CHANGED
|
@@ -14,21 +14,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.dev = void 0;
|
|
16
16
|
const mfsu_1 = require("@umijs/mfsu");
|
|
17
|
+
const utils_1 = require("@umijs/utils");
|
|
18
|
+
const path_1 = require("path");
|
|
17
19
|
const webpack_1 = __importDefault(require("../compiled/webpack"));
|
|
18
20
|
const config_1 = require("./config/config");
|
|
19
21
|
const constants_1 = require("./constants");
|
|
20
22
|
const server_1 = require("./server/server");
|
|
21
23
|
const types_1 = require("./types");
|
|
22
24
|
function dev(opts) {
|
|
23
|
-
var _a;
|
|
24
|
-
var
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
26
|
+
var _f;
|
|
25
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
const enableMFSU = opts.config.mfsu !== false;
|
|
27
29
|
let mfsu = null;
|
|
28
30
|
if (enableMFSU) {
|
|
31
|
+
if (opts.config.srcTranspiler === types_1.Transpiler.swc) {
|
|
32
|
+
utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
33
|
+
}
|
|
29
34
|
mfsu = new mfsu_1.MFSU({
|
|
30
35
|
implementor: webpack_1.default,
|
|
31
36
|
buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
|
|
37
|
+
depBuildConfig: {
|
|
38
|
+
extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
|
|
39
|
+
},
|
|
40
|
+
mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
|
|
41
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
42
|
+
tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
|
|
43
|
+
(0, path_1.join)(opts.cwd, 'node_modules/.cache/mfsu'),
|
|
44
|
+
getCacheDependency() {
|
|
45
|
+
var _a;
|
|
46
|
+
return {
|
|
47
|
+
version: require('../package.json').version,
|
|
48
|
+
esbuildMode: !!((_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild),
|
|
49
|
+
};
|
|
50
|
+
},
|
|
32
51
|
});
|
|
33
52
|
}
|
|
34
53
|
const webpackConfig = yield (0, config_1.getConfig)({
|
|
@@ -36,6 +55,7 @@ function dev(opts) {
|
|
|
36
55
|
env: types_1.Env.development,
|
|
37
56
|
entry: opts.entry,
|
|
38
57
|
userConfig: opts.config,
|
|
58
|
+
babelPreset: opts.babelPreset,
|
|
39
59
|
extraBabelPlugins: [
|
|
40
60
|
...(opts.beforeBabelPlugins || []),
|
|
41
61
|
...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getBabelPlugins()) || []),
|
|
@@ -45,10 +65,12 @@ function dev(opts) {
|
|
|
45
65
|
...(opts.beforeBabelPresets || []),
|
|
46
66
|
...(opts.extraBabelPresets || []),
|
|
47
67
|
],
|
|
68
|
+
extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
|
|
48
69
|
chainWebpack: opts.chainWebpack,
|
|
49
70
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
50
71
|
hmr: true,
|
|
51
72
|
analyze: process.env.ANALYZE,
|
|
73
|
+
cache: opts.cache,
|
|
52
74
|
});
|
|
53
75
|
const depConfig = yield (0, config_1.getConfig)({
|
|
54
76
|
cwd: opts.cwd,
|
|
@@ -58,17 +80,21 @@ function dev(opts) {
|
|
|
58
80
|
hash: true,
|
|
59
81
|
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
60
82
|
name: constants_1.MFSU_NAME,
|
|
83
|
+
cache: {
|
|
84
|
+
buildDependencies: (_e = opts.cache) === null || _e === void 0 ? void 0 : _e.buildDependencies,
|
|
85
|
+
cacheDirectory: (0, path_1.join)(opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
|
|
86
|
+
},
|
|
61
87
|
});
|
|
62
|
-
(
|
|
88
|
+
(_f = webpackConfig.resolve).alias || (_f.alias = {});
|
|
63
89
|
// TODO: REMOVE ME
|
|
64
90
|
['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
|
|
65
91
|
// @ts-ignore
|
|
66
92
|
webpackConfig.resolve.alias[dep] = require.resolve(dep);
|
|
67
93
|
});
|
|
68
|
-
mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
|
|
94
|
+
yield (mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
|
|
69
95
|
config: webpackConfig,
|
|
70
96
|
depConfig: depConfig,
|
|
71
|
-
});
|
|
97
|
+
}));
|
|
72
98
|
yield (0, server_1.createServer)({
|
|
73
99
|
webpackConfig,
|
|
74
100
|
userConfig: opts.config,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type webpack from '../compiled/webpack';
|
|
2
|
+
export type { RequestHandler } from '@umijs/bundler-utils/compiled/express';
|
|
3
|
+
export type { Compiler, Stats } from '../compiled/webpack';
|
|
2
4
|
export * from './build';
|
|
3
5
|
export * from './config/config';
|
|
4
6
|
export * from './dev';
|
|
5
7
|
export * from './schema';
|
|
6
|
-
|
|
8
|
+
export { webpack };
|
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.
|
|
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];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
// MIT: https://github.com/gregberge/svgr/blob/main/packages/webpack/src/index.ts
|
|
16
|
+
// TODO: prebuild @svgr/core @svgr/plugin-jsx @svgr/plugin-svgo
|
|
17
|
+
const core_1 = require("@svgr/core");
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const plugin_jsx_1 = __importDefault(require("@svgr/plugin-jsx"));
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const plugin_svgo_1 = __importDefault(require("@svgr/plugin-svgo"));
|
|
22
|
+
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
23
|
+
const path_1 = require("path");
|
|
24
|
+
const util_1 = require("util");
|
|
25
|
+
const tranformSvg = (0, util_1.callbackify)((contents, options, state) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
const jsCode = yield (0, core_1.transform)(contents, options, state);
|
|
27
|
+
const result = yield (0, esbuild_1.transform)(jsCode, {
|
|
28
|
+
loader: 'tsx',
|
|
29
|
+
target: 'es2015',
|
|
30
|
+
});
|
|
31
|
+
if (!(result === null || result === void 0 ? void 0 : result.code)) {
|
|
32
|
+
throw new Error(`Error while transforming using Esbuild`);
|
|
33
|
+
}
|
|
34
|
+
return result.code;
|
|
35
|
+
}));
|
|
36
|
+
function svgrLoader(contents) {
|
|
37
|
+
this.cacheable && this.cacheable();
|
|
38
|
+
const callback = this.async();
|
|
39
|
+
const options = this.getOptions();
|
|
40
|
+
const previousExport = (() => {
|
|
41
|
+
if (contents.startsWith('export '))
|
|
42
|
+
return contents;
|
|
43
|
+
const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
|
|
44
|
+
return exportMatches ? `export default ${exportMatches[1]}` : null;
|
|
45
|
+
})();
|
|
46
|
+
const state = {
|
|
47
|
+
caller: {
|
|
48
|
+
name: 'svgr-loader',
|
|
49
|
+
previousExport,
|
|
50
|
+
defaultPlugins: [plugin_svgo_1.default, plugin_jsx_1.default],
|
|
51
|
+
},
|
|
52
|
+
filePath: (0, path_1.normalize)(this.resourcePath),
|
|
53
|
+
};
|
|
54
|
+
if (!previousExport) {
|
|
55
|
+
tranformSvg(contents, options, state, callback);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.fs.readFile(this.resourcePath, (err, result) => {
|
|
59
|
+
if (err) {
|
|
60
|
+
callback(err);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
tranformSvg(String(result), options, state, callback);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.default = svgrLoader;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const core_1 = require("@swc/core");
|
|
15
|
+
const types_1 = require("../types");
|
|
16
|
+
function getBaseOpts({ filename }) {
|
|
17
|
+
const isTSFile = filename.endsWith('.ts');
|
|
18
|
+
const isTypeScript = isTSFile || filename.endsWith('.tsx');
|
|
19
|
+
const isDev = process.env.NODE_ENV === types_1.Env.development;
|
|
20
|
+
/**
|
|
21
|
+
* Not use swc auto polyfill , depend on `preset-umi/features/polyfill/polyfill` imported polyfill file
|
|
22
|
+
*
|
|
23
|
+
* @issue https://github.com/swc-project/swc/issues/2607
|
|
24
|
+
* https://github.com/swc-project/swc/issues/1604
|
|
25
|
+
*/
|
|
26
|
+
const swcOpts = {
|
|
27
|
+
module: {
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
type: 'es6',
|
|
30
|
+
ignoreDynamic: true,
|
|
31
|
+
},
|
|
32
|
+
jsc: {
|
|
33
|
+
parser: {
|
|
34
|
+
syntax: isTypeScript ? 'typescript' : 'ecmascript',
|
|
35
|
+
[isTypeScript ? 'tsx' : 'jsx']: !isTSFile,
|
|
36
|
+
dynamicImport: isTypeScript,
|
|
37
|
+
},
|
|
38
|
+
target: 'es2015',
|
|
39
|
+
transform: {
|
|
40
|
+
react: {
|
|
41
|
+
runtime: 'automatic',
|
|
42
|
+
pragma: 'React.createElement',
|
|
43
|
+
pragmaFrag: 'React.Fragment',
|
|
44
|
+
throwIfNamespace: true,
|
|
45
|
+
development: isDev,
|
|
46
|
+
useBuiltins: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
return swcOpts;
|
|
52
|
+
}
|
|
53
|
+
function swcLoader(contents) {
|
|
54
|
+
// 启用异步模式
|
|
55
|
+
const callback = this.async();
|
|
56
|
+
const loaderOpts = this.getOptions();
|
|
57
|
+
const { sync = false, parseMap = false } = loaderOpts, otherOpts = __rest(loaderOpts, ["sync", "parseMap"]);
|
|
58
|
+
const filename = this.resourcePath;
|
|
59
|
+
const swcOpts = Object.assign(Object.assign(Object.assign({}, getBaseOpts({
|
|
60
|
+
filename,
|
|
61
|
+
})), { filename, sourceMaps: this.sourceMap, sourceFileName: filename }), otherOpts);
|
|
62
|
+
try {
|
|
63
|
+
if (sync) {
|
|
64
|
+
const output = (0, core_1.transformSync)(contents, swcOpts);
|
|
65
|
+
callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
(0, core_1.transform)(contents, swcOpts).then((output) => {
|
|
69
|
+
callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
|
|
70
|
+
}, (err) => {
|
|
71
|
+
callback(err);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
callback(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.default = swcLoader;
|
|
@@ -38,9 +38,7 @@ class ESBuildCSSMinifyPlugin {
|
|
|
38
38
|
transformAssets(compilation) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
const { options: { devtool }, } = compilation.compiler;
|
|
41
|
-
const sourcemap = this.options.sourcemap === undefined
|
|
42
|
-
? devtool && devtool
|
|
43
|
-
: this.options.sourcemap;
|
|
41
|
+
const sourcemap = this.options.sourcemap === undefined ? !!devtool : this.options.sourcemap;
|
|
44
42
|
const assets = compilation.getAssets().filter((asset) => {
|
|
45
43
|
return !asset.info.minimized && RE_CSS_FILE.test(asset.name);
|
|
46
44
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TransformOptions } from '@parcel/css';
|
|
2
|
+
import type { Compiler } from '../../compiled/webpack/types';
|
|
3
|
+
declare type MinifyPluginOpts = Omit<TransformOptions, 'filename' | 'code' | 'minify'>;
|
|
4
|
+
export declare class ParcelCSSMinifyPlugin {
|
|
5
|
+
private readonly options;
|
|
6
|
+
constructor(opts?: MinifyPluginOpts);
|
|
7
|
+
apply(compiler: Compiler): void;
|
|
8
|
+
private transformAssets;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ParcelCSSMinifyPlugin = void 0;
|
|
13
|
+
const utils_1 = require("@umijs/utils");
|
|
14
|
+
const buffer_1 = require("buffer");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const webpack_sources_1 = require("../../compiled/webpack-sources");
|
|
17
|
+
const pkgPath = (0, path_1.join)(__dirname, '../../package.json');
|
|
18
|
+
const pkg = require(pkgPath);
|
|
19
|
+
const PLUGIN_NAME = 'parcel-css-minify-plugin';
|
|
20
|
+
const CSS_FILE_REG = /\.css(?:\?.*)?$/i;
|
|
21
|
+
class ParcelCSSMinifyPlugin {
|
|
22
|
+
constructor(opts = {}) {
|
|
23
|
+
this.options = opts;
|
|
24
|
+
}
|
|
25
|
+
apply(compiler) {
|
|
26
|
+
const meta = JSON.stringify({
|
|
27
|
+
name: pkg.name,
|
|
28
|
+
version: pkg.version,
|
|
29
|
+
options: this.options,
|
|
30
|
+
});
|
|
31
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
32
|
+
compilation.hooks.chunkHash.tap(PLUGIN_NAME, (_, hash) => hash.update(meta));
|
|
33
|
+
compilation.hooks.processAssets.tapPromise({
|
|
34
|
+
name: PLUGIN_NAME,
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE,
|
|
37
|
+
additionalAssets: true,
|
|
38
|
+
}, () => __awaiter(this, void 0, void 0, function* () { return yield this.transformAssets(compilation); }));
|
|
39
|
+
compilation.hooks.statsPrinter.tap(PLUGIN_NAME, (statsPrinter) => {
|
|
40
|
+
statsPrinter.hooks.print
|
|
41
|
+
.for('asset.info.minimized')
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
.tap(PLUGIN_NAME, (minimized, { green, formatFlag }) => {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
return minimized ? green(formatFlag('minimized')) : undefined;
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
transformAssets(compilation) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const { options: { devtool }, } = compilation.compiler;
|
|
53
|
+
const sourcemap = this.options.sourceMap === undefined
|
|
54
|
+
? (devtool && devtool.includes('source-map'))
|
|
55
|
+
: this.options.sourceMap;
|
|
56
|
+
const assets = compilation.getAssets().filter((asset) => {
|
|
57
|
+
return !asset.info.minimized && CSS_FILE_REG.test(asset.name);
|
|
58
|
+
});
|
|
59
|
+
yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const { source, map } = asset.source.sourceAndMap();
|
|
61
|
+
const sourceAsString = source.toString();
|
|
62
|
+
const code = typeof source === 'string' ? buffer_1.Buffer.from(source) : source;
|
|
63
|
+
const { transform } = (0, utils_1.importLazy)('@parcel/css');
|
|
64
|
+
const result = yield transform(Object.assign({ filename: asset.name, code, minify: true, sourceMap: sourcemap }, this.options));
|
|
65
|
+
const codeString = result.code.toString();
|
|
66
|
+
compilation.updateAsset(asset.name,
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
sourcemap
|
|
69
|
+
? new webpack_sources_1.SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, true)
|
|
70
|
+
: new webpack_sources_1.RawSource(codeString), Object.assign(Object.assign({}, asset.info), { minimized: true }));
|
|
71
|
+
})));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ParcelCSSMinifyPlugin = ParcelCSSMinifyPlugin;
|
|
@@ -13,7 +13,7 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
|
|
|
13
13
|
}
|
|
14
14
|
apply(compiler) {
|
|
15
15
|
compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
|
|
16
|
-
utils_1.logger.wait('
|
|
16
|
+
utils_1.logger.wait('Compiling...');
|
|
17
17
|
});
|
|
18
18
|
compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
|
|
19
19
|
const { errors, warnings } = stats.toJson({
|
|
@@ -33,7 +33,7 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
|
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
const prefix = this.options.name ? `${this.options.name} ` : '';
|
|
36
|
-
utils_1.logger.event(`${prefix}
|
|
36
|
+
utils_1.logger.event(`${prefix}Compiled successfully in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimePublicPathPlugin = void 0;
|
|
4
|
+
const PLUGIN_NAME = 'RuntimePublicPath';
|
|
5
|
+
// ref: https://gist.github.com/ScriptedAlchemy/60d0c49ce049184f6ce3e86ca351fdca
|
|
6
|
+
class RuntimePublicPathPlugin {
|
|
7
|
+
apply(compiler) {
|
|
8
|
+
compiler.hooks.make.tap(PLUGIN_NAME, (compilation) => {
|
|
9
|
+
compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (module) => {
|
|
10
|
+
// The hook to get the public path ('__webpack_require__.p')
|
|
11
|
+
// https://github.com/webpack/webpack/blob/master/lib/runtime/PublicPathRuntimeModule.js
|
|
12
|
+
if (module.constructor.name === 'PublicPathRuntimeModule') {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath;`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.RuntimePublicPathPlugin = RuntimePublicPathPlugin;
|
package/dist/requireHook.js
CHANGED
|
@@ -17,7 +17,7 @@ const hookPropertyMap = new Map([
|
|
|
17
17
|
['webpack/lib/webpack.js', '@umijs/bundler-webpack/compiled/webpack'],
|
|
18
18
|
]);
|
|
19
19
|
deepImports_json_1.default.forEach((item) => {
|
|
20
|
-
const name = item.split('/').
|
|
20
|
+
const name = item.split('/').pop();
|
|
21
21
|
hookPropertyMap.set(item, `@umijs/bundler-webpack/compiled/webpack/${name}`);
|
|
22
22
|
hookPropertyMap.set(`${item}.js`, `@umijs/bundler-webpack/compiled/webpack/${name}`);
|
|
23
23
|
});
|
package/dist/schema.js
CHANGED
|
@@ -24,6 +24,7 @@ function getSchemas() {
|
|
|
24
24
|
return {
|
|
25
25
|
alias: (Joi) => Joi.object(),
|
|
26
26
|
autoCSSModules: (Joi) => Joi.boolean(),
|
|
27
|
+
autoprefixer: (Joi) => Joi.object(),
|
|
27
28
|
chainWebpack: (Joi) => Joi.function(),
|
|
28
29
|
copy: (Joi) => Joi.array().items(Joi.alternatives().try(Joi.object({
|
|
29
30
|
from: Joi.string(),
|
|
@@ -31,42 +32,49 @@ function getSchemas() {
|
|
|
31
32
|
}), Joi.string())),
|
|
32
33
|
cssLoader: (Joi) => Joi.object(),
|
|
33
34
|
cssLoaderModules: (Joi) => Joi.object(),
|
|
34
|
-
cssMinifier: (Joi) => Joi.string().valid(types_1.CSSMinifier.cssnano, types_1.CSSMinifier.esbuild, types_1.CSSMinifier.none),
|
|
35
|
+
cssMinifier: (Joi) => Joi.string().valid(types_1.CSSMinifier.cssnano, types_1.CSSMinifier.esbuild, types_1.CSSMinifier.parcelCSS, types_1.CSSMinifier.none),
|
|
35
36
|
cssMinifierOptions: (Joi) => Joi.object(),
|
|
37
|
+
deadCode: (Joi) => Joi.object(),
|
|
36
38
|
define: (Joi) => Joi.object(),
|
|
37
39
|
depTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
|
|
38
40
|
devtool: (Joi) => Joi.alternatives().try(Joi.string().regex(DEVTOOL_REGEX), Joi.boolean()),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Joi.boolean(),
|
|
42
|
-
Joi.object().pattern(/.+/, [Joi.string(), Joi.boolean()]),
|
|
43
|
-
]), Joi.string(), Joi.func().arity(3), Joi.object().regex()),
|
|
41
|
+
esm: (Joi) => Joi.object(),
|
|
42
|
+
externals: (Joi) => Joi.alternatives().try(Joi.object(), Joi.string(), Joi.func()),
|
|
44
43
|
extraBabelPlugins: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
|
|
45
44
|
extraBabelPresets: (Joi) => Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.alternatives().try(Joi.string(), Joi.object()))),
|
|
46
45
|
extraPostCSSPlugins: (Joi) => Joi.array(),
|
|
47
46
|
fastRefresh: (Joi) => Joi.boolean(),
|
|
47
|
+
forkTSChecker: (Joi) => Joi.object(),
|
|
48
48
|
hash: (Joi) => Joi.boolean(),
|
|
49
49
|
ignoreMomentLocale: (Joi) => Joi.boolean(),
|
|
50
|
+
inlineLimit: (Joi) => Joi.number(),
|
|
50
51
|
jsMinifier: (Joi) => Joi.string().valid(types_1.JSMinifier.esbuild, types_1.JSMinifier.swc, types_1.JSMinifier.terser, types_1.JSMinifier.uglifyJs, types_1.JSMinifier.none),
|
|
51
52
|
jsMinifierOptions: (Joi) => Joi.object(),
|
|
52
53
|
lessLoader: (Joi) => Joi.object(),
|
|
54
|
+
manifest: (Joi) => Joi.object(),
|
|
55
|
+
mdx: (Joi) => Joi.object({
|
|
56
|
+
loader: Joi.string(),
|
|
57
|
+
loaderOptions: Joi.object(),
|
|
58
|
+
}),
|
|
53
59
|
mfsu: (Joi) => Joi.alternatives(Joi.object({
|
|
60
|
+
cacheDirectory: Joi.string(),
|
|
54
61
|
esbuild: Joi.boolean(),
|
|
62
|
+
mfName: Joi.string(),
|
|
55
63
|
}), Joi.boolean()),
|
|
56
64
|
outputPath: (Joi) => Joi.string(),
|
|
57
65
|
postcssLoader: (Joi) => Joi.object(),
|
|
58
66
|
proxy: (Joi) => Joi.object(),
|
|
59
67
|
publicPath: (Joi) => Joi.string(),
|
|
60
68
|
purgeCSS: (Joi) => Joi.object(),
|
|
69
|
+
runtimePublicPath: (Joi) => Joi.object(),
|
|
61
70
|
sassLoader: (Joi) => Joi.object(),
|
|
62
71
|
srcTranspiler: (Joi) => Joi.string().valid(types_1.Transpiler.babel, types_1.Transpiler.esbuild, types_1.Transpiler.swc, types_1.Transpiler.none),
|
|
63
72
|
styleLoader: (Joi) => Joi.object(),
|
|
64
|
-
svgr: (Joi) => Joi.object(),
|
|
65
73
|
svgo: (Joi) => Joi.alternatives().try(Joi.object(), Joi.boolean()),
|
|
74
|
+
svgr: (Joi) => Joi.object(),
|
|
66
75
|
targets: (Joi) => Joi.object(),
|
|
67
|
-
writeToDisk: (Joi) => Joi.boolean(),
|
|
68
|
-
esm: (Joi) => Joi.object(),
|
|
69
76
|
theme: (Joi) => Joi.object(),
|
|
77
|
+
writeToDisk: (Joi) => Joi.boolean(),
|
|
70
78
|
};
|
|
71
79
|
}
|
|
72
80
|
exports.getSchemas = getSchemas;
|
package/dist/server/server.js
CHANGED
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.createServer = void 0;
|
|
16
|
-
const express_1 = __importDefault(require("@umijs/bundler-
|
|
16
|
+
const express_1 = __importDefault(require("@umijs/bundler-utils/compiled/express"));
|
|
17
17
|
const http_proxy_middleware_1 = require("@umijs/bundler-webpack/compiled/http-proxy-middleware");
|
|
18
18
|
const webpack_1 = __importDefault(require("@umijs/bundler-webpack/compiled/webpack"));
|
|
19
19
|
const utils_1 = require("@umijs/utils");
|
|
@@ -27,6 +27,25 @@ function createServer(opts) {
|
|
|
27
27
|
const { webpackConfig, userConfig } = opts;
|
|
28
28
|
const { proxy } = userConfig;
|
|
29
29
|
const app = (0, express_1.default)();
|
|
30
|
+
// basename middleware
|
|
31
|
+
app.use((req, _res, next) => {
|
|
32
|
+
const { url, path } = req;
|
|
33
|
+
const { basename, history } = userConfig;
|
|
34
|
+
if ((history === null || history === void 0 ? void 0 : history.type) === 'browser' &&
|
|
35
|
+
basename !== '/' &&
|
|
36
|
+
url.startsWith(basename)) {
|
|
37
|
+
req.url = url.slice(basename.length);
|
|
38
|
+
req.path = path.slice(basename.length);
|
|
39
|
+
}
|
|
40
|
+
next();
|
|
41
|
+
});
|
|
42
|
+
// cros
|
|
43
|
+
app.use((_req, res, next) => {
|
|
44
|
+
res.header('Access-Control-Allow-Origin', '*');
|
|
45
|
+
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');
|
|
46
|
+
res.header('Access-Control-Allow-Methods', 'GET, HEAD, PUT, POST, PATCH, DELETE, OPTIONS');
|
|
47
|
+
next();
|
|
48
|
+
});
|
|
30
49
|
// compression
|
|
31
50
|
app.use(require('@umijs/bundler-webpack/compiled/compression')());
|
|
32
51
|
// TODO: headers
|
|
@@ -118,7 +137,10 @@ function createServer(opts) {
|
|
|
118
137
|
});
|
|
119
138
|
}
|
|
120
139
|
// after middlewares
|
|
121
|
-
(opts.afterMiddlewares || []).forEach((m) =>
|
|
140
|
+
(opts.afterMiddlewares || []).forEach((m) => {
|
|
141
|
+
// TODO: FIXME
|
|
142
|
+
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
|
143
|
+
});
|
|
122
144
|
// history fallback
|
|
123
145
|
app.use(require('@umijs/bundler-webpack/compiled/connect-history-api-fallback')({
|
|
124
146
|
index: '/',
|
|
@@ -150,7 +172,7 @@ function createServer(opts) {
|
|
|
150
172
|
const port = opts.port || 8000;
|
|
151
173
|
server.listen(port, () => {
|
|
152
174
|
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
153
|
-
utils_1.logger.ready(`App listening at http://${host}:${port}`);
|
|
175
|
+
utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`http://${host}:${port}`)}`);
|
|
154
176
|
});
|
|
155
177
|
return server;
|
|
156
178
|
});
|