@umijs/bundler-vite 4.0.0-beta.13 → 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 +1 -7
- package/dist/config/config.js +1 -1
- package/dist/config/transformer/alias.d.ts +6 -0
- package/dist/config/transformer/alias.js +21 -0
- package/dist/config/transformer/css.js +1 -1
- package/dist/config/transformer/index.js +2 -0
- package/dist/config/transformer/optimizeDeps.js +4 -1
- package/dist/config/transformer/rename.js +0 -1
- 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'),
|
|
@@ -80,12 +80,6 @@ else {
|
|
|
80
80
|
function error(msg) {
|
|
81
81
|
console.error(utils_1.chalk.red(msg));
|
|
82
82
|
}
|
|
83
|
-
function tryPaths(paths) {
|
|
84
|
-
for (const path of paths) {
|
|
85
|
-
if ((0, fs_1.existsSync)(path))
|
|
86
|
-
return path;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
83
|
function getEntryKey(path) {
|
|
90
84
|
return (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
91
85
|
}
|
package/dist/config/config.js
CHANGED
|
@@ -18,7 +18,7 @@ const plugins_1 = __importDefault(require("../plugins"));
|
|
|
18
18
|
const transformer_1 = __importDefault(require("./transformer"));
|
|
19
19
|
function getConfig(opts) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const applyOpts = Object.assign(Object.assign({}, opts.userConfig), { extraBabelPlugins: [
|
|
21
|
+
const applyOpts = Object.assign(Object.assign({}, opts.userConfig), { entry: opts.entry, extraBabelPlugins: [
|
|
22
22
|
...(opts.extraBabelPlugins || []),
|
|
23
23
|
...(opts.userConfig.extraBabelPlugins || []),
|
|
24
24
|
], extraBabelPresets: [
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* transform umi alias to vite alias
|
|
5
|
+
*/
|
|
6
|
+
exports.default = (function alias(userConfig) {
|
|
7
|
+
const config = {};
|
|
8
|
+
if (typeof userConfig.alias === 'object') {
|
|
9
|
+
config.resolve = {
|
|
10
|
+
alias: Object.entries(userConfig.alias).map(([name, target]) => ({
|
|
11
|
+
// supports webpack suffix $ and less-loader prefix ~
|
|
12
|
+
// example:
|
|
13
|
+
// - dep => ^~?dep(?=\/|$)
|
|
14
|
+
// - dep$ => ^~?dep$
|
|
15
|
+
find: new RegExp(`^~?${name.replace(/(?<!\$)$/, '(?=/|$)')}`),
|
|
16
|
+
replacement: target,
|
|
17
|
+
})),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
});
|
|
@@ -23,7 +23,7 @@ exports.default = (function css(userConfig) {
|
|
|
23
23
|
css: { postcss: {}, preprocessorOptions: {} },
|
|
24
24
|
resolve: {
|
|
25
25
|
alias: [
|
|
26
|
-
// to
|
|
26
|
+
// to support less-loader ~ for local deps, refer: https://github.com/vitejs/vite/issues/2185
|
|
27
27
|
{ find: /^~/, replacement: '' },
|
|
28
28
|
],
|
|
29
29
|
},
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const vite_1 = require("vite");
|
|
7
|
+
const alias_1 = __importDefault(require("./alias"));
|
|
7
8
|
const css_1 = __importDefault(require("./css"));
|
|
8
9
|
const define_1 = __importDefault(require("./define"));
|
|
9
10
|
const devServer_1 = __importDefault(require("./devServer"));
|
|
@@ -19,6 +20,7 @@ exports.default = (userConfig) => {
|
|
|
19
20
|
const transformers = [
|
|
20
21
|
rename_1.default,
|
|
21
22
|
devServer_1.default,
|
|
23
|
+
alias_1.default,
|
|
22
24
|
css_1.default,
|
|
23
25
|
rollup_1.default,
|
|
24
26
|
react_1.default,
|
|
@@ -4,7 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* transform user config to vite optimizeDeps config
|
|
5
5
|
*/
|
|
6
6
|
exports.default = (function optimizeDeps(userConfig) {
|
|
7
|
-
const config = {
|
|
7
|
+
const config = {
|
|
8
|
+
// configure pre-bundling entries
|
|
9
|
+
optimizeDeps: { entries: Object.values(userConfig.entry) },
|
|
10
|
+
};
|
|
8
11
|
// include alias which within node_modules for optimize dependencies
|
|
9
12
|
if (typeof userConfig.alias === 'object') {
|
|
10
13
|
config.optimizeDeps.include = Object.keys(userConfig.alias).filter((name) => userConfig.alias[name].includes('node_modules'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-vite",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.17",
|
|
4
4
|
"description": "@umijs/bundler-vite",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-vite#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@svgr/core": "6.0.0",
|
|
28
|
-
"@umijs/bundler-utils": "4.0.0-beta.
|
|
29
|
-
"@umijs/utils": "4.0.0-beta.
|
|
28
|
+
"@umijs/bundler-utils": "4.0.0-beta.17",
|
|
29
|
+
"@umijs/utils": "4.0.0-beta.17",
|
|
30
30
|
"@vitejs/plugin-legacy": "1.6.3",
|
|
31
31
|
"@vitejs/plugin-react": "1.1.0",
|
|
32
32
|
"postcss-preset-env": "7.0.1",
|
|
33
33
|
"rollup-plugin-copy": "3.4.0",
|
|
34
34
|
"rollup-plugin-polyfill": "3.0.0",
|
|
35
35
|
"rollup-plugin-visualizer": "5.5.2",
|
|
36
|
-
"vite": "2.6
|
|
36
|
+
"vite": "2.7.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"express": "4.17.1"
|