@umijs/bundler-esbuild 4.0.42 → 4.0.43

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 CHANGED
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
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));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/build.ts
package/dist/cli.js CHANGED
@@ -12,7 +12,10 @@ var __copyProps = (to, from, except, desc) => {
12
12
  }
13
13
  return to;
14
14
  };
15
- 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));
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
17
+ mod
18
+ ));
16
19
 
17
20
  // src/cli.ts
18
21
  var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
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));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/plugins/alias.ts
@@ -35,7 +38,11 @@ var resolver = import_enhanced_resolve.default.create({
35
38
  });
36
39
  async function resolve(context, path) {
37
40
  return new Promise((resolve2, reject) => {
38
- resolver(context, path, (err, result) => err ? reject(err) : resolve2(result));
41
+ resolver(
42
+ context,
43
+ path,
44
+ (err, result) => err ? reject(err) : resolve2(result)
45
+ );
39
46
  });
40
47
  }
41
48
  var alias_default = (options = {}) => {
@@ -52,7 +59,10 @@ var alias_default = (options = {}) => {
52
59
  filter = new RegExp(`^${key}$`);
53
60
  }
54
61
  onResolve({ filter }, async (args) => {
55
- const path = await resolve(args.importer, args.path.replace(filter, value));
62
+ const path = await resolve(
63
+ args.importer,
64
+ args.path.replace(filter, value)
65
+ );
56
66
  return {
57
67
  path
58
68
  };
@@ -60,7 +70,10 @@ var alias_default = (options = {}) => {
60
70
  if (!key.endsWith("/") && (0, import_fs.existsSync)(value) && (0, import_fs.statSync)(value).isDirectory()) {
61
71
  const filter2 = new RegExp(`^${addSlashAffix(key)}`);
62
72
  onResolve({ filter: filter2 }, async (args) => {
63
- const path = await resolve(args.importer, args.path.replace(filter2, addSlashAffix(value)));
73
+ const path = await resolve(
74
+ args.importer,
75
+ args.path.replace(filter2, addSlashAffix(value))
76
+ );
64
77
  return {
65
78
  path
66
79
  };
@@ -50,7 +50,10 @@ var LessAliasPlugin = class {
50
50
  if (!matchedEntry) {
51
51
  return filename;
52
52
  }
53
- const resolvedPath = filename.replace(matchedEntry.find, matchedEntry.replacement);
53
+ const resolvedPath = filename.replace(
54
+ matchedEntry.find,
55
+ matchedEntry.replacement
56
+ );
54
57
  return resolvedPath;
55
58
  }
56
59
  class AliasePlugin extends less.FileManager {
@@ -62,7 +65,9 @@ var LessAliasPlugin = class {
62
65
  import_utils.logger.error(error);
63
66
  }
64
67
  if (!resolved) {
65
- const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
68
+ const error = new Error(
69
+ `[less-plugin-alias]: '${filename}' not found.`
70
+ );
66
71
  import_utils.logger.error(error);
67
72
  throw error;
68
73
  }
@@ -76,11 +81,18 @@ var LessAliasPlugin = class {
76
81
  import_utils.logger.error(error);
77
82
  }
78
83
  if (!resolved) {
79
- const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
84
+ const error = new Error(
85
+ `[less-plugin-alias]: '${filename}' not found.`
86
+ );
80
87
  import_utils.logger.error(error);
81
88
  throw error;
82
89
  }
83
- return super.loadFileSync(resolved, currentDirectory, options, enviroment);
90
+ return super.loadFileSync(
91
+ resolved,
92
+ currentDirectory,
93
+ options,
94
+ enviroment
95
+ );
84
96
  }
85
97
  }
86
98
  pluginManager.addFileManager(new AliasePlugin());
@@ -28,7 +28,10 @@ function hoistAlias(alias) {
28
28
  newAlias.splice(index, 1);
29
29
  for (let i = 0; i < newAlias.length; i++) {
30
30
  if (newAlias[i].find.test(replacement)) {
31
- replacement = replacement.replace(newAlias[i].find, newAlias[i].replacement);
31
+ replacement = replacement.replace(
32
+ newAlias[i].find,
33
+ newAlias[i].replacement
34
+ );
32
35
  return getFinalReplacement(newAlias, replacement, i);
33
36
  }
34
37
  }
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
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));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/plugins/less.ts
@@ -50,7 +53,11 @@ var resolver = import_enhanced_resolve.default.create({
50
53
  });
51
54
  async function resolve(context, path2) {
52
55
  return new Promise((resolve2, reject) => {
53
- resolver(context, path2, (err, result) => err ? reject(err) : resolve2(result));
56
+ resolver(
57
+ context,
58
+ path2,
59
+ (err, result) => err ? reject(err) : resolve2(result)
60
+ );
54
61
  });
55
62
  }
56
63
  var aliasLessImports = async (ctx, alias, importer) => {
@@ -89,7 +96,11 @@ var less_default = (options = {}) => {
89
96
  let filePath = args.path;
90
97
  let isMatchedAlias = false;
91
98
  if (!!alias) {
92
- const aliasMatchPath = await aliasLessImportPath(filePath, alias, args.path);
99
+ const aliasMatchPath = await aliasLessImportPath(
100
+ filePath,
101
+ alias,
102
+ args.path
103
+ );
93
104
  if (aliasMatchPath) {
94
105
  isMatchedAlias = true;
95
106
  filePath = aliasMatchPath;
@@ -100,7 +111,11 @@ var less_default = (options = {}) => {
100
111
  if (isImportFromDeps) {
101
112
  filePath = await resolve(process.cwd(), filePath);
102
113
  } else {
103
- filePath = import_path.default.resolve(process.cwd(), import_path.default.relative(process.cwd(), args.resolveDir), args.path);
114
+ filePath = import_path.default.resolve(
115
+ process.cwd(),
116
+ import_path.default.relative(process.cwd(), args.resolveDir),
117
+ args.path
118
+ );
104
119
  }
105
120
  }
106
121
  return {
@@ -112,11 +127,14 @@ var less_default = (options = {}) => {
112
127
  onResolve({ filter: /\.less$/, namespace: "less-file" }, (args) => {
113
128
  return { path: args.path, namespace: "less-content" };
114
129
  });
115
- onResolve({ filter: /^__style_helper__$/, namespace: "less-file" }, (args) => ({
116
- path: args.path,
117
- namespace: "style-helper",
118
- sideEffects: false
119
- }));
130
+ onResolve(
131
+ { filter: /^__style_helper__$/, namespace: "less-file" },
132
+ (args) => ({
133
+ path: args.path,
134
+ namespace: "style-helper",
135
+ sideEffects: false
136
+ })
137
+ );
120
138
  onLoad({ filter: /.*/, namespace: "less-file" }, async (args) => ({
121
139
  contents: `
122
140
  import { injectStyle } from "__style_helper__"
@@ -126,48 +144,55 @@ var less_default = (options = {}) => {
126
144
  `
127
145
  }));
128
146
  }
129
- onLoad({ filter: /\.less$/, namespace: inlineStyle ? "less-content" : "file" }, async (args) => {
130
- let content = await import_fs.promises.readFile(args.path, "utf-8");
131
- if (!!alias) {
132
- content = await aliasLessImports(content, alias, args.path);
133
- }
134
- const dir = import_path.default.dirname(args.path);
135
- const filename = import_path.default.basename(args.path);
136
- try {
137
- const result = await import_less.default.render(content, {
138
- plugins: [
139
- new import_less_plugin_alias.default({
140
- alias: alias || {}
141
- })
142
- ],
143
- filename,
144
- rootpath: dir,
145
- ...lessOptions,
146
- paths: [...lessOptions.paths || [], dir]
147
- });
148
- const postcssrResult = await (0, import_postcssProcess.postcssProcess)(config, result.css, args.path);
149
- return {
150
- contents: postcssrResult.css,
151
- loader: inlineStyle ? "text" : "css",
152
- resolveDir: dir
153
- };
154
- } catch (error) {
155
- return {
156
- errors: [
157
- {
158
- text: error.message,
159
- location: {
160
- namespace: "file",
161
- file: error.filename,
162
- line: error.line,
163
- column: error.column
147
+ onLoad(
148
+ { filter: /\.less$/, namespace: inlineStyle ? "less-content" : "file" },
149
+ async (args) => {
150
+ let content = await import_fs.promises.readFile(args.path, "utf-8");
151
+ if (!!alias) {
152
+ content = await aliasLessImports(content, alias, args.path);
153
+ }
154
+ const dir = import_path.default.dirname(args.path);
155
+ const filename = import_path.default.basename(args.path);
156
+ try {
157
+ const result = await import_less.default.render(content, {
158
+ plugins: [
159
+ new import_less_plugin_alias.default({
160
+ alias: alias || {}
161
+ })
162
+ ],
163
+ filename,
164
+ rootpath: dir,
165
+ ...lessOptions,
166
+ paths: [...lessOptions.paths || [], dir]
167
+ });
168
+ const postcssrResult = await (0, import_postcssProcess.postcssProcess)(
169
+ config,
170
+ result.css,
171
+ args.path
172
+ );
173
+ return {
174
+ contents: postcssrResult.css,
175
+ loader: inlineStyle ? "text" : "css",
176
+ resolveDir: dir
177
+ };
178
+ } catch (error) {
179
+ return {
180
+ errors: [
181
+ {
182
+ text: error.message,
183
+ location: {
184
+ namespace: "file",
185
+ file: error.filename,
186
+ line: error.line,
187
+ column: error.column
188
+ }
164
189
  }
165
- }
166
- ],
167
- resolveDir: dir
168
- };
190
+ ],
191
+ resolveDir: dir
192
+ };
193
+ }
169
194
  }
170
- });
195
+ );
171
196
  }
172
197
  };
173
198
  };
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
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));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/plugins/style.ts
@@ -62,7 +65,11 @@ function style({
62
65
  }
63
66
  };
64
67
  onResolve({ filter: /\.css$/, namespace: "file" }, (args) => {
65
- const absPath = import_path.default.resolve(cwd, import_path.default.relative(cwd, args.resolveDir), args.path);
68
+ const absPath = import_path.default.resolve(
69
+ cwd,
70
+ import_path.default.relative(cwd, args.resolveDir),
71
+ args.path
72
+ );
66
73
  const resolved = import_fs.default.existsSync(absPath) ? absPath : import_utils.resolve.sync(`${args.path}`, {
67
74
  basedir: args.resolveDir
68
75
  });
@@ -72,11 +79,14 @@ function style({
72
79
  onResolve({ filter: /\.css$/, namespace: "style-stub" }, (args) => {
73
80
  return { path: args.path, namespace: "style-content" };
74
81
  });
75
- onResolve({ filter: /^__style_helper__$/, namespace: "style-stub" }, (args) => ({
76
- path: args.path,
77
- namespace: "style-helper",
78
- sideEffects: false
79
- }));
82
+ onResolve(
83
+ { filter: /^__style_helper__$/, namespace: "style-stub" },
84
+ (args) => ({
85
+ path: args.path,
86
+ namespace: "style-helper",
87
+ sideEffects: false
88
+ })
89
+ );
80
90
  onLoad({ filter: /.*/, namespace: "style-helper" }, async () => ({
81
91
  contents: `
82
92
  export function injectStyle(text) {
@@ -97,46 +107,55 @@ function style({
97
107
  `
98
108
  }));
99
109
  }
100
- onLoad({
101
- filter: inlineStyle ? /.*/ : /\.css$/,
102
- namespace: inlineStyle ? "style-content" : "file"
103
- }, async (args) => {
104
- const options = { entryPoints: [args.path], ...opt };
105
- const { errors, warnings, outputFiles } = await import_esbuild.default.build(options);
106
- if (errors.length > 0) {
107
- return {
108
- errors,
109
- warnings,
110
- contents: outputFiles[0].text,
111
- loader: "text"
112
- };
113
- }
114
- const dir = import_path.default.dirname(args.path);
115
- try {
116
- const result = await (0, import_postcssProcess.postcssProcess)(config, outputFiles[0].text, args.path);
117
- return {
118
- errors,
119
- warnings,
120
- contents: result.css,
121
- loader: inlineStyle ? "text" : "css"
122
- };
123
- } catch (error) {
124
- return {
125
- errors: [
126
- {
127
- text: error.message,
128
- location: {
129
- namespace: "file",
130
- file: error.filename,
131
- line: error.line,
132
- column: error.column
110
+ onLoad(
111
+ {
112
+ filter: inlineStyle ? /.*/ : /\.css$/,
113
+ namespace: inlineStyle ? "style-content" : "file"
114
+ },
115
+ async (args) => {
116
+ const options = { entryPoints: [args.path], ...opt };
117
+ const { errors, warnings, outputFiles } = await import_esbuild.default.build(
118
+ options
119
+ );
120
+ if (errors.length > 0) {
121
+ return {
122
+ errors,
123
+ warnings,
124
+ contents: outputFiles[0].text,
125
+ loader: "text"
126
+ };
127
+ }
128
+ const dir = import_path.default.dirname(args.path);
129
+ try {
130
+ const result = await (0, import_postcssProcess.postcssProcess)(
131
+ config,
132
+ outputFiles[0].text,
133
+ args.path
134
+ );
135
+ return {
136
+ errors,
137
+ warnings,
138
+ contents: result.css,
139
+ loader: inlineStyle ? "text" : "css"
140
+ };
141
+ } catch (error) {
142
+ return {
143
+ errors: [
144
+ {
145
+ text: error.message,
146
+ location: {
147
+ namespace: "file",
148
+ file: error.filename,
149
+ line: error.line,
150
+ column: error.column
151
+ }
133
152
  }
134
- }
135
- ],
136
- resolveDir: dir
137
- };
153
+ ],
154
+ resolveDir: dir
155
+ };
156
+ }
138
157
  }
139
- });
158
+ );
140
159
  }
141
160
  };
142
161
  }
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
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));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/utils/postcssProcess.ts
@@ -28,17 +31,19 @@ module.exports = __toCommonJS(postcssProcess_exports);
28
31
  var import_postcss = __toESM(require("postcss"));
29
32
  var import_getBrowserlist = require("./getBrowserlist");
30
33
  async function postcssProcess(config, css, path) {
31
- return await (0, import_postcss.default)([
32
- require("postcss-flexbugs-fixes"),
33
- require("postcss-preset-env")({
34
- browsers: (0, import_getBrowserlist.getBrowserlist)((config == null ? void 0 : config.targets) || {}),
35
- autoprefixer: {
36
- flexbox: "no-2009",
37
- ...config == null ? void 0 : config.autoprefixer
38
- },
39
- stage: 3
40
- })
41
- ].concat((config == null ? void 0 : config.extraPostCSSPlugins) || [])).process(css, {
34
+ return await (0, import_postcss.default)(
35
+ [
36
+ require("postcss-flexbugs-fixes"),
37
+ require("postcss-preset-env")({
38
+ browsers: (0, import_getBrowserlist.getBrowserlist)((config == null ? void 0 : config.targets) || {}),
39
+ autoprefixer: {
40
+ flexbox: "no-2009",
41
+ ...config == null ? void 0 : config.autoprefixer
42
+ },
43
+ stage: 3
44
+ })
45
+ ].concat((config == null ? void 0 : config.extraPostCSSPlugins) || [])
46
+ ).process(css, {
42
47
  from: path,
43
48
  to: path
44
49
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-esbuild",
3
- "version": "4.0.42",
3
+ "version": "4.0.43",
4
4
  "description": "@umijs/bundler-esbuild",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-esbuild#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -24,10 +24,10 @@
24
24
  "test": "umi-scripts jest-turbo"
25
25
  },
26
26
  "dependencies": {
27
- "@umijs/bundler-utils": "4.0.42",
28
- "@umijs/utils": "4.0.42",
27
+ "@umijs/bundler-utils": "4.0.43",
28
+ "@umijs/utils": "4.0.43",
29
29
  "enhanced-resolve": "5.9.3",
30
- "postcss": "^8.4.13",
30
+ "postcss": "^8.4.21",
31
31
  "postcss-flexbugs-fixes": "5.0.2",
32
32
  "postcss-preset-env": "7.5.0"
33
33
  },