@umijs/bundler-webpack 4.0.0-rc.14 → 4.0.0-rc.17
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/build.js +48 -59
- package/dist/cli.js +6 -15
- package/dist/client/client.js +34 -47
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +68 -76
- package/dist/config/config.js +177 -185
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +93 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCodePlugin.js +16 -21
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.js +11 -22
- package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.js +151 -162
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +12 -23
- package/dist/config/nodePolyfill.js +14 -21
- package/dist/config/nodePrefixPlugin.js +8 -19
- 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.js +43 -47
- package/dist/dev.js +101 -112
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +23 -34
- package/dist/plugins/ParcelCSSMinifyPlugin.js +30 -32
- package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
- package/dist/schema.js +18 -6
- package/dist/server/server.d.ts +1 -1
- package/dist/server/server.js +161 -170
- package/dist/server/ws.d.ts +1 -1
- package/dist/types.d.ts +2 -6
- package/package.json +9 -11
- package/dist/server/https.d.ts +0 -4
- package/dist/server/https.js +0 -74
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,19 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.addMiniCSSExtractPlugin = void 0;
|
|
16
7
|
// @ts-ignore
|
|
17
8
|
const mini_css_extract_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/mini-css-extract-plugin"));
|
|
18
|
-
function addMiniCSSExtractPlugin(opts) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
});
|
|
9
|
+
async function addMiniCSSExtractPlugin(opts) {
|
|
10
|
+
const { config, userConfig, useHash } = opts;
|
|
11
|
+
const hash = useHash ? '.[contenthash:8]' : '';
|
|
12
|
+
if (!userConfig.styleLoader) {
|
|
13
|
+
config.plugin('mini-css-extract-plugin').use(mini_css_extract_plugin_1.default, [
|
|
14
|
+
{
|
|
15
|
+
filename: `[name]${hash}.css`,
|
|
16
|
+
chunkFilename: `[name]${hash}.chunk.css`,
|
|
17
|
+
ignoreOrder: true,
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
32
21
|
}
|
|
33
22
|
exports.addMiniCSSExtractPlugin = addMiniCSSExtractPlugin;
|
|
@@ -1,27 +1,18 @@
|
|
|
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.addNodePolyfill = void 0;
|
|
13
4
|
const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
|
|
14
|
-
function addNodePolyfill(opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
async function addNodePolyfill(opts) {
|
|
6
|
+
const { config } = opts;
|
|
7
|
+
const nodeLibs = require('node-libs-browser');
|
|
8
|
+
config.plugin('node-polyfill-provider').use(webpack_1.ProvidePlugin, [
|
|
9
|
+
{
|
|
10
|
+
Buffer: ['buffer', 'Buffer'],
|
|
11
|
+
process: nodeLibs['process'],
|
|
12
|
+
},
|
|
13
|
+
]);
|
|
14
|
+
config.resolve.fallback.merge({
|
|
15
|
+
...Object.keys(nodeLibs).reduce((memo, key) => {
|
|
25
16
|
if (nodeLibs[key]) {
|
|
26
17
|
memo[key] = nodeLibs[key];
|
|
27
18
|
}
|
|
@@ -29,7 +20,9 @@ function addNodePolyfill(opts) {
|
|
|
29
20
|
memo[key] = false;
|
|
30
21
|
}
|
|
31
22
|
return memo;
|
|
32
|
-
}, {})
|
|
23
|
+
}, {}),
|
|
24
|
+
http: false,
|
|
25
|
+
https: false,
|
|
33
26
|
});
|
|
34
27
|
}
|
|
35
28
|
exports.addNodePolyfill = addNodePolyfill;
|
|
@@ -1,25 +1,14 @@
|
|
|
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.addNodePrefixPlugin = void 0;
|
|
13
4
|
const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
|
|
14
|
-
function addNodePrefixPlugin(opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]);
|
|
23
|
-
});
|
|
5
|
+
async function addNodePrefixPlugin(opts) {
|
|
6
|
+
const { config } = opts;
|
|
7
|
+
config.plugin('node-prefix-plugin').use(webpack_1.NormalModuleReplacementPlugin, [
|
|
8
|
+
/^node:/,
|
|
9
|
+
(resource) => {
|
|
10
|
+
resource.request = resource.request.replace(/^node:/, '');
|
|
11
|
+
},
|
|
12
|
+
]);
|
|
24
13
|
}
|
|
25
14
|
exports.addNodePrefixPlugin = addNodePrefixPlugin;
|
|
@@ -1,27 +1,16 @@
|
|
|
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
6
|
exports.addProgressPlugin = void 0;
|
|
16
7
|
const ProgressPlugin_1 = __importDefault(require("../plugins/ProgressPlugin"));
|
|
17
|
-
function addProgressPlugin(opts) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
8
|
+
async function addProgressPlugin(opts) {
|
|
9
|
+
const { config, name } = opts;
|
|
10
|
+
config.plugin('progress-plugin').use(ProgressPlugin_1.default, [
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
26
15
|
}
|
|
27
16
|
exports.addProgressPlugin = addProgressPlugin;
|
|
@@ -1,32 +1,21 @@
|
|
|
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.applyPurgeCSSWebpackPlugin = void 0;
|
|
13
4
|
const types_1 = require("../types");
|
|
14
|
-
function applyPurgeCSSWebpackPlugin(opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
});
|
|
5
|
+
async function applyPurgeCSSWebpackPlugin(opts) {
|
|
6
|
+
const { config, userConfig, cwd, env } = opts;
|
|
7
|
+
config;
|
|
8
|
+
userConfig;
|
|
9
|
+
cwd;
|
|
10
|
+
env;
|
|
11
|
+
if (userConfig.purgeCSS && env === types_1.Env.production) {
|
|
12
|
+
config
|
|
13
|
+
.plugin('purgecss-webpack-plugin')
|
|
14
|
+
.use(require('@umijs/bundler-webpack/compiled/purgecss-webpack-plugin'), [
|
|
15
|
+
{
|
|
16
|
+
paths: [],
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
31
20
|
}
|
|
32
21
|
exports.applyPurgeCSSWebpackPlugin = applyPurgeCSSWebpackPlugin;
|
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,19 +7,17 @@ exports.addSpeedMeasureWebpackPlugin = void 0;
|
|
|
16
7
|
// @ts-ignore
|
|
17
8
|
const speed_measure_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/speed-measure-webpack-plugin"));
|
|
18
9
|
const path_1 = require("path");
|
|
19
|
-
function addSpeedMeasureWebpackPlugin(opts) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return webpackConfig;
|
|
32
|
-
});
|
|
10
|
+
async function addSpeedMeasureWebpackPlugin(opts) {
|
|
11
|
+
let webpackConfig = opts.webpackConfig;
|
|
12
|
+
if (process.env.SPEED_MEASURE) {
|
|
13
|
+
const smpOption = process.env.SPEED_MEASURE === 'JSON'
|
|
14
|
+
? {
|
|
15
|
+
outputFormat: 'json',
|
|
16
|
+
outputTarget: (0, path_1.join)(process.cwd(), 'SPEED_MEASURE.json'),
|
|
17
|
+
}
|
|
18
|
+
: { outputFormat: 'human', outputTarget: console.log };
|
|
19
|
+
webpackConfig = new speed_measure_webpack_plugin_1.default(smpOption).wrap(webpackConfig);
|
|
20
|
+
}
|
|
21
|
+
return webpackConfig;
|
|
33
22
|
}
|
|
34
23
|
exports.addSpeedMeasureWebpackPlugin = addSpeedMeasureWebpackPlugin;
|
package/dist/config/svgRules.js
CHANGED
|
@@ -1,57 +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
|
-
|
|
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,
|
|
32
23
|
},
|
|
33
24
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
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) {
|
|
48
38
|
const svgRule = config.module.rule('svg');
|
|
49
39
|
svgRule
|
|
50
40
|
.test(/\.svg$/)
|
|
51
|
-
.use('
|
|
52
|
-
.loader(require.resolve('@umijs/bundler-webpack/compiled/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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();
|
|
56
52
|
}
|
|
57
53
|
exports.addSVGRules = addSVGRules;
|
package/dist/dev.js
CHANGED
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -31,115 +22,113 @@ function stripUndefined(obj) {
|
|
|
31
22
|
return obj;
|
|
32
23
|
}
|
|
33
24
|
exports.stripUndefined = stripUndefined;
|
|
34
|
-
function dev(opts) {
|
|
25
|
+
async function dev(opts) {
|
|
35
26
|
var _a, _b, _c, _d, _e, _f;
|
|
36
27
|
var _g;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
43
|
-
}
|
|
44
|
-
mfsu = new mfsu_1.MFSU({
|
|
45
|
-
implementor: webpack_1.default,
|
|
46
|
-
buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
|
|
47
|
-
depBuildConfig: {
|
|
48
|
-
extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
|
|
49
|
-
},
|
|
50
|
-
mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
|
|
51
|
-
runtimePublicPath: opts.config.runtimePublicPath,
|
|
52
|
-
tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
|
|
53
|
-
(0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules/.cache/mfsu'),
|
|
54
|
-
onMFSUProgress: opts.onMFSUProgress,
|
|
55
|
-
getCacheDependency() {
|
|
56
|
-
return stripUndefined({
|
|
57
|
-
version: require('../package.json').version,
|
|
58
|
-
mfsu: opts.config.mfsu,
|
|
59
|
-
alias: opts.config.alias,
|
|
60
|
-
externals: opts.config.externals,
|
|
61
|
-
theme: opts.config.theme,
|
|
62
|
-
runtimePublicPath: opts.config.runtimePublicPath,
|
|
63
|
-
publicPath: opts.config.publicPath,
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
});
|
|
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.`);
|
|
67
33
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
analyze: process.env.ANALYZE,
|
|
90
|
-
cache: opts.cache,
|
|
91
|
-
});
|
|
92
|
-
const depConfig = yield (0, config_1.getConfig)({
|
|
93
|
-
cwd: opts.cwd,
|
|
94
|
-
rootDir: opts.rootDir,
|
|
95
|
-
env: types_1.Env.development,
|
|
96
|
-
entry: opts.entry,
|
|
97
|
-
userConfig: opts.config,
|
|
98
|
-
hash: true,
|
|
99
|
-
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
100
|
-
name: constants_1.MFSU_NAME,
|
|
101
|
-
chainWebpack: (_e = opts.config.mfsu) === null || _e === void 0 ? void 0 : _e.chainWebpack,
|
|
102
|
-
cache: {
|
|
103
|
-
buildDependencies: (_f = opts.cache) === null || _f === void 0 ? void 0 : _f.buildDependencies,
|
|
104
|
-
cacheDirectory: (0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
|
|
34
|
+
mfsu = new mfsu_1.MFSU({
|
|
35
|
+
implementor: webpack_1.default,
|
|
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
|
+
});
|
|
105
55
|
},
|
|
106
56
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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);
|
|
128
117
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
],
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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,
|
|
143
132
|
});
|
|
144
133
|
}
|
|
145
134
|
exports.dev = dev;
|
package/dist/loader/svgr.js
CHANGED
|
@@ -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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,9 +13,9 @@ const plugin_svgo_1 = __importDefault(require("@svgr/plugin-svgo"));
|
|
|
22
13
|
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
23
14
|
const path_1 = require("path");
|
|
24
15
|
const util_1 = require("util");
|
|
25
|
-
const tranformSvg = (0, util_1.callbackify)((contents, options, state) =>
|
|
26
|
-
const jsCode =
|
|
27
|
-
const result =
|
|
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, {
|
|
28
19
|
loader: 'tsx',
|
|
29
20
|
target: 'es2015',
|
|
30
21
|
});
|
|
@@ -32,7 +23,7 @@ const tranformSvg = (0, util_1.callbackify)((contents, options, state) => __awai
|
|
|
32
23
|
throw new Error(`Error while transforming using Esbuild`);
|
|
33
24
|
}
|
|
34
25
|
return result.code;
|
|
35
|
-
})
|
|
26
|
+
});
|
|
36
27
|
function svgrLoader(contents) {
|
|
37
28
|
this.cacheable && this.cacheable();
|
|
38
29
|
const callback = this.async();
|