@umijs/bundler-esbuild 4.0.0-beta.8 → 4.0.0-canary-20240513.3

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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build.d.ts +3 -2
  3. package/dist/build.js +97 -54
  4. package/dist/cli.js +63 -61
  5. package/dist/index.js +22 -12
  6. package/dist/plugins/__sample.js +30 -5
  7. package/dist/plugins/alias.js +89 -65
  8. package/dist/plugins/externals.d.ts +1 -1
  9. package/dist/plugins/externals.js +43 -21
  10. package/dist/plugins/less-plugin-alias/index.d.ts +9 -0
  11. package/dist/plugins/less-plugin-alias/index.js +100 -0
  12. package/dist/plugins/less-plugin-alias/types.d.ts +4 -0
  13. package/dist/plugins/less-plugin-alias/types.js +17 -0
  14. package/dist/plugins/less-plugin-alias/utils.d.ts +2 -0
  15. package/dist/plugins/less-plugin-alias/utils.js +60 -0
  16. package/dist/plugins/less.d.ts +7 -2
  17. package/dist/plugins/less.js +203 -49
  18. package/dist/plugins/nodeGlobalsPolyfill.js +36 -12
  19. package/dist/plugins/style.d.ts +17 -0
  20. package/dist/plugins/style.js +171 -0
  21. package/dist/plugins/watchRebuild.d.ts +4 -0
  22. package/dist/plugins/watchRebuild.js +67 -0
  23. package/dist/types.d.ts +11 -3
  24. package/dist/types.js +40 -13
  25. package/dist/utils/getBrowserlist.d.ts +1 -0
  26. package/dist/utils/getBrowserlist.js +33 -0
  27. package/dist/utils/postcssProcess.d.ts +2 -0
  28. package/dist/utils/postcssProcess.js +58 -0
  29. package/dist/utils/sortByAffix.js +38 -14
  30. package/package.json +28 -25
  31. package/dist/build.d.ts.map +0 -1
  32. package/dist/cli.d.ts.map +0 -1
  33. package/dist/index.d.ts.map +0 -1
  34. package/dist/plugins/__sample.d.ts.map +0 -1
  35. package/dist/plugins/alias.d.ts.map +0 -1
  36. package/dist/plugins/externals.d.ts.map +0 -1
  37. package/dist/plugins/less.d.ts.map +0 -1
  38. package/dist/plugins/nodeGlobalsPolyfill.d.ts.map +0 -1
  39. package/dist/types.d.ts.map +0 -1
  40. package/dist/utils/sortByAffix.d.ts.map +0 -1
