@umijs/bundler-webpack 4.0.0-beta.16 → 4.0.0-beta.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/cli.js +4 -7
- package/dist/config/assetRules.js +6 -2
- package/dist/config/javaScriptRules.js +12 -0
- package/dist/dev.js +1 -2
- package/dist/schema.js +4 -0
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ const dev_1 = require("./dev");
|
|
|
22
22
|
const args = (0, utils_1.yParser)(process.argv.slice(2), {});
|
|
23
23
|
const command = args._[0];
|
|
24
24
|
const cwd = process.cwd();
|
|
25
|
-
const entry = tryPaths([
|
|
25
|
+
const entry = (0, utils_1.tryPaths)([
|
|
26
26
|
(0, path_1.join)(cwd, 'src/index.tsx'),
|
|
27
27
|
(0, path_1.join)(cwd, 'src/index.ts'),
|
|
28
28
|
(0, path_1.join)(cwd, 'index.tsx'),
|
|
@@ -69,6 +69,9 @@ else if (command === 'dev') {
|
|
|
69
69
|
entry: {
|
|
70
70
|
[getEntryKey(entry)]: entry,
|
|
71
71
|
},
|
|
72
|
+
cache: {
|
|
73
|
+
buildDependencies: [].filter(Boolean),
|
|
74
|
+
},
|
|
72
75
|
});
|
|
73
76
|
}
|
|
74
77
|
catch (e) {
|
|
@@ -82,12 +85,6 @@ else {
|
|
|
82
85
|
function error(msg) {
|
|
83
86
|
console.error(utils_1.chalk.red(msg));
|
|
84
87
|
}
|
|
85
|
-
function tryPaths(paths) {
|
|
86
|
-
for (const path of paths) {
|
|
87
|
-
if ((0, fs_1.existsSync)(path))
|
|
88
|
-
return path;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
88
|
function getEntryKey(path) {
|
|
92
89
|
return (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
93
90
|
}
|
|
@@ -40,13 +40,17 @@ function addAssetRules(opts) {
|
|
|
40
40
|
.generator({
|
|
41
41
|
filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
|
|
42
42
|
});
|
|
43
|
-
rule
|
|
43
|
+
const fallback = rule
|
|
44
44
|
.oneOf('fallback')
|
|
45
45
|
.exclude.add(/^$/) /* handle data: resources */
|
|
46
46
|
.add(/\.(js|mjs|jsx|ts|tsx)$/)
|
|
47
47
|
.add(/\.(css|less|sass|scss|stylus)$/)
|
|
48
48
|
.add(/\.html$/)
|
|
49
|
-
.add(/\.json$/)
|
|
49
|
+
.add(/\.json$/);
|
|
50
|
+
if (userConfig.mdx) {
|
|
51
|
+
fallback.add(/\.mdx?$/);
|
|
52
|
+
}
|
|
53
|
+
fallback
|
|
50
54
|
.end()
|
|
51
55
|
.type('asset/resource')
|
|
52
56
|
.generator({
|
|
@@ -19,6 +19,7 @@ const autoCSSModules_1 = __importDefault(require("../swcPlugins/autoCSSModules")
|
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const depMatch_1 = require("../utils/depMatch");
|
|
21
21
|
function addJavaScriptRules(opts) {
|
|
22
|
+
var _a, _b;
|
|
22
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
const { config, userConfig, cwd, name } = opts;
|
|
24
25
|
const isDev = opts.env === types_1.Env.development;
|
|
@@ -54,6 +55,9 @@ function addJavaScriptRules(opts) {
|
|
|
54
55
|
})
|
|
55
56
|
.end(),
|
|
56
57
|
];
|
|
58
|
+
if (userConfig.mdx) {
|
|
59
|
+
srcRules.push(config.module.rule('markdown').test(/\.mdx?$/));
|
|
60
|
+
}
|
|
57
61
|
const depRules = [
|
|
58
62
|
config.module
|
|
59
63
|
.rule('dep')
|
|
@@ -124,6 +128,14 @@ function addJavaScriptRules(opts) {
|
|
|
124
128
|
throw new Error(`Unsupported srcTranspiler ${srcTranspiler}.`);
|
|
125
129
|
}
|
|
126
130
|
});
|
|
131
|
+
if (userConfig.mdx) {
|
|
132
|
+
config.module
|
|
133
|
+
.rule('mdx')
|
|
134
|
+
.test(/\.mdx?$/)
|
|
135
|
+
.use('mdx-loader')
|
|
136
|
+
.loader((_a = userConfig.mdx) === null || _a === void 0 ? void 0 : _a.loader)
|
|
137
|
+
.options((_b = userConfig.mdx) === null || _b === void 0 ? void 0 : _b.loaderOptions);
|
|
138
|
+
}
|
|
127
139
|
const depTranspiler = userConfig.depTranspiler || types_1.Transpiler.none;
|
|
128
140
|
depRules.forEach((_rule) => {
|
|
129
141
|
if (depTranspiler === types_1.Transpiler.none) {
|
package/dist/dev.js
CHANGED
|
@@ -55,8 +55,7 @@ function dev(opts) {
|
|
|
55
55
|
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
56
56
|
hmr: true,
|
|
57
57
|
analyze: process.env.ANALYZE,
|
|
58
|
-
|
|
59
|
-
// cache: opts.cache,
|
|
58
|
+
cache: opts.cache,
|
|
60
59
|
});
|
|
61
60
|
const depConfig = yield (0, config_1.getConfig)({
|
|
62
61
|
cwd: opts.cwd,
|
package/dist/schema.js
CHANGED
|
@@ -50,6 +50,10 @@ function getSchemas() {
|
|
|
50
50
|
jsMinifierOptions: (Joi) => Joi.object(),
|
|
51
51
|
lessLoader: (Joi) => Joi.object(),
|
|
52
52
|
manifest: (Joi) => Joi.object(),
|
|
53
|
+
mdx: (Joi) => Joi.object({
|
|
54
|
+
loader: Joi.string(),
|
|
55
|
+
loaderOptions: Joi.object(),
|
|
56
|
+
}),
|
|
53
57
|
mfsu: (Joi) => Joi.alternatives(Joi.object({
|
|
54
58
|
esbuild: Joi.boolean(),
|
|
55
59
|
mfName: Joi.string(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.17",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@svgr/plugin-svgo": "^6.1.0",
|
|
35
35
|
"@swc/core": "1.2.117",
|
|
36
36
|
"@types/hapi__joi": "17.1.7",
|
|
37
|
-
"@umijs/babel-preset-umi": "4.0.0-beta.
|
|
38
|
-
"@umijs/mfsu": "4.0.0-beta.
|
|
39
|
-
"@umijs/utils": "4.0.0-beta.
|
|
37
|
+
"@umijs/babel-preset-umi": "4.0.0-beta.17",
|
|
38
|
+
"@umijs/mfsu": "4.0.0-beta.17",
|
|
39
|
+
"@umijs/utils": "4.0.0-beta.17",
|
|
40
40
|
"css-loader": "6.5.1",
|
|
41
41
|
"es5-imcompatible-versions": "^0.1.73",
|
|
42
42
|
"jest-worker": "27.4.2",
|