@umijs/bundler-webpack 4.0.0-beta.7 → 4.0.0-canary.202200505.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/client/client/client.js +65 -37
- package/client/constants.js +9 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +13 -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 +2 -2
- 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 +38 -4
- 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/939.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 +42 -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/LICENSE +21 -0
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- 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/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +13409 -5746
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +11 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
- 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 +6 -3
- package/dist/build.js +48 -56
- package/dist/cli.js +10 -22
- package/dist/client/client.js +57 -51
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -51
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +70 -64
- package/dist/config/config.d.ts +9 -2
- package/dist/config/config.js +184 -144
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +93 -83
- package/dist/config/definePlugin.js +11 -19
- 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 +70 -0
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +23 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +31 -0
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +153 -131
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +17 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +12 -24
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +45 -48
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +10 -1
- package/dist/dev.d.ts +8 -2
- package/dist/dev.js +117 -66
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +58 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +74 -0
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +23 -36
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +73 -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 +23 -11
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +165 -130
- package/dist/server/ws.d.ts +6 -3
- package/dist/server/ws.js +1 -1
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +16 -17
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +24 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/dist/utils/depMatch.js +1 -1
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +68 -67
- 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/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
package/dist/config/svgRules.js
CHANGED
|
@@ -1,56 +1,53 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addSVGRules = void 0;
|
|
13
|
-
function addSVGRules(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
4
|
+
async function addSVGRules(opts) {
|
|
5
|
+
const { config, userConfig } = opts;
|
|
6
|
+
const { svgr, svgo = {} } = userConfig;
|
|
7
|
+
if (svgr) {
|
|
8
|
+
const svgrRule = config.module.rule('svgr');
|
|
9
|
+
svgrRule
|
|
10
|
+
.test(/\.svg$/)
|
|
11
|
+
.issuer(/\.[jt]sx?$/)
|
|
12
|
+
.type('javascript/auto')
|
|
13
|
+
.use('svgr-loader')
|
|
14
|
+
.loader(require.resolve('../loader/svgr'))
|
|
15
|
+
.options({
|
|
16
|
+
svgoConfig: {
|
|
17
|
+
plugins: [
|
|
18
|
+
{
|
|
19
|
+
name: 'preset-default',
|
|
20
|
+
params: {
|
|
21
|
+
overrides: {
|
|
22
|
+
removeTitle: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
...svgo,
|
|
28
|
+
},
|
|
29
|
+
...svgr,
|
|
30
|
+
svgo: !!svgo,
|
|
31
|
+
})
|
|
32
|
+
.end()
|
|
33
|
+
.use('url-loader')
|
|
34
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
|
|
35
|
+
.end();
|
|
36
|
+
}
|
|
37
|
+
if (svgo === false) {
|
|
47
38
|
const svgRule = config.module.rule('svg');
|
|
48
39
|
svgRule
|
|
49
40
|
.test(/\.svg$/)
|
|
50
|
-
.use('
|
|
51
|
-
.loader(require.resolve('@umijs/bundler-webpack/compiled/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
.use('url-loader')
|
|
42
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'));
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const svgRule = config.module.rule('svg');
|
|
46
|
+
svgRule
|
|
47
|
+
.test(/\.svg$/)
|
|
48
|
+
.use('svgo-loader')
|
|
49
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
|
|
50
|
+
.options({ configFile: false, ...svgo })
|
|
51
|
+
.end();
|
|
55
52
|
}
|
|
56
53
|
exports.addSVGRules = addSVGRules;
|
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_ESBUILD_TARGET_KEYS = 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,12 @@ 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
|
+
};
|
|
19
|
+
exports.DEFAULT_ESBUILD_TARGET_KEYS = [
|
|
20
|
+
'chrome',
|
|
21
|
+
'firefox',
|
|
22
|
+
'edge',
|
|
23
|
+
'safari',
|
|
24
|
+
];
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
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;
|
|
7
|
+
onProgress?: Function;
|
|
8
|
+
onMFSUProgress?: Function;
|
|
6
9
|
port?: number;
|
|
7
10
|
host?: string;
|
|
11
|
+
babelPreset?: any;
|
|
8
12
|
chainWebpack?: Function;
|
|
9
13
|
modifyWebpackConfig?: Function;
|
|
10
14
|
beforeBabelPlugins?: any[];
|
|
@@ -12,8 +16,10 @@ interface IOpts {
|
|
|
12
16
|
extraBabelPlugins?: any[];
|
|
13
17
|
extraBabelPresets?: any[];
|
|
14
18
|
cwd: string;
|
|
19
|
+
rootDir?: string;
|
|
15
20
|
config: IConfig;
|
|
16
21
|
entry: Record<string, string>;
|
|
17
|
-
}
|
|
22
|
+
} & Pick<IConfigOpts, 'cache'>;
|
|
23
|
+
export declare function stripUndefined(obj: any): any;
|
|
18
24
|
export declare function dev(opts: IOpts): Promise<void>;
|
|
19
25
|
export {};
|
package/dist/dev.js
CHANGED
|
@@ -1,83 +1,134 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.dev = void 0;
|
|
6
|
+
exports.dev = exports.stripUndefined = void 0;
|
|
16
7
|
const mfsu_1 = require("@umijs/mfsu");
|
|
8
|
+
const utils_1 = require("@umijs/utils");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const path_1 = require("path");
|
|
17
11
|
const webpack_1 = __importDefault(require("../compiled/webpack"));
|
|
18
12
|
const config_1 = require("./config/config");
|
|
19
13
|
const constants_1 = require("./constants");
|
|
20
14
|
const server_1 = require("./server/server");
|
|
21
15
|
const types_1 = require("./types");
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
function stripUndefined(obj) {
|
|
17
|
+
Object.keys(obj).forEach((key) => {
|
|
18
|
+
if (obj[key] === undefined) {
|
|
19
|
+
delete obj[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
exports.stripUndefined = stripUndefined;
|
|
25
|
+
async function dev(opts) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
var _g;
|
|
28
|
+
const enableMFSU = opts.config.mfsu !== false;
|
|
29
|
+
let mfsu = null;
|
|
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
|
+
}
|
|
34
|
+
mfsu = new mfsu_1.MFSU({
|
|
27
35
|
implementor: webpack_1.default,
|
|
28
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.rootDir || opts.cwd, 'node_modules/.cache/mfsu'),
|
|
44
|
+
onMFSUProgress: opts.onMFSUProgress,
|
|
45
|
+
getCacheDependency() {
|
|
46
|
+
return stripUndefined({
|
|
47
|
+
version: require('../package.json').version,
|
|
48
|
+
mfsu: opts.config.mfsu,
|
|
49
|
+
alias: opts.config.alias,
|
|
50
|
+
externals: opts.config.externals,
|
|
51
|
+
theme: opts.config.theme,
|
|
52
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
53
|
+
publicPath: opts.config.publicPath,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
29
56
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
],
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
mfsu.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
}
|
|
58
|
+
const webpackConfig = await (0, config_1.getConfig)({
|
|
59
|
+
cwd: opts.cwd,
|
|
60
|
+
rootDir: opts.rootDir,
|
|
61
|
+
env: types_1.Env.development,
|
|
62
|
+
entry: opts.entry,
|
|
63
|
+
userConfig: opts.config,
|
|
64
|
+
babelPreset: opts.babelPreset,
|
|
65
|
+
extraBabelPlugins: [
|
|
66
|
+
...(opts.beforeBabelPlugins || []),
|
|
67
|
+
...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getBabelPlugins()) || []),
|
|
68
|
+
...(opts.extraBabelPlugins || []),
|
|
69
|
+
],
|
|
70
|
+
extraBabelPresets: [
|
|
71
|
+
...(opts.beforeBabelPresets || []),
|
|
72
|
+
...(opts.extraBabelPresets || []),
|
|
73
|
+
],
|
|
74
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
75
|
+
extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
|
|
76
|
+
chainWebpack: opts.chainWebpack,
|
|
77
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
78
|
+
hmr: true,
|
|
79
|
+
analyze: process.env.ANALYZE,
|
|
80
|
+
cache: opts.cache,
|
|
81
|
+
});
|
|
82
|
+
const depConfig = await (0, config_1.getConfig)({
|
|
83
|
+
cwd: opts.cwd,
|
|
84
|
+
rootDir: opts.rootDir,
|
|
85
|
+
env: types_1.Env.development,
|
|
86
|
+
entry: opts.entry,
|
|
87
|
+
userConfig: opts.config,
|
|
88
|
+
hash: true,
|
|
89
|
+
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
90
|
+
name: constants_1.MFSU_NAME,
|
|
91
|
+
chainWebpack: (_e = opts.config.mfsu) === null || _e === void 0 ? void 0 : _e.chainWebpack,
|
|
92
|
+
cache: {
|
|
93
|
+
buildDependencies: (_f = opts.cache) === null || _f === void 0 ? void 0 : _f.buildDependencies,
|
|
94
|
+
cacheDirectory: (0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
(_g = webpackConfig.resolve).alias || (_g.alias = {});
|
|
98
|
+
// TODO: REMOVE ME
|
|
99
|
+
['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
webpackConfig.resolve.alias[dep] = require.resolve(dep);
|
|
102
|
+
});
|
|
103
|
+
await (mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
|
|
104
|
+
config: webpackConfig,
|
|
105
|
+
depConfig: depConfig,
|
|
106
|
+
}));
|
|
107
|
+
if (mfsu &&
|
|
108
|
+
webpackConfig.cache &&
|
|
109
|
+
typeof webpackConfig.cache === 'object' &&
|
|
110
|
+
webpackConfig.cache.type === 'filesystem') {
|
|
111
|
+
const webpackCachePath = (0, path_1.join)(webpackConfig.cache.cacheDirectory, `default-development`, 'index.pack');
|
|
112
|
+
const mfsuCacheExists = (0, fs_1.existsSync)(mfsu.depInfo.cacheFilePath);
|
|
113
|
+
const webpackCacheExists = (0, fs_1.existsSync)(webpackCachePath);
|
|
114
|
+
if (webpackCacheExists && !mfsuCacheExists) {
|
|
115
|
+
utils_1.logger.warn(`Invalidate webpack cache since mfsu cache is missing`);
|
|
116
|
+
utils_1.rimraf.sync(webpackConfig.cache.cacheDirectory);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
await (0, server_1.createServer)({
|
|
120
|
+
webpackConfig,
|
|
121
|
+
userConfig: opts.config,
|
|
122
|
+
cwd: opts.cwd,
|
|
123
|
+
beforeMiddlewares: [
|
|
124
|
+
...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getMiddlewares()) || []),
|
|
125
|
+
...(opts.beforeMiddlewares || []),
|
|
126
|
+
],
|
|
127
|
+
port: opts.port,
|
|
128
|
+
host: opts.host,
|
|
129
|
+
afterMiddlewares: [...(opts.afterMiddlewares || [])],
|
|
130
|
+
onDevCompileDone: opts.onDevCompileDone,
|
|
131
|
+
onProgress: opts.onProgress,
|
|
81
132
|
});
|
|
82
133
|
}
|
|
83
134
|
exports.dev = dev;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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';
|
|
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,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// MIT: https://github.com/gregberge/svgr/blob/main/packages/webpack/src/index.ts
|
|
7
|
+
// TODO: prebuild @svgr/core @svgr/plugin-jsx @svgr/plugin-svgo
|
|
8
|
+
const core_1 = require("@svgr/core");
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const plugin_jsx_1 = __importDefault(require("@svgr/plugin-jsx"));
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const plugin_svgo_1 = __importDefault(require("@svgr/plugin-svgo"));
|
|
13
|
+
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
14
|
+
const path_1 = require("path");
|
|
15
|
+
const util_1 = require("util");
|
|
16
|
+
const tranformSvg = (0, util_1.callbackify)(async (contents, options, state) => {
|
|
17
|
+
const jsCode = await (0, core_1.transform)(contents, options, state);
|
|
18
|
+
const result = await (0, esbuild_1.transform)(jsCode, {
|
|
19
|
+
loader: 'tsx',
|
|
20
|
+
target: 'es2015',
|
|
21
|
+
});
|
|
22
|
+
if (!(result === null || result === void 0 ? void 0 : result.code)) {
|
|
23
|
+
throw new Error(`Error while transforming using Esbuild`);
|
|
24
|
+
}
|
|
25
|
+
return result.code;
|
|
26
|
+
});
|
|
27
|
+
function svgrLoader(contents) {
|
|
28
|
+
this.cacheable && this.cacheable();
|
|
29
|
+
const callback = this.async();
|
|
30
|
+
const options = this.getOptions();
|
|
31
|
+
const previousExport = (() => {
|
|
32
|
+
if (contents.startsWith('export '))
|
|
33
|
+
return contents;
|
|
34
|
+
const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
|
|
35
|
+
return exportMatches ? `export default ${exportMatches[1]}` : null;
|
|
36
|
+
})();
|
|
37
|
+
const state = {
|
|
38
|
+
caller: {
|
|
39
|
+
name: 'svgr-loader',
|
|
40
|
+
previousExport,
|
|
41
|
+
defaultPlugins: [plugin_svgo_1.default, plugin_jsx_1.default],
|
|
42
|
+
},
|
|
43
|
+
filePath: (0, path_1.normalize)(this.resourcePath),
|
|
44
|
+
};
|
|
45
|
+
if (!previousExport) {
|
|
46
|
+
tranformSvg(contents, options, state, callback);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.fs.readFile(this.resourcePath, (err, result) => {
|
|
50
|
+
if (err) {
|
|
51
|
+
callback(err);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
tranformSvg(String(result), options, state, callback);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = svgrLoader;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@swc/core");
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
function getBaseOpts({ filename }) {
|
|
6
|
+
const isTSFile = filename.endsWith('.ts');
|
|
7
|
+
const isTypeScript = isTSFile || filename.endsWith('.tsx');
|
|
8
|
+
const isDev = process.env.NODE_ENV === types_1.Env.development;
|
|
9
|
+
/**
|
|
10
|
+
* Not use swc auto polyfill , depend on `preset-umi/features/polyfill/polyfill` imported polyfill file
|
|
11
|
+
*
|
|
12
|
+
* @issue https://github.com/swc-project/swc/issues/2607
|
|
13
|
+
* https://github.com/swc-project/swc/issues/1604
|
|
14
|
+
*/
|
|
15
|
+
const swcOpts = {
|
|
16
|
+
module: {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
type: 'es6',
|
|
19
|
+
ignoreDynamic: true,
|
|
20
|
+
},
|
|
21
|
+
jsc: {
|
|
22
|
+
parser: {
|
|
23
|
+
syntax: isTypeScript ? 'typescript' : 'ecmascript',
|
|
24
|
+
[isTypeScript ? 'tsx' : 'jsx']: !isTSFile,
|
|
25
|
+
dynamicImport: isTypeScript,
|
|
26
|
+
},
|
|
27
|
+
target: 'es2015',
|
|
28
|
+
transform: {
|
|
29
|
+
react: {
|
|
30
|
+
runtime: 'automatic',
|
|
31
|
+
pragma: 'React.createElement',
|
|
32
|
+
pragmaFrag: 'React.Fragment',
|
|
33
|
+
throwIfNamespace: true,
|
|
34
|
+
development: isDev,
|
|
35
|
+
useBuiltins: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return swcOpts;
|
|
41
|
+
}
|
|
42
|
+
function swcLoader(contents) {
|
|
43
|
+
// 启用异步模式
|
|
44
|
+
const callback = this.async();
|
|
45
|
+
const loaderOpts = this.getOptions();
|
|
46
|
+
const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
|
|
47
|
+
const filename = this.resourcePath;
|
|
48
|
+
const swcOpts = {
|
|
49
|
+
...getBaseOpts({
|
|
50
|
+
filename,
|
|
51
|
+
}),
|
|
52
|
+
filename,
|
|
53
|
+
sourceMaps: this.sourceMap,
|
|
54
|
+
sourceFileName: filename,
|
|
55
|
+
...otherOpts,
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
if (sync) {
|
|
59
|
+
const output = (0, core_1.transformSync)(contents, swcOpts);
|
|
60
|
+
callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
(0, core_1.transform)(contents, swcOpts).then((output) => {
|
|
64
|
+
callback(null, output.code, parseMap ? JSON.parse(output.map) : output.map);
|
|
65
|
+
}, (err) => {
|
|
66
|
+
callback(err);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
callback(e);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.default = swcLoader;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
13
4
|
const webpack_sources_1 = require("@umijs/bundler-webpack/compiled/webpack-sources");
|
|
@@ -30,36 +21,32 @@ class ESBuildCSSMinifyPlugin {
|
|
|
30
21
|
name: PLUGIN_NAME,
|
|
31
22
|
stage: 400,
|
|
32
23
|
additionalAssets: true,
|
|
33
|
-
}, () =>
|
|
34
|
-
|
|
35
|
-
})
|
|
24
|
+
}, async () => {
|
|
25
|
+
await this.transformAssets(compilation);
|
|
26
|
+
});
|
|
36
27
|
});
|
|
37
28
|
}
|
|
38
|
-
transformAssets(compilation) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
: this.options.sourcemap;
|
|
44
|
-
const assets = compilation.getAssets().filter((asset) => {
|
|
45
|
-
return !asset.info.minimized && RE_CSS_FILE.test(asset.name);
|
|
46
|
-
});
|
|
47
|
-
yield Promise.all(assets.map((asset) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const { source, map } = asset.source.sourceAndMap();
|
|
49
|
-
const sourceAsString = source.toString();
|
|
50
|
-
const result = yield (0, esbuild_1.transform)(sourceAsString, {
|
|
51
|
-
loader: 'css',
|
|
52
|
-
sourcemap,
|
|
53
|
-
sourcefile: asset.name,
|
|
54
|
-
minify: true,
|
|
55
|
-
});
|
|
56
|
-
compilation.updateAsset(asset.name,
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
sourcemap
|
|
59
|
-
? new webpack_sources_1.SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
|
|
60
|
-
: new webpack_sources_1.RawSource(result.code), Object.assign(Object.assign({}, asset.info), { minimized: true }));
|
|
61
|
-
})));
|
|
29
|
+
async transformAssets(compilation) {
|
|
30
|
+
const { options: { devtool }, } = compilation.compiler;
|
|
31
|
+
const sourcemap = this.options.sourcemap === undefined ? !!devtool : this.options.sourcemap;
|
|
32
|
+
const assets = compilation.getAssets().filter((asset) => {
|
|
33
|
+
return !asset.info.minimized && RE_CSS_FILE.test(asset.name);
|
|
62
34
|
});
|
|
35
|
+
await Promise.all(assets.map(async (asset) => {
|
|
36
|
+
const { source, map } = asset.source.sourceAndMap();
|
|
37
|
+
const sourceAsString = source.toString();
|
|
38
|
+
const result = await (0, esbuild_1.transform)(sourceAsString, {
|
|
39
|
+
loader: 'css',
|
|
40
|
+
sourcemap,
|
|
41
|
+
sourcefile: asset.name,
|
|
42
|
+
minify: true,
|
|
43
|
+
});
|
|
44
|
+
compilation.updateAsset(asset.name,
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
sourcemap
|
|
47
|
+
? new webpack_sources_1.SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
|
|
48
|
+
: new webpack_sources_1.RawSource(result.code), { ...asset.info, minimized: true });
|
|
49
|
+
}));
|
|
63
50
|
}
|
|
64
51
|
}
|
|
65
52
|
exports.default = ESBuildCSSMinifyPlugin;
|
|
@@ -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 {};
|