@@ -1,22 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = (options) => {
4
- return {
5
- name: 'externals',
6
- setup({ onLoad, onResolve }) {
7
- if (!options || Object.keys(options).length === 0) {
8
- return;
9
- }
10
- Object.keys(options).forEach((key) => {
11
- onResolve({ filter: new RegExp(`^${key}$`) }, (args) => ({
12
- path: args.path,
13
- namespace: key,
14
- }));
15
- onLoad({ filter: /.*/, namespace: key }, () => ({
16
- contents: `module.export=${options[key]}`,
17
- loader: 'js',
18
- }));
19
- });
20
- },
21
- };
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/plugins/externals.ts
20
+ var externals_exports = {};
21
+ __export(externals_exports, {
22
+ default: () => externals_default
23
+ });
24
+ module.exports = __toCommonJS(externals_exports);
25
+ var externals_default = (options) => {
26
+ return {
27
+ name: "externals",
28
+ setup({ onLoad, onResolve }) {
29
+ if (!options || Object.keys(options).length === 0) {
30
+ return;
31
+ }
32
+ Object.keys(options).forEach((key) => {
33
+ onResolve({ filter: new RegExp(`^${key}$`) }, (args) => ({
34
+ path: args.path,
35
+ namespace: key
36
+ }));
37
+ onLoad({ filter: /.*/, namespace: key }, () => ({
38
+ contents: `module.export=${options[key]}`,
39
+ loader: "js"
40
+ }));
41
+ });
42
+ }
43
+ };
22
44
  };
@@ -0,0 +1,9 @@
1
+ interface Options {
2
+ alias: Record<string, string>;
3
+ }
4
+ export default class LessAliasPlugin {
5
+ private options;
6
+ constructor(options: Options);
7
+ install(less: LessStatic, pluginManager: Less.PluginManager): void;
8
+ }
9
+ export {};
@@ -0,0 +1,100 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/plugins/less-plugin-alias/index.ts
20
+ var less_plugin_alias_exports = {};
21
+ __export(less_plugin_alias_exports, {
22
+ default: () => LessAliasPlugin
23
+ });
24
+ module.exports = __toCommonJS(less_plugin_alias_exports);
25
+ var import_utils = require("@umijs/utils");
26
+ var import_utils2 = require("./utils");
27
+ function matches(pattern, importee) {
28
+ if (pattern instanceof RegExp) {
29
+ return pattern.test(importee);
30
+ }
31
+ if (importee.length < pattern.length) {
32
+ return false;
33
+ }
34
+ if (importee === pattern) {
35
+ return true;
36
+ }
37
+ return importee.startsWith(pattern + "/");
38
+ }
39
+ var LessAliasPlugin = class {
40
+ constructor(options) {
41
+ this.options = options;
42
+ }
43
+ install(less, pluginManager) {
44
+ const alias = (0, import_utils2.parseAlias)(this.options.alias);
45
+ function resolveId(filename) {
46
+ if (!filename) {
47
+ return null;
48
+ }
49
+ const matchedEntry = alias.find((entry) => matches(entry.find, filename));
50
+ if (!matchedEntry) {
51
+ return filename;
52
+ }
53
+ const resolvedPath = filename.replace(
54
+ matchedEntry.find,
55
+ matchedEntry.replacement
56
+ );
57
+ return resolvedPath;
58
+ }
59
+ class AliasePlugin extends less.FileManager {
60
+ loadFile(filename, currentDirectory, options, enviroment) {
61
+ let resolved;
62
+ try {
63
+ resolved = resolveId(filename);
64
+ } catch (error) {
65
+ import_utils.logger.error(error);
66
+ }
67
+ if (!resolved) {
68
+ const error = new Error(
69
+ `[less-plugin-alias]: '${filename}' not found.`
70
+ );
71
+ import_utils.logger.error(error);
72
+ throw error;
73
+ }
74
+ return super.loadFile(resolved, currentDirectory, options, enviroment);
75
+ }
76
+ loadFileSync(filename, currentDirectory, options, enviroment) {
77
+ let resolved;
78
+ try {
79
+ resolved = resolveId(filename);
80
+ } catch (error) {
81
+ import_utils.logger.error(error);
82
+ }
83
+ if (!resolved) {
84
+ const error = new Error(
85
+ `[less-plugin-alias]: '${filename}' not found.`
86
+ );
87
+ import_utils.logger.error(error);
88
+ throw error;
89
+ }
90
+ return super.loadFileSync(
91
+ resolved,
92
+ currentDirectory,
93
+ options,
94
+ enviroment
95
+ );
96
+ }
97
+ }
98
+ pluginManager.addFileManager(new AliasePlugin());
99
+ }
100
+ };
@@ -0,0 +1,4 @@
1
+ export interface Alias {
2
+ find: string | RegExp;
3
+ replacement: string;
4
+ }
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/plugins/less-plugin-alias/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,2 @@
1
+ import { Alias } from './types';
2
+ export declare function parseAlias(alias: Record<string, string>): Alias[];
@@ -0,0 +1,60 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/plugins/less-plugin-alias/utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ parseAlias: () => parseAlias
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
25
+ function hoistAlias(alias) {
26
+ function getFinalReplacement(oAlias, replacement, index) {
27
+ const newAlias = oAlias.slice();
28
+ newAlias.splice(index, 1);
29
+ for (let i = 0; i < newAlias.length; i++) {
30
+ if (newAlias[i].find.test(replacement)) {
31
+ replacement = replacement.replace(
32
+ newAlias[i].find,
33
+ newAlias[i].replacement
34
+ );
35
+ return getFinalReplacement(newAlias, replacement, i);
36
+ }
37
+ }
38
+ return replacement;
39
+ }
40
+ alias.forEach((rule, index, alias2) => {
41
+ rule.replacement = getFinalReplacement(alias2, rule.replacement, index);
42
+ });
43
+ return alias;
44
+ }
45
+ function parseAlias(alias) {
46
+ const wholeAlias = [
47
+ // to support less-loader ~ for local deps, refer: https://github.com/vitejs/vite/issues/2185
48
+ { find: /^~/, replacement: "" }
49
+ ];
50
+ const userAlias = Object.entries(alias).map(([name, target]) => ({
51
+ find: new RegExp(`^~?${name.replace(/(?<!\$)$/, "(?=/|$)")}`),
52
+ replacement: target
53
+ }));
54
+ wholeAlias.unshift(...userAlias);
55
+ return hoistAlias(wholeAlias);
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ parseAlias
60
+ });
@@ -1,4 +1,9 @@
1
- /// <reference types="less" />
2
1
  import { Plugin } from '@umijs/bundler-utils/compiled/esbuild';
3
- declare const _default: (options?: Less.Options) => Plugin;
2
+ import { IConfig } from '../types';
3
+ export declare const aliasLessImportPath: (filePath: string, alias: Record<string, string>, importer: string) => Promise<string | null>;
4
+ declare const _default: (options?: Less.Options & {
5
+ alias?: Record<string, string>;
6
+ inlineStyle?: boolean;
7
+ config?: IConfig;
8
+ }) => Plugin;
4
9
  export default _default;
@@ -1,53 +1,207 @@
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
- });
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
13
18
  };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const fs_1 = require("fs");
16
- const less_1 = __importDefault(require("less"));
17
- const path_1 = __importDefault(require("path"));
18
- exports.default = (options = {}) => {
19
- return {
20
- name: 'less',
21
- setup({ onLoad }) {
22
- onLoad({ filter: /\.less$/, namespace: 'file' }, (args) => __awaiter(this, void 0, void 0, function* () {
23
- const content = yield fs_1.promises.readFile(args.path, 'utf-8');
24
- const dir = path_1.default.dirname(args.path);
25
- const filename = path_1.default.basename(args.path);
26
- try {
27
- const result = yield less_1.default.render(content, Object.assign(Object.assign({ filename, rootpath: dir }, options), { paths: [...(options.paths || []), dir] }));
28
- return {
29
- contents: result.css,
30
- loader: 'css',
31
- resolveDir: dir,
32
- };
33
- }
34
- catch (error) {
35
- return {
36
- errors: [
37
- {
38
- text: error.message,
39
- location: {
40
- namespace: 'file',
41
- file: error.filename,
42
- line: error.line,
43
- column: error.column,
44
- },
45
- },
46
- ],
47
- resolveDir: dir,
48
- };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/plugins/less.ts
30
+ var less_exports = {};
31
+ __export(less_exports, {
32
+ aliasLessImportPath: () => aliasLessImportPath,
33
+ default: () => less_default
34
+ });
35
+ module.exports = __toCommonJS(less_exports);
36
+ var import_less = __toESM(require("@umijs/bundler-utils/compiled/less"));
37
+ var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
38
+ var import_fs = require("fs");
39
+ var import_path = __toESM(require("path"));
40
+ var import_postcssProcess = require("../utils/postcssProcess");
41
+ var import_sortByAffix = require("../utils/sortByAffix");
42
+ var import_less_plugin_alias = __toESM(require("./less-plugin-alias"));
43
+ var resolver = import_enhanced_resolve.default.create({
44
+ mainFields: ["module", "browser", "main"],
45
+ extensions: [
46
+ ".json",
47
+ ".js",
48
+ ".jsx",
49
+ ".ts",
50
+ ".tsx",
51
+ ".cjs",
52
+ ".mjs",
53
+ ".less",
54
+ ".css"
55
+ ],
56
+ // TODO: support exports
57
+ exportsFields: []
58
+ });
59
+ async function resolve(context, path2) {
60
+ return new Promise((resolve2, reject) => {
61
+ resolver(
62
+ context,
63
+ path2,
64
+ (err, result) => err ? reject(err) : resolve2(result)
65
+ );
66
+ });
67
+ }
68
+ var aliasLessImports = async (ctx, alias, importer) => {
69
+ const importRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/;
70
+ const globalImportRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/g;
71
+ const match = ctx.match(globalImportRegex) || [];
72
+ for (const el of match) {
73
+ const [imp, _, filePath] = el.match(importRegex) || [];
74
+ let aliaPath = await aliasLessImportPath(filePath, alias, importer);
75
+ if (aliaPath) {
76
+ ctx = ctx.replace(imp, el.replace(filePath, aliaPath));
77
+ }
78
+ }
79
+ return ctx;
80
+ };
81
+ var aliasLessImportPath = async (filePath, alias, importer) => {
82
+ let aliaPath = filePath.startsWith("~") ? filePath.replace("~", "") : filePath;
83
+ const keys = (0, import_sortByAffix.sortByAffix)({ arr: Object.keys(alias), affix: "$" });
84
+ for (const key of keys) {
85
+ const pathSegments = aliaPath.split("/");
86
+ if (pathSegments[0] === key) {
87
+ pathSegments[0] = alias[key];
88
+ aliaPath = pathSegments.join("/");
89
+ aliaPath = import_path.default.extname(aliaPath) ? aliaPath : `${aliaPath}.less`;
90
+ return await resolve(importer, aliaPath);
91
+ }
92
+ }
93
+ return null;
94
+ };
95
+ var less_default = (options = {}) => {
96
+ const { alias, inlineStyle, config, ...lessOptions } = options;
97
+ return {
98
+ name: "less",
99
+ setup({ onResolve, onLoad }) {
100
+ onResolve({ filter: /\.less$/, namespace: "file" }, async (args) => {
101
+ let filePath = args.path;
102
+ let isMatchedAlias = false;
103
+ if (!!alias) {
104
+ const aliasMatchPath = await aliasLessImportPath(
105
+ filePath,
106
+ alias,
107
+ args.path
108
+ );
109
+ if (aliasMatchPath) {
110
+ isMatchedAlias = true;
111
+ filePath = aliasMatchPath;
112
+ }
113
+ }
114
+ if (!isMatchedAlias) {
115
+ const isImportFromDeps = !import_path.default.isAbsolute(filePath) && !filePath.startsWith(".");
116
+ if (isImportFromDeps) {
117
+ filePath = await resolve(process.cwd(), filePath);
118
+ } else {
119
+ filePath = import_path.default.resolve(
120
+ process.cwd(),
121
+ import_path.default.relative(process.cwd(), args.resolveDir),
122
+ args.path
123
+ );
124
+ }
125
+ }
126
+ return {
127
+ path: filePath,
128
+ namespace: inlineStyle ? "less-file" : "file"
129
+ };
130
+ });
131
+ if (inlineStyle) {
132
+ onResolve({ filter: /\.less$/, namespace: "less-file" }, (args) => {
133
+ return { path: args.path, namespace: "less-content" };
134
+ });
135
+ onResolve(
136
+ { filter: /^__style_helper__$/, namespace: "less-file" },
137
+ (args) => ({
138
+ path: args.path,
139
+ namespace: "style-helper",
140
+ sideEffects: false
141
+ })
142
+ );
143
+ onLoad({ filter: /.*/, namespace: "less-file" }, async (args) => ({
144
+ contents: `
145
+ import { injectStyle } from "__style_helper__"
146
+ import css from ${JSON.stringify(args.path)}
147
+ injectStyle(css)
148
+ export default{}
149
+ `
150
+ }));
151
+ }
152
+ onLoad(
153
+ { filter: /\.less$/, namespace: inlineStyle ? "less-content" : "file" },
154
+ async (args) => {
155
+ let content = await import_fs.promises.readFile(args.path, "utf-8");
156
+ if (!!alias) {
157
+ content = await aliasLessImports(content, alias, args.path);
158
+ }
159
+ const dir = import_path.default.dirname(args.path);
160
+ const filename = import_path.default.basename(args.path);
161
+ try {
162
+ const result = await import_less.default.render(content, {
163
+ plugins: [
164
+ new import_less_plugin_alias.default({
165
+ alias: alias || {}
166
+ })
167
+ ],
168
+ filename,
169
+ rootpath: dir,
170
+ ...lessOptions,
171
+ paths: [...lessOptions.paths || [], dir]
172
+ });
173
+ const postcssrResult = await (0, import_postcssProcess.postcssProcess)(
174
+ config,
175
+ result.css,
176
+ args.path
177
+ );
178
+ return {
179
+ contents: postcssrResult.css,
180
+ loader: inlineStyle ? "text" : "css",
181
+ resolveDir: dir
182
+ };
183
+ } catch (error) {
184
+ return {
185
+ errors: [
186
+ {
187
+ text: error.message,
188
+ location: {
189
+ namespace: "file",
190
+ file: error.filename,
191
+ line: error.line,
192
+ column: error.column
193
+ }
49
194
  }
50
- }));
51
- },
52
- };
195
+ ],
196
+ resolveDir: dir
197
+ };
198
+ }
199
+ }
200
+ );
201
+ }
202
+ };
53
203
  };
204
+ // Annotate the CommonJS export names for ESM import in node:
205
+ 0 && (module.exports = {
206
+ aliasLessImportPath
207
+ });
@@ -1,14 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.nodeGlobalsPolyfill = void 0;
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/plugins/nodeGlobalsPolyfill.ts
20
+ var nodeGlobalsPolyfill_exports = {};
21
+ __export(nodeGlobalsPolyfill_exports, {
22
+ nodeGlobalsPolyfill: () => nodeGlobalsPolyfill
23
+ });
24
+ module.exports = __toCommonJS(nodeGlobalsPolyfill_exports);
4
25
  function nodeGlobalsPolyfill() {
5
- return {
6
- name: 'node-globals-polyfill',
7
- setup({ initialOptions, onResolve, onLoad }) {
8
- onResolve;
9
- onLoad;
10
- initialOptions.inject || (initialOptions.inject = []);
11
- },
12
- };
26
+ return {
27
+ name: "node-globals-polyfill",
28
+ setup({ initialOptions, onResolve, onLoad }) {
29
+ onResolve;
30
+ onLoad;
31
+ initialOptions.inject || (initialOptions.inject = []);
32
+ }
33
+ };
13
34
  }
14
- exports.nodeGlobalsPolyfill = nodeGlobalsPolyfill;
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ nodeGlobalsPolyfill
38
+ });
@@ -0,0 +1,17 @@
1
+ import { Charset, Plugin } from '@umijs/bundler-utils/compiled/esbuild';
2
+ import { IConfig } from '../types';
3
+ export interface StylePluginOptions {
4
+ /**
5
+ * whether to minify the css code.
6
+ * @default true
7
+ */
8
+ minify?: boolean;
9
+ /**
10
+ * css charset.
11
+ * @default 'utf8'
12
+ */
13
+ charset?: Charset;
14
+ inlineStyle?: boolean;
15
+ config?: IConfig;
16
+ }
17
+ export declare function style({ minify, charset, inlineStyle, config, }?: StylePluginOptions): Plugin;