@umijs/bundler-esbuild 4.0.0-rc.12 → 4.0.0-rc.15
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 +41 -43
- package/dist/cli.js +3 -12
- package/dist/plugins/alias.js +9 -20
- package/dist/plugins/less.js +29 -47
- package/dist/plugins/style.js +9 -22
- package/dist/utils/postcssProcess.js +14 -22
- package/package.json +5 -5
package/dist/build.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
|
};
|
|
@@ -20,40 +11,47 @@ const alias_1 = __importDefault(require("./plugins/alias"));
|
|
|
20
11
|
const externals_1 = __importDefault(require("./plugins/externals"));
|
|
21
12
|
const less_1 = __importDefault(require("./plugins/less"));
|
|
22
13
|
const style_1 = require("./plugins/style");
|
|
23
|
-
function build(opts) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
14
|
+
async function build(opts) {
|
|
15
|
+
const outputPath = opts.config.outputPath || (0, path_1.join)(opts.cwd, 'dist');
|
|
16
|
+
if (opts.clean) {
|
|
17
|
+
utils_1.rimraf.sync(outputPath);
|
|
18
|
+
}
|
|
19
|
+
return await (0, esbuild_1.build)({
|
|
20
|
+
entryPoints: opts.entry,
|
|
21
|
+
bundle: true,
|
|
22
|
+
format: opts.format || 'iife',
|
|
23
|
+
logLevel: 'error',
|
|
24
|
+
// splitting: true,
|
|
25
|
+
sourcemap: opts.sourcemap,
|
|
26
|
+
outdir: outputPath,
|
|
27
|
+
metafile: true,
|
|
28
|
+
plugins: [
|
|
29
|
+
(0, less_1.default)({
|
|
30
|
+
modifyVars: opts.config.theme,
|
|
31
|
+
javascriptEnabled: true,
|
|
32
|
+
alias: opts.config.alias,
|
|
33
|
+
// ref: https://github.com/umijs/umi-next/pull/214
|
|
34
|
+
inlineStyle: opts.inlineStyle,
|
|
35
|
+
config: opts.config,
|
|
36
|
+
...opts.config.lessLoader,
|
|
37
|
+
}),
|
|
38
|
+
opts.config.alias && (0, alias_1.default)(addCwdPrefix(opts.config.alias, opts.cwd)),
|
|
39
|
+
opts.config.externals && (0, externals_1.default)(opts.config.externals),
|
|
40
|
+
(0, style_1.style)({
|
|
41
|
+
inlineStyle: opts.inlineStyle,
|
|
42
|
+
config: opts.config,
|
|
43
|
+
}),
|
|
44
|
+
].filter(Boolean),
|
|
45
|
+
define: {
|
|
46
|
+
// __dirname sham
|
|
47
|
+
__dirname: JSON.stringify('__dirname'),
|
|
48
|
+
'process.env.NODE_ENV': JSON.stringify(opts.mode || 'development'),
|
|
49
|
+
...opts.config.define,
|
|
50
|
+
},
|
|
51
|
+
loader: {
|
|
52
|
+
'.svg': 'dataurl',
|
|
53
|
+
'.ttf': 'dataurl',
|
|
54
|
+
},
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
57
|
exports.build = build;
|
package/dist/cli.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
|
};
|
|
@@ -38,11 +29,11 @@ if ((0, fs_1.existsSync)(configFile)) {
|
|
|
38
29
|
}
|
|
39
30
|
Object.assign(config, args);
|
|
40
31
|
if (command === 'build') {
|
|
41
|
-
(() =>
|
|
32
|
+
(async () => {
|
|
42
33
|
process.env.NODE_ENV = 'production';
|
|
43
34
|
(0, assert_1.default)(entry, `Build failed: entry not found.`);
|
|
44
35
|
try {
|
|
45
|
-
|
|
36
|
+
await (0, build_1.build)({
|
|
46
37
|
config,
|
|
47
38
|
cwd,
|
|
48
39
|
entry: {
|
|
@@ -53,7 +44,7 @@ if (command === 'build') {
|
|
|
53
44
|
catch (e) {
|
|
54
45
|
console.error(e);
|
|
55
46
|
}
|
|
56
|
-
})
|
|
47
|
+
})();
|
|
57
48
|
}
|
|
58
49
|
else {
|
|
59
50
|
error(`Unsupported command ${command}.`);
|
package/dist/plugins/alias.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
|
};
|
|
@@ -21,11 +12,9 @@ const resolver = enhanced_resolve_1.default.create({
|
|
|
21
12
|
// TODO: support exports
|
|
22
13
|
exportsFields: [],
|
|
23
14
|
});
|
|
24
|
-
function resolve(context, path) {
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
|
|
28
|
-
});
|
|
15
|
+
async function resolve(context, path) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
|
|
29
18
|
});
|
|
30
19
|
}
|
|
31
20
|
// https://esbuild.github.io/plugins/#resolve-callbacks
|
|
@@ -43,22 +32,22 @@ exports.default = (options = {}) => {
|
|
|
43
32
|
else {
|
|
44
33
|
filter = new RegExp(`^${key}$`);
|
|
45
34
|
}
|
|
46
|
-
onResolve({ filter: filter }, (args) =>
|
|
47
|
-
const path =
|
|
35
|
+
onResolve({ filter: filter }, async (args) => {
|
|
36
|
+
const path = await resolve(args.importer, args.path.replace(filter, value));
|
|
48
37
|
return {
|
|
49
38
|
path,
|
|
50
39
|
};
|
|
51
|
-
})
|
|
40
|
+
});
|
|
52
41
|
if (!key.endsWith('/') &&
|
|
53
42
|
(0, fs_1.existsSync)(value) &&
|
|
54
43
|
(0, fs_1.statSync)(value).isDirectory()) {
|
|
55
44
|
const filter = new RegExp(`^${addSlashAffix(key)}`);
|
|
56
|
-
onResolve({ filter }, (args) =>
|
|
57
|
-
const path =
|
|
45
|
+
onResolve({ filter }, async (args) => {
|
|
46
|
+
const path = await resolve(args.importer, args.path.replace(filter, addSlashAffix(value)));
|
|
58
47
|
return {
|
|
59
48
|
path,
|
|
60
49
|
};
|
|
61
|
-
})
|
|
50
|
+
});
|
|
62
51
|
}
|
|
63
52
|
});
|
|
64
53
|
},
|
package/dist/plugins/less.js
CHANGED
|
@@ -1,24 +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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
@@ -47,27 +27,25 @@ const resolver = enhanced_resolve_1.default.create({
|
|
|
47
27
|
// TODO: support exports
|
|
48
28
|
exportsFields: [],
|
|
49
29
|
});
|
|
50
|
-
function resolve(context, path) {
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
|
|
54
|
-
});
|
|
30
|
+
async function resolve(context, path) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
|
|
55
33
|
});
|
|
56
34
|
}
|
|
57
|
-
const aliasLessImports = (ctx, alias, importer) =>
|
|
35
|
+
const aliasLessImports = async (ctx, alias, importer) => {
|
|
58
36
|
const importRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/;
|
|
59
37
|
const globalImportRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/g;
|
|
60
38
|
const match = ctx.match(globalImportRegex) || [];
|
|
61
39
|
for (const el of match) {
|
|
62
40
|
const [imp, _, filePath] = el.match(importRegex) || [];
|
|
63
|
-
let aliaPath =
|
|
41
|
+
let aliaPath = await (0, exports.aliasLessImportPath)(filePath, alias, importer);
|
|
64
42
|
if (aliaPath) {
|
|
65
43
|
ctx = ctx.replace(imp, el.replace(filePath, aliaPath));
|
|
66
44
|
}
|
|
67
45
|
}
|
|
68
46
|
return ctx;
|
|
69
|
-
}
|
|
70
|
-
const aliasLessImportPath = (filePath, alias, importer) =>
|
|
47
|
+
};
|
|
48
|
+
const aliasLessImportPath = async (filePath, alias, importer) => {
|
|
71
49
|
// ~ 写法在 esbuild 中无实际意义
|
|
72
50
|
let aliaPath = filePath.startsWith('~')
|
|
73
51
|
? filePath.replace('~', '')
|
|
@@ -79,23 +57,23 @@ const aliasLessImportPath = (filePath, alias, importer) => __awaiter(void 0, voi
|
|
|
79
57
|
pathSegments[0] = alias[key];
|
|
80
58
|
aliaPath = pathSegments.join('/');
|
|
81
59
|
aliaPath = path_1.default.extname(aliaPath) ? aliaPath : `${aliaPath}.less`;
|
|
82
|
-
return
|
|
60
|
+
return await resolve(importer, aliaPath);
|
|
83
61
|
}
|
|
84
62
|
}
|
|
85
63
|
return null;
|
|
86
|
-
}
|
|
64
|
+
};
|
|
87
65
|
exports.aliasLessImportPath = aliasLessImportPath;
|
|
88
66
|
exports.default = (options = {}) => {
|
|
89
|
-
const { alias, inlineStyle, config
|
|
67
|
+
const { alias, inlineStyle, config, ...lessOptions } = options;
|
|
90
68
|
return {
|
|
91
69
|
name: 'less',
|
|
92
70
|
setup({ onResolve, onLoad }) {
|
|
93
|
-
onResolve({ filter: /\.less$/, namespace: 'file' }, (args) =>
|
|
71
|
+
onResolve({ filter: /\.less$/, namespace: 'file' }, async (args) => {
|
|
94
72
|
let filePath = args.path;
|
|
95
73
|
let isMatchedAlias = false;
|
|
96
74
|
// first match alias
|
|
97
75
|
if (!!alias) {
|
|
98
|
-
const aliasMatchPath =
|
|
76
|
+
const aliasMatchPath = await (0, exports.aliasLessImportPath)(filePath, alias, args.path);
|
|
99
77
|
if (aliasMatchPath) {
|
|
100
78
|
isMatchedAlias = true;
|
|
101
79
|
filePath = aliasMatchPath;
|
|
@@ -105,7 +83,7 @@ exports.default = (options = {}) => {
|
|
|
105
83
|
if (!isMatchedAlias) {
|
|
106
84
|
const isImportFromDeps = !path_1.default.isAbsolute(filePath) && !filePath.startsWith('.');
|
|
107
85
|
if (isImportFromDeps) {
|
|
108
|
-
filePath =
|
|
86
|
+
filePath = await resolve(process.cwd(), filePath);
|
|
109
87
|
}
|
|
110
88
|
else {
|
|
111
89
|
filePath = path_1.default.resolve(process.cwd(), path_1.default.relative(process.cwd(), args.resolveDir), args.path);
|
|
@@ -115,7 +93,7 @@ exports.default = (options = {}) => {
|
|
|
115
93
|
path: filePath,
|
|
116
94
|
namespace: inlineStyle ? 'less-file' : 'file',
|
|
117
95
|
};
|
|
118
|
-
})
|
|
96
|
+
});
|
|
119
97
|
if (inlineStyle) {
|
|
120
98
|
onResolve({ filter: /\.less$/, namespace: 'less-file' }, (args) => {
|
|
121
99
|
return { path: args.path, namespace: 'less-content' };
|
|
@@ -125,32 +103,36 @@ exports.default = (options = {}) => {
|
|
|
125
103
|
namespace: 'style-helper',
|
|
126
104
|
sideEffects: false,
|
|
127
105
|
}));
|
|
128
|
-
onLoad({ filter: /.*/, namespace: 'less-file' }, (args) =>
|
|
129
|
-
|
|
130
|
-
contents: `
|
|
106
|
+
onLoad({ filter: /.*/, namespace: 'less-file' }, async (args) => ({
|
|
107
|
+
contents: `
|
|
131
108
|
import { injectStyle } from "__style_helper__"
|
|
132
109
|
import css from ${JSON.stringify(args.path)}
|
|
133
110
|
injectStyle(css)
|
|
134
111
|
export default{}
|
|
135
112
|
`,
|
|
136
|
-
});
|
|
137
113
|
}));
|
|
138
114
|
}
|
|
139
|
-
onLoad({ filter: /\.less$/, namespace: inlineStyle ? 'less-content' : 'file' }, (args) =>
|
|
140
|
-
let content =
|
|
115
|
+
onLoad({ filter: /\.less$/, namespace: inlineStyle ? 'less-content' : 'file' }, async (args) => {
|
|
116
|
+
let content = await fs_1.promises.readFile(args.path, 'utf-8');
|
|
141
117
|
if (!!alias) {
|
|
142
|
-
content =
|
|
118
|
+
content = await aliasLessImports(content, alias, args.path);
|
|
143
119
|
}
|
|
144
120
|
const dir = path_1.default.dirname(args.path);
|
|
145
121
|
const filename = path_1.default.basename(args.path);
|
|
146
122
|
try {
|
|
147
|
-
const result =
|
|
123
|
+
const result = await less_1.default.render(content, {
|
|
124
|
+
plugins: [
|
|
148
125
|
new less_plugin_aliases_1.default({
|
|
149
126
|
prefix: '~',
|
|
150
127
|
aliases: alias || {},
|
|
151
128
|
}),
|
|
152
|
-
],
|
|
153
|
-
|
|
129
|
+
],
|
|
130
|
+
filename,
|
|
131
|
+
rootpath: dir,
|
|
132
|
+
...lessOptions,
|
|
133
|
+
paths: [...(lessOptions.paths || []), dir],
|
|
134
|
+
});
|
|
135
|
+
const postcssrResult = await (0, postcssProcess_1.postcssProcess)(config, result.css, args.path);
|
|
154
136
|
return {
|
|
155
137
|
contents: postcssrResult.css,
|
|
156
138
|
loader: inlineStyle ? 'text' : 'css',
|
|
@@ -173,7 +155,7 @@ exports.default = (options = {}) => {
|
|
|
173
155
|
resolveDir: dir,
|
|
174
156
|
};
|
|
175
157
|
}
|
|
176
|
-
})
|
|
158
|
+
});
|
|
177
159
|
},
|
|
178
160
|
};
|
|
179
161
|
};
|
package/dist/plugins/style.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
|
};
|
|
@@ -56,9 +47,8 @@ function style({ minify = true, charset = 'utf8', inlineStyle, config, } = {}) {
|
|
|
56
47
|
namespace: 'style-helper',
|
|
57
48
|
sideEffects: false,
|
|
58
49
|
}));
|
|
59
|
-
onLoad({ filter: /.*/, namespace: 'style-helper' }, () =>
|
|
60
|
-
|
|
61
|
-
contents: `
|
|
50
|
+
onLoad({ filter: /.*/, namespace: 'style-helper' }, async () => ({
|
|
51
|
+
contents: `
|
|
62
52
|
export function injectStyle(text) {
|
|
63
53
|
if (typeof document !== 'undefined') {
|
|
64
54
|
var style = document.createElement('style')
|
|
@@ -68,24 +58,21 @@ function style({ minify = true, charset = 'utf8', inlineStyle, config, } = {}) {
|
|
|
68
58
|
}
|
|
69
59
|
}
|
|
70
60
|
`,
|
|
71
|
-
});
|
|
72
61
|
}));
|
|
73
|
-
onLoad({ filter: /.*/, namespace: 'style-stub' }, (args) =>
|
|
74
|
-
|
|
75
|
-
contents: `
|
|
62
|
+
onLoad({ filter: /.*/, namespace: 'style-stub' }, async (args) => ({
|
|
63
|
+
contents: `
|
|
76
64
|
import { injectStyle } from "__style_helper__"
|
|
77
65
|
import css from ${JSON.stringify(args.path)}
|
|
78
66
|
injectStyle(css)
|
|
79
67
|
`,
|
|
80
|
-
});
|
|
81
68
|
}));
|
|
82
69
|
}
|
|
83
70
|
onLoad({
|
|
84
71
|
filter: inlineStyle ? /.*/ : /\.css$/,
|
|
85
72
|
namespace: inlineStyle ? 'style-content' : 'file',
|
|
86
|
-
}, (args) =>
|
|
87
|
-
const options =
|
|
88
|
-
const { errors, warnings, outputFiles } =
|
|
73
|
+
}, async (args) => {
|
|
74
|
+
const options = { entryPoints: [args.path], ...opt };
|
|
75
|
+
const { errors, warnings, outputFiles } = await esbuild_1.default.build(options);
|
|
89
76
|
if (errors.length > 0) {
|
|
90
77
|
return {
|
|
91
78
|
errors,
|
|
@@ -96,7 +83,7 @@ function style({ minify = true, charset = 'utf8', inlineStyle, config, } = {}) {
|
|
|
96
83
|
}
|
|
97
84
|
const dir = path_1.default.dirname(args.path);
|
|
98
85
|
try {
|
|
99
|
-
const result =
|
|
86
|
+
const result = await (0, postcssProcess_1.postcssProcess)(config, outputFiles[0].text, args.path);
|
|
100
87
|
return {
|
|
101
88
|
errors,
|
|
102
89
|
warnings,
|
|
@@ -120,7 +107,7 @@ function style({ minify = true, charset = 'utf8', inlineStyle, config, } = {}) {
|
|
|
120
107
|
resolveDir: dir,
|
|
121
108
|
};
|
|
122
109
|
}
|
|
123
|
-
})
|
|
110
|
+
});
|
|
124
111
|
},
|
|
125
112
|
};
|
|
126
113
|
}
|
|
@@ -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,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.postcssProcess = void 0;
|
|
16
7
|
const postcss_1 = __importDefault(require("postcss"));
|
|
17
8
|
const getBrowserlist_1 = require("./getBrowserlist");
|
|
18
|
-
function postcssProcess(config, css, path) {
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
async function postcssProcess(config, css, path) {
|
|
10
|
+
return await (0, postcss_1.default)([
|
|
11
|
+
require('postcss-flexbugs-fixes'),
|
|
12
|
+
require('postcss-preset-env')({
|
|
13
|
+
browsers: (0, getBrowserlist_1.getBrowserlist)((config === null || config === void 0 ? void 0 : config.targets) || {}),
|
|
14
|
+
autoprefixer: {
|
|
15
|
+
flexbox: 'no-2009',
|
|
16
|
+
...config === null || config === void 0 ? void 0 : config.autoprefixer,
|
|
17
|
+
},
|
|
18
|
+
stage: 3,
|
|
19
|
+
}),
|
|
20
|
+
].concat((config === null || config === void 0 ? void 0 : config.extraPostCSSPlugins) || [])).process(css, {
|
|
21
|
+
from: path,
|
|
22
|
+
to: path,
|
|
31
23
|
});
|
|
32
24
|
}
|
|
33
25
|
exports.postcssProcess = postcssProcess;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-esbuild",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.15",
|
|
4
4
|
"description": "@umijs/bundler-esbuild",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-esbuild#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "pnpm tsc",
|
|
22
|
-
"build:deps": "
|
|
22
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
23
23
|
"dev": "pnpm build -- --watch",
|
|
24
|
-
"test": "
|
|
24
|
+
"test": "umi-scripts jest-turbo"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
28
|
-
"@umijs/utils": "4.0.0-rc.
|
|
27
|
+
"@umijs/bundler-utils": "4.0.0-rc.15",
|
|
28
|
+
"@umijs/utils": "4.0.0-rc.15",
|
|
29
29
|
"enhanced-resolve": "5.9.2",
|
|
30
30
|
"less-plugin-aliases": "^1.0.3",
|
|
31
31
|
"postcss": "^8.4.12",
|