@umijs/bundler-webpack 4.0.7 → 4.0.10
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/{dist → client}/client/client.d.ts +0 -0
- package/client/client/client.js +295 -194
- package/client/constants.d.ts +15 -0
- package/client/constants.js +28 -19
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +68 -86
- package/dist/build.d.ts +1 -1
- package/dist/build.js +105 -68
- package/dist/cli.js +77 -69
- package/dist/config/_sampleFeature.js +33 -9
- package/dist/config/assetRules.js +45 -36
- package/dist/config/bundleAnalyzerPlugin.js +39 -17
- package/dist/config/compressPlugin.js +114 -95
- package/dist/config/config.d.ts +1 -0
- package/dist/config/config.js +204 -215
- package/dist/config/copyPlugin.js +59 -40
- package/dist/config/cssRules.js +136 -131
- package/dist/config/definePlugin.js +71 -35
- package/dist/config/detectDeadCode.js +120 -108
- package/dist/config/detectDeadCodePlugin.js +78 -63
- package/dist/config/fastRefreshPlugin.js +39 -20
- package/dist/config/forkTSCheckerPlugin.js +38 -19
- package/dist/config/harmonyLinkingErrorPlugin.js +48 -29
- package/dist/config/ignorePlugin.js +38 -14
- package/dist/config/javaScriptRules.js +147 -173
- package/dist/config/manifestPlugin.js +51 -15
- package/dist/config/miniCSSExtractPlugin.js +42 -22
- package/dist/config/nodePolyfill.js +65 -26
- package/dist/config/nodePrefixPlugin.js +36 -12
- package/dist/config/progressPlugin.js +37 -13
- package/dist/config/purgecssWebpackPlugin.js +41 -19
- package/dist/config/speedMeasureWebpackPlugin.js +41 -20
- package/dist/config/ssrPlugin.js +83 -63
- package/dist/config/svgRules.js +74 -46
- package/dist/constants.js +57 -22
- package/dist/dev.d.ts +1 -1
- package/dist/dev.js +174 -134
- package/dist/index.js +22 -20
- package/dist/loader/svgr.js +73 -54
- package/dist/loader/swc.js +110 -69
- package/dist/parcelCSS.js +31 -27
- package/dist/plugins/ProgressPlugin.js +66 -43
- package/dist/plugins/RuntimePublicPathPlugin.js +42 -23
- package/dist/plugins/_SamplePlugin.js +39 -14
- package/dist/requireHook.js +37 -27
- package/dist/schema.js +123 -96
- package/dist/server/server.d.ts +0 -1
- package/dist/server/server.js +214 -184
- package/dist/server/ws.d.ts +0 -2
- package/dist/server/ws.js +63 -38
- package/dist/swcPlugins/autoCSSModules.js +50 -31
- package/dist/swcPlugins/changeImportFromString.js +31 -9
- package/dist/swcPlugins/lockCoreJS.js +44 -20
- package/dist/types.d.ts +2 -1
- package/dist/types.js +61 -30
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +63 -39
- package/dist/utils/formatWebpackMessages.js +93 -91
- package/dist/utils/getEsBuildTarget.d.ts +3 -1
- package/dist/utils/getEsBuildTarget.js +39 -11
- package/package.json +12 -16
- package/compiled/fork-ts-checker-webpack-plugin/LICENSE +0 -21
- package/compiled/fork-ts-checker-webpack-plugin/fsevents.node +0 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +0 -42
- package/compiled/fork-ts-checker-webpack-plugin/package.json +0 -1
- package/compiled/react-refresh/LICENSE +0 -21
- package/compiled/react-refresh/index.js +0 -21
- package/compiled/react-refresh/package.json +0 -1
- package/dist/client/client.js +0 -245
package/dist/dev.js
CHANGED
|
@@ -1,142 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
4
35
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// src/dev.ts
|
|
40
|
+
var dev_exports = {};
|
|
41
|
+
__export(dev_exports, {
|
|
42
|
+
dev: () => dev,
|
|
43
|
+
stripUndefined: () => stripUndefined
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(dev_exports);
|
|
46
|
+
var import_mfsu = require("@umijs/mfsu");
|
|
47
|
+
var import_utils = require("@umijs/utils");
|
|
48
|
+
var import_fs = require("fs");
|
|
49
|
+
var import_path = require("path");
|
|
50
|
+
var import_webpack = __toESM(require("../compiled/webpack"));
|
|
51
|
+
var import_config = require("./config/config");
|
|
52
|
+
var import_constants = require("./constants");
|
|
53
|
+
var import_server = require("./server/server");
|
|
54
|
+
var import_types = require("./types");
|
|
16
55
|
function stripUndefined(obj) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
56
|
+
Object.keys(obj).forEach((key) => {
|
|
57
|
+
if (obj[key] === void 0) {
|
|
58
|
+
delete obj[key];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return obj;
|
|
23
62
|
}
|
|
24
|
-
exports.stripUndefined = stripUndefined;
|
|
25
63
|
async function dev(opts) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
34
|
-
}
|
|
35
|
-
mfsu = new mfsu_1.MFSU({
|
|
36
|
-
strategy: opts.mfsuStrategy,
|
|
37
|
-
include: opts.mfsuInclude || [],
|
|
38
|
-
srcCodeCache: opts.srcCodeCache,
|
|
39
|
-
implementor: webpack_1.default,
|
|
40
|
-
buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
|
|
41
|
-
depBuildConfig: {
|
|
42
|
-
extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
|
|
43
|
-
},
|
|
44
|
-
mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
|
|
45
|
-
runtimePublicPath: opts.config.runtimePublicPath,
|
|
46
|
-
tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) || (0, path_1.join)(cacheDirectoryPath, 'mfsu'),
|
|
47
|
-
onMFSUProgress: opts.onMFSUProgress,
|
|
48
|
-
getCacheDependency() {
|
|
49
|
-
return stripUndefined({
|
|
50
|
-
version: require('../package.json').version,
|
|
51
|
-
mfsu: opts.config.mfsu,
|
|
52
|
-
alias: opts.config.alias,
|
|
53
|
-
externals: opts.config.externals,
|
|
54
|
-
theme: opts.config.theme,
|
|
55
|
-
runtimePublicPath: opts.config.runtimePublicPath,
|
|
56
|
-
publicPath: opts.config.publicPath,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
});
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
65
|
+
const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
|
|
66
|
+
const enableMFSU = opts.config.mfsu !== false;
|
|
67
|
+
let mfsu = null;
|
|
68
|
+
if (enableMFSU) {
|
|
69
|
+
if (opts.config.srcTranspiler === import_types.Transpiler.swc) {
|
|
70
|
+
import_utils.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
60
71
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const depConfig = await (0, config_1.getConfig)({
|
|
91
|
-
cwd: opts.cwd,
|
|
92
|
-
rootDir: opts.rootDir,
|
|
93
|
-
env: types_1.Env.development,
|
|
94
|
-
entry: opts.entry,
|
|
95
|
-
userConfig: opts.config,
|
|
96
|
-
hash: true,
|
|
97
|
-
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
98
|
-
name: constants_1.MFSU_NAME,
|
|
99
|
-
chainWebpack: (_e = opts.config.mfsu) === null || _e === void 0 ? void 0 : _e.chainWebpack,
|
|
100
|
-
cache: {
|
|
101
|
-
buildDependencies: (_f = opts.cache) === null || _f === void 0 ? void 0 : _f.buildDependencies,
|
|
102
|
-
cacheDirectory: (0, path_1.join)(cacheDirectoryPath, 'mfsu-deps'),
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
(_g = webpackConfig.resolve).alias || (_g.alias = {});
|
|
106
|
-
// TODO: REMOVE ME
|
|
107
|
-
['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
webpackConfig.resolve.alias[dep] = require.resolve(dep);
|
|
72
|
+
mfsu = new import_mfsu.MFSU({
|
|
73
|
+
strategy: opts.mfsuStrategy,
|
|
74
|
+
include: opts.mfsuInclude || [],
|
|
75
|
+
srcCodeCache: opts.srcCodeCache,
|
|
76
|
+
implementor: import_webpack.default,
|
|
77
|
+
buildDepWithESBuild: (_a = opts.config.mfsu) == null ? void 0 : _a.esbuild,
|
|
78
|
+
depBuildConfig: {
|
|
79
|
+
extraPostCSSPlugins: ((_b = opts.config) == null ? void 0 : _b.extraPostCSSPlugins) || []
|
|
80
|
+
},
|
|
81
|
+
mfName: (_c = opts.config.mfsu) == null ? void 0 : _c.mfName,
|
|
82
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
83
|
+
tmpBase: ((_d = opts.config.mfsu) == null ? void 0 : _d.cacheDirectory) || (0, import_path.join)(cacheDirectoryPath, "mfsu"),
|
|
84
|
+
onMFSUProgress: opts.onMFSUProgress,
|
|
85
|
+
unMatchLibs: (_e = opts.config.mfsu) == null ? void 0 : _e.exclude,
|
|
86
|
+
shared: (_f = opts.config.mfsu) == null ? void 0 : _f.shared,
|
|
87
|
+
remoteAliases: (_g = opts.config.mfsu) == null ? void 0 : _g.remoteAliases,
|
|
88
|
+
remoteName: (_h = opts.config.mfsu) == null ? void 0 : _h.remoteName,
|
|
89
|
+
getCacheDependency() {
|
|
90
|
+
return stripUndefined({
|
|
91
|
+
version: require("../package.json").version,
|
|
92
|
+
mfsu: opts.config.mfsu,
|
|
93
|
+
alias: opts.config.alias,
|
|
94
|
+
externals: opts.config.externals,
|
|
95
|
+
theme: opts.config.theme,
|
|
96
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
97
|
+
publicPath: opts.config.publicPath
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
serverBase: `${opts.config.https ? "https" : "http"}://${opts.host}:${opts.port || 8e3}`
|
|
110
101
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
102
|
+
}
|
|
103
|
+
const webpackConfig = await (0, import_config.getConfig)({
|
|
104
|
+
cwd: opts.cwd,
|
|
105
|
+
rootDir: opts.rootDir,
|
|
106
|
+
env: import_types.Env.development,
|
|
107
|
+
entry: opts.entry,
|
|
108
|
+
userConfig: opts.config,
|
|
109
|
+
babelPreset: opts.babelPreset,
|
|
110
|
+
extraBabelPlugins: [
|
|
111
|
+
...opts.beforeBabelPlugins || [],
|
|
112
|
+
...(mfsu == null ? void 0 : mfsu.getBabelPlugins()) || [],
|
|
113
|
+
...opts.extraBabelPlugins || []
|
|
114
|
+
],
|
|
115
|
+
extraBabelPresets: [
|
|
116
|
+
...opts.beforeBabelPresets || [],
|
|
117
|
+
...opts.extraBabelPresets || []
|
|
118
|
+
],
|
|
119
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
120
|
+
extraEsbuildLoaderHandler: (mfsu == null ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
|
|
121
|
+
chainWebpack: opts.chainWebpack,
|
|
122
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
123
|
+
hmr: process.env.HMR !== "none",
|
|
124
|
+
analyze: process.env.ANALYZE,
|
|
125
|
+
cache: opts.cache ? __spreadProps(__spreadValues({}, opts.cache), {
|
|
126
|
+
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "bundler-webpack")
|
|
127
|
+
}) : void 0,
|
|
128
|
+
pkg: opts.pkg
|
|
129
|
+
});
|
|
130
|
+
const depConfig = await (0, import_config.getConfig)({
|
|
131
|
+
cwd: opts.cwd,
|
|
132
|
+
rootDir: opts.rootDir,
|
|
133
|
+
env: import_types.Env.development,
|
|
134
|
+
entry: opts.entry,
|
|
135
|
+
userConfig: opts.config,
|
|
136
|
+
hash: true,
|
|
137
|
+
staticPathPrefix: import_mfsu.MF_DEP_PREFIX,
|
|
138
|
+
name: import_constants.MFSU_NAME,
|
|
139
|
+
chainWebpack: (_i = opts.config.mfsu) == null ? void 0 : _i.chainWebpack,
|
|
140
|
+
cache: {
|
|
141
|
+
buildDependencies: (_j = opts.cache) == null ? void 0 : _j.buildDependencies,
|
|
142
|
+
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "mfsu-deps")
|
|
143
|
+
},
|
|
144
|
+
pkg: opts.pkg
|
|
145
|
+
});
|
|
146
|
+
(_k = webpackConfig.resolve).alias || (_k.alias = {});
|
|
147
|
+
["@umijs/utils/compiled/strip-ansi", "react-error-overlay"].forEach((dep) => {
|
|
148
|
+
webpackConfig.resolve.alias[dep] = require.resolve(dep);
|
|
149
|
+
});
|
|
150
|
+
await (mfsu == null ? void 0 : mfsu.setWebpackConfig({
|
|
151
|
+
config: webpackConfig,
|
|
152
|
+
depConfig
|
|
153
|
+
}));
|
|
154
|
+
if (mfsu && webpackConfig.cache && typeof webpackConfig.cache === "object" && webpackConfig.cache.type === "filesystem") {
|
|
155
|
+
const webpackCachePath = (0, import_path.join)(webpackConfig.cache.cacheDirectory, `default-development`, "index.pack");
|
|
156
|
+
const mfsuCacheExists = (0, import_fs.existsSync)(mfsu.getCacheFilePath());
|
|
157
|
+
const webpackCacheExists = (0, import_fs.existsSync)(webpackCachePath);
|
|
158
|
+
if (webpackCacheExists && !mfsuCacheExists) {
|
|
159
|
+
import_utils.logger.warn(`Invalidate webpack cache since mfsu cache is missing`);
|
|
160
|
+
import_utils.rimraf.sync(webpackConfig.cache.cacheDirectory);
|
|
126
161
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
162
|
+
}
|
|
163
|
+
await (0, import_server.createServer)({
|
|
164
|
+
webpackConfig,
|
|
165
|
+
userConfig: opts.config,
|
|
166
|
+
cwd: opts.cwd,
|
|
167
|
+
beforeMiddlewares: [
|
|
168
|
+
...(mfsu == null ? void 0 : mfsu.getMiddlewares()) || [],
|
|
169
|
+
...opts.beforeMiddlewares || []
|
|
170
|
+
],
|
|
171
|
+
port: opts.port,
|
|
172
|
+
host: opts.host,
|
|
173
|
+
afterMiddlewares: [...opts.afterMiddlewares || []],
|
|
174
|
+
onDevCompileDone: opts.onDevCompileDone,
|
|
175
|
+
onProgress: opts.onProgress
|
|
176
|
+
});
|
|
141
177
|
}
|
|
142
|
-
|
|
178
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
179
|
+
0 && (module.exports = {
|
|
180
|
+
dev,
|
|
181
|
+
stripUndefined
|
|
182
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
var import_requireHook = require("./requireHook");
|
|
20
|
+
__reExport(src_exports, require("./build"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./config/config"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./dev"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./schema"), module.exports);
|
package/dist/loader/svgr.js
CHANGED
|
@@ -1,58 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/loader/svgr.ts
|
|
23
|
+
var svgr_exports = {};
|
|
24
|
+
__export(svgr_exports, {
|
|
25
|
+
default: () => svgr_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(svgr_exports);
|
|
28
|
+
var import_core = require("@svgr/core");
|
|
29
|
+
var import_plugin_jsx = __toESM(require("@svgr/plugin-jsx"));
|
|
30
|
+
var import_plugin_svgo = __toESM(require("@svgr/plugin-svgo"));
|
|
31
|
+
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
32
|
+
var import_path = require("path");
|
|
33
|
+
var import_util = require("util");
|
|
34
|
+
var tranformSvg = (0, import_util.callbackify)(async (contents, options, state) => {
|
|
35
|
+
const jsCode = await (0, import_core.transform)(contents, options, state);
|
|
36
|
+
const result = await (0, import_esbuild.transform)(jsCode, {
|
|
37
|
+
loader: "tsx",
|
|
38
|
+
target: "es2015"
|
|
39
|
+
});
|
|
40
|
+
if (!(result == null ? void 0 : result.code)) {
|
|
41
|
+
throw new Error(`Error while transforming using Esbuild`);
|
|
42
|
+
}
|
|
43
|
+
return result.code;
|
|
26
44
|
});
|
|
27
45
|
function svgrLoader(contents) {
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
}
|
|
46
|
+
this.cacheable && this.cacheable();
|
|
47
|
+
const callback = this.async();
|
|
48
|
+
const options = this.getOptions();
|
|
49
|
+
const previousExport = (() => {
|
|
50
|
+
if (contents.startsWith("export "))
|
|
51
|
+
return contents;
|
|
52
|
+
const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
|
|
53
|
+
return exportMatches ? `export default ${exportMatches[1]}` : null;
|
|
54
|
+
})();
|
|
55
|
+
const state = {
|
|
56
|
+
caller: {
|
|
57
|
+
name: "svgr-loader",
|
|
58
|
+
previousExport,
|
|
59
|
+
defaultPlugins: [import_plugin_svgo.default, import_plugin_jsx.default]
|
|
60
|
+
},
|
|
61
|
+
filePath: (0, import_path.normalize)(this.resourcePath)
|
|
62
|
+
};
|
|
63
|
+
if (!previousExport) {
|
|
64
|
+
tranformSvg(contents, options, state, callback);
|
|
65
|
+
} else {
|
|
66
|
+
this.fs.readFile(this.resourcePath, (err, result) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
callback(err);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
tranformSvg(String(result), options, state, callback);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
57
74
|
}
|
|
58
|
-
|
|
75
|
+
var svgr_default = svgrLoader;
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {});
|