@umijs/bundler-esbuild 4.0.5 → 4.0.8

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.
@@ -1,70 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("@umijs/utils");
4
- const utils_2 = require("./utils");
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
+ // 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");
5
27
  function matches(pattern, importee) {
6
- if (pattern instanceof RegExp) {
7
- return pattern.test(importee);
8
- }
9
- if (importee.length < pattern.length) {
10
- return false;
11
- }
12
- if (importee === pattern) {
13
- return true;
14
- }
15
- return importee.startsWith(pattern + '/');
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 + "/");
16
38
  }
17
- class LessAliasPlugin {
18
- constructor(options) {
19
- this.options = options;
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(matchedEntry.find, matchedEntry.replacement);
54
+ return resolvedPath;
20
55
  }
21
- install(less, pluginManager) {
22
- const alias = (0, utils_2.parseAlias)(this.options.alias);
23
- function resolveId(filename) {
24
- if (!filename) {
25
- return null;
26
- }
27
- // First match is supposed to be the correct one
28
- const matchedEntry = alias.find((entry) => matches(entry.find, filename));
29
- if (!matchedEntry) {
30
- return filename;
31
- }
32
- const resolvedPath = filename.replace(matchedEntry.find, matchedEntry.replacement);
33
- return resolvedPath;
56
+ class AliasePlugin extends less.FileManager {
57
+ loadFile(filename, currentDirectory, options, enviroment) {
58
+ let resolved;
59
+ try {
60
+ resolved = resolveId(filename);
61
+ } catch (error) {
62
+ import_utils.logger.error(error);
34
63
  }
35
- class AliasePlugin extends less.FileManager {
36
- loadFile(filename, currentDirectory, options, enviroment) {
37
- let resolved;
38
- try {
39
- resolved = resolveId(filename);
40
- }
41
- catch (error) {
42
- utils_1.logger.error(error);
43
- }
44
- if (!resolved) {
45
- const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
46
- utils_1.logger.error(error);
47
- throw error;
48
- }
49
- return super.loadFile(resolved, currentDirectory, options, enviroment);
50
- }
51
- loadFileSync(filename, currentDirectory, options, enviroment) {
52
- let resolved;
53
- try {
54
- resolved = resolveId(filename);
55
- }
56
- catch (error) {
57
- utils_1.logger.error(error);
58
- }
59
- if (!resolved) {
60
- const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
61
- utils_1.logger.error(error);
62
- throw error;
63
- }
64
- return super.loadFileSync(resolved, currentDirectory, options, enviroment);
65
- }
64
+ if (!resolved) {
65
+ const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
66
+ import_utils.logger.error(error);
67
+ throw error;
66
68
  }
67
- pluginManager.addFileManager(new AliasePlugin());
69
+ return super.loadFile(resolved, currentDirectory, options, enviroment);
70
+ }
71
+ loadFileSync(filename, currentDirectory, options, enviroment) {
72
+ let resolved;
73
+ try {
74
+ resolved = resolveId(filename);
75
+ } catch (error) {
76
+ import_utils.logger.error(error);
77
+ }
78
+ if (!resolved) {
79
+ const error = new Error(`[less-plugin-alias]: '${filename}' not found.`);
80
+ import_utils.logger.error(error);
81
+ throw error;
82
+ }
83
+ return super.loadFileSync(resolved, currentDirectory, options, enviroment);
84
+ }
68
85
  }
69
- }
70
- exports.default = LessAliasPlugin;
86
+ pluginManager.addFileManager(new AliasePlugin());
87
+ }
88
+ };
89
+ // Annotate the CommonJS export names for ESM import in node:
90
+ 0 && (module.exports = {});
File without changes
@@ -1,2 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
+ // types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
File without changes
@@ -1,35 +1,56 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseAlias = 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
+ // utils.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ parseAlias: () => parseAlias
23
+ });
24
+ module.exports = __toCommonJS(utils_exports);
4
25
  function hoistAlias(alias) {
5
- function getFinalReplacement(oAlias, replacement, index) {
6
- //过滤重复配置,防止死循环
7
- const newAlias = oAlias.slice();
8
- newAlias.splice(index, 1);
9
- //遍历找到需要深层替换的配置
10
- for (let i = 0; i < newAlias.length; i++) {
11
- if (newAlias[i].find.test(replacement)) {
12
- replacement = replacement.replace(newAlias[i].find, newAlias[i].replacement);
13
- return getFinalReplacement(newAlias, replacement, i);
14
- }
15
- }
16
- return replacement;
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(newAlias[i].find, newAlias[i].replacement);
32
+ return getFinalReplacement(newAlias, replacement, i);
33
+ }
17
34
  }
18
- alias.forEach((rule, index, alias) => {
19
- rule.replacement = getFinalReplacement(alias, rule.replacement, index);
20
- });
21
- return alias;
35
+ return replacement;
36
+ }
37
+ alias.forEach((rule, index, alias2) => {
38
+ rule.replacement = getFinalReplacement(alias2, rule.replacement, index);
39
+ });
40
+ return alias;
22
41
  }
23
42
  function parseAlias(alias) {
24
- const wholeAlias = [
25
- // to support less-loader ~ for local deps, refer: https://github.com/vitejs/vite/issues/2185
26
- { find: /^~/, replacement: '' },
27
- ];
28
- const userAlias = Object.entries(alias).map(([name, target]) => ({
29
- find: new RegExp(`^~?${name.replace(/(?<!\$)$/, '(?=/|$)')}`),
30
- replacement: target,
31
- }));
32
- wholeAlias.unshift(...userAlias);
33
- return hoistAlias(wholeAlias);
43
+ const wholeAlias = [
44
+ { find: /^~/, replacement: "" }
45
+ ];
46
+ const userAlias = Object.entries(alias).map(([name, target]) => ({
47
+ find: new RegExp(`^~?${name.replace(/(?<!\$)$/, "(?=/|$)")}`),
48
+ replacement: target
49
+ }));
50
+ wholeAlias.unshift(...userAlias);
51
+ return hoistAlias(wholeAlias);
34
52
  }
35
- exports.parseAlias = parseAlias;
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ parseAlias
56
+ });
File without changes
@@ -1,160 +1,206 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __objRest = (source, exclude) => {
25
+ var target = {};
26
+ for (var prop in source)
27
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
28
+ target[prop] = source[prop];
29
+ if (source != null && __getOwnPropSymbols)
30
+ for (var prop of __getOwnPropSymbols(source)) {
31
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
32
+ target[prop] = source[prop];
33
+ }
34
+ return target;
35
+ };
36
+ var __export = (target, all) => {
37
+ for (var name in all)
38
+ __defProp(target, name, { get: all[name], enumerable: true });
39
+ };
40
+ var __copyProps = (to, from, except, desc) => {
41
+ if (from && typeof from === "object" || typeof from === "function") {
42
+ for (let key of __getOwnPropNames(from))
43
+ if (!__hasOwnProp.call(to, key) && key !== except)
44
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
45
+ }
46
+ return to;
4
47
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.aliasLessImportPath = void 0;
7
- const less_1 = __importDefault(require("@umijs/bundler-utils/compiled/less"));
8
- const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
9
- const fs_1 = require("fs");
10
- const path_1 = __importDefault(require("path"));
11
- const postcssProcess_1 = require("../utils/postcssProcess");
12
- const sortByAffix_1 = require("../utils/sortByAffix");
13
- const less_plugin_alias_1 = __importDefault(require("./less-plugin-alias"));
14
- const resolver = enhanced_resolve_1.default.create({
15
- mainFields: ['module', 'browser', 'main'],
16
- extensions: [
17
- '.json',
18
- '.js',
19
- '.jsx',
20
- '.ts',
21
- '.tsx',
22
- '.cjs',
23
- '.mjs',
24
- '.less',
25
- '.css',
26
- ],
27
- // TODO: support exports
28
- exportsFields: [],
48
+ 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));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
50
+
51
+ // less.ts
52
+ var less_exports = {};
53
+ __export(less_exports, {
54
+ aliasLessImportPath: () => aliasLessImportPath,
55
+ default: () => less_default
29
56
  });
30
- async function resolve(context, path) {
31
- return new Promise((resolve, reject) => {
32
- resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
33
- });
57
+ module.exports = __toCommonJS(less_exports);
58
+ var import_less = __toESM(require("@umijs/bundler-utils/compiled/less"));
59
+ var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
60
+ var import_fs = require("fs");
61
+ var import_path = __toESM(require("path"));
62
+ var import_postcssProcess = require("../utils/postcssProcess");
63
+ var import_sortByAffix = require("../utils/sortByAffix");
64
+ var import_less_plugin_alias = __toESM(require("./less-plugin-alias"));
65
+ var resolver = import_enhanced_resolve.default.create({
66
+ mainFields: ["module", "browser", "main"],
67
+ extensions: [
68
+ ".json",
69
+ ".js",
70
+ ".jsx",
71
+ ".ts",
72
+ ".tsx",
73
+ ".cjs",
74
+ ".mjs",
75
+ ".less",
76
+ ".css"
77
+ ],
78
+ exportsFields: []
79
+ });
80
+ async function resolve(context, path2) {
81
+ return new Promise((resolve2, reject) => {
82
+ resolver(context, path2, (err, result) => err ? reject(err) : resolve2(result));
83
+ });
34
84
  }
35
- const aliasLessImports = async (ctx, alias, importer) => {
36
- const importRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/;
37
- const globalImportRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/g;
38
- const match = ctx.match(globalImportRegex) || [];
39
- for (const el of match) {
40
- const [imp, _, filePath] = el.match(importRegex) || [];
41
- let aliaPath = await (0, exports.aliasLessImportPath)(filePath, alias, importer);
42
- if (aliaPath) {
43
- ctx = ctx.replace(imp, el.replace(filePath, aliaPath));
44
- }
85
+ var aliasLessImports = async (ctx, alias, importer) => {
86
+ const importRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/;
87
+ const globalImportRegex = /@import(?:\s+\((.*)\))?\s+['"](.*)['"]/g;
88
+ const match = ctx.match(globalImportRegex) || [];
89
+ for (const el of match) {
90
+ const [imp, _, filePath] = el.match(importRegex) || [];
91
+ let aliaPath = await aliasLessImportPath(filePath, alias, importer);
92
+ if (aliaPath) {
93
+ ctx = ctx.replace(imp, el.replace(filePath, aliaPath));
45
94
  }
46
- return ctx;
95
+ }
96
+ return ctx;
47
97
  };
48
- const aliasLessImportPath = async (filePath, alias, importer) => {
49
- // 写法在 esbuild 中无实际意义
50
- let aliaPath = filePath.startsWith('~')
51
- ? filePath.replace('~', '')
52
- : filePath;
53
- const keys = (0, sortByAffix_1.sortByAffix)({ arr: Object.keys(alias), affix: '$' });
54
- for (const key of keys) {
55
- const pathSegments = aliaPath.split('/');
56
- if (pathSegments[0] === key) {
57
- pathSegments[0] = alias[key];
58
- aliaPath = pathSegments.join('/');
59
- aliaPath = path_1.default.extname(aliaPath) ? aliaPath : `${aliaPath}.less`;
60
- return await resolve(importer, aliaPath);
61
- }
98
+ var aliasLessImportPath = async (filePath, alias, importer) => {
99
+ let aliaPath = filePath.startsWith("~") ? filePath.replace("~", "") : filePath;
100
+ const keys = (0, import_sortByAffix.sortByAffix)({ arr: Object.keys(alias), affix: "$" });
101
+ for (const key of keys) {
102
+ const pathSegments = aliaPath.split("/");
103
+ if (pathSegments[0] === key) {
104
+ pathSegments[0] = alias[key];
105
+ aliaPath = pathSegments.join("/");
106
+ aliaPath = import_path.default.extname(aliaPath) ? aliaPath : `${aliaPath}.less`;
107
+ return await resolve(importer, aliaPath);
62
108
  }
63
- return null;
109
+ }
110
+ return null;
64
111
  };
65
- exports.aliasLessImportPath = aliasLessImportPath;
66
- exports.default = (options = {}) => {
67
- const { alias, inlineStyle, config, ...lessOptions } = options;
68
- return {
69
- name: 'less',
70
- setup({ onResolve, onLoad }) {
71
- onResolve({ filter: /\.less$/, namespace: 'file' }, async (args) => {
72
- let filePath = args.path;
73
- let isMatchedAlias = false;
74
- // first match alias
75
- if (!!alias) {
76
- const aliasMatchPath = await (0, exports.aliasLessImportPath)(filePath, alias, args.path);
77
- if (aliasMatchPath) {
78
- isMatchedAlias = true;
79
- filePath = aliasMatchPath;
80
- }
81
- }
82
- // if alias not matched, identify whether import from deps (node_modules)
83
- if (!isMatchedAlias) {
84
- const isImportFromDeps = !path_1.default.isAbsolute(filePath) && !filePath.startsWith('.');
85
- if (isImportFromDeps) {
86
- filePath = await resolve(process.cwd(), filePath);
87
- }
88
- else {
89
- filePath = path_1.default.resolve(process.cwd(), path_1.default.relative(process.cwd(), args.resolveDir), args.path);
90
- }
91
- }
92
- return {
93
- path: filePath,
94
- namespace: inlineStyle ? 'less-file' : 'file',
95
- };
96
- });
97
- if (inlineStyle) {
98
- onResolve({ filter: /\.less$/, namespace: 'less-file' }, (args) => {
99
- return { path: args.path, namespace: 'less-content' };
100
- });
101
- onResolve({ filter: /^__style_helper__$/, namespace: 'less-file' }, (args) => ({
102
- path: args.path,
103
- namespace: 'style-helper',
104
- sideEffects: false,
105
- }));
106
- onLoad({ filter: /.*/, namespace: 'less-file' }, async (args) => ({
107
- contents: `
112
+ var less_default = (options = {}) => {
113
+ const _a = options, { alias, inlineStyle, config } = _a, lessOptions = __objRest(_a, ["alias", "inlineStyle", "config"]);
114
+ return {
115
+ name: "less",
116
+ setup({ onResolve, onLoad }) {
117
+ onResolve({ filter: /\.less$/, namespace: "file" }, async (args) => {
118
+ let filePath = args.path;
119
+ let isMatchedAlias = false;
120
+ if (!!alias) {
121
+ const aliasMatchPath = await aliasLessImportPath(filePath, alias, args.path);
122
+ if (aliasMatchPath) {
123
+ isMatchedAlias = true;
124
+ filePath = aliasMatchPath;
125
+ }
126
+ }
127
+ if (!isMatchedAlias) {
128
+ const isImportFromDeps = !import_path.default.isAbsolute(filePath) && !filePath.startsWith(".");
129
+ if (isImportFromDeps) {
130
+ filePath = await resolve(process.cwd(), filePath);
131
+ } else {
132
+ filePath = import_path.default.resolve(process.cwd(), import_path.default.relative(process.cwd(), args.resolveDir), args.path);
133
+ }
134
+ }
135
+ return {
136
+ path: filePath,
137
+ namespace: inlineStyle ? "less-file" : "file"
138
+ };
139
+ });
140
+ if (inlineStyle) {
141
+ onResolve({ filter: /\.less$/, namespace: "less-file" }, (args) => {
142
+ return { path: args.path, namespace: "less-content" };
143
+ });
144
+ onResolve({ filter: /^__style_helper__$/, namespace: "less-file" }, (args) => ({
145
+ path: args.path,
146
+ namespace: "style-helper",
147
+ sideEffects: false
148
+ }));
149
+ onLoad({ filter: /.*/, namespace: "less-file" }, async (args) => ({
150
+ contents: `
108
151
  import { injectStyle } from "__style_helper__"
109
152
  import css from ${JSON.stringify(args.path)}
110
153
  injectStyle(css)
111
154
  export default{}
112
- `,
113
- }));
114
- }
115
- onLoad({ filter: /\.less$/, namespace: inlineStyle ? 'less-content' : 'file' }, async (args) => {
116
- let content = await fs_1.promises.readFile(args.path, 'utf-8');
117
- if (!!alias) {
118
- content = await aliasLessImports(content, alias, args.path);
119
- }
120
- const dir = path_1.default.dirname(args.path);
121
- const filename = path_1.default.basename(args.path);
122
- try {
123
- const result = await less_1.default.render(content, {
124
- plugins: [
125
- new less_plugin_alias_1.default({
126
- alias: alias || {},
127
- }),
128
- ],
129
- filename,
130
- rootpath: dir,
131
- ...lessOptions,
132
- paths: [...(lessOptions.paths || []), dir],
133
- });
134
- const postcssrResult = await (0, postcssProcess_1.postcssProcess)(config, result.css, args.path);
135
- return {
136
- contents: postcssrResult.css,
137
- loader: inlineStyle ? 'text' : 'css',
138
- resolveDir: dir,
139
- };
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
- },
152
- },
153
- ],
154
- resolveDir: dir,
155
- };
155
+ `
156
+ }));
157
+ }
158
+ onLoad({ filter: /\.less$/, namespace: inlineStyle ? "less-content" : "file" }, async (args) => {
159
+ let content = await import_fs.promises.readFile(args.path, "utf-8");
160
+ if (!!alias) {
161
+ content = await aliasLessImports(content, alias, args.path);
162
+ }
163
+ const dir = import_path.default.dirname(args.path);
164
+ const filename = import_path.default.basename(args.path);
165
+ try {
166
+ const result = await import_less.default.render(content, __spreadProps(__spreadValues({
167
+ plugins: [
168
+ new import_less_plugin_alias.default({
169
+ alias: alias || {}
170
+ })
171
+ ],
172
+ filename,
173
+ rootpath: dir
174
+ }, lessOptions), {
175
+ paths: [...lessOptions.paths || [], dir]
176
+ }));
177
+ const postcssrResult = await (0, import_postcssProcess.postcssProcess)(config, result.css, args.path);
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
156
193
  }
157
- });
158
- },
159
- };
194
+ }
195
+ ],
196
+ resolveDir: dir
197
+ };
198
+ }
199
+ });
200
+ }
201
+ };
160
202
  };
203
+ // Annotate the CommonJS export names for ESM import in node:
204
+ 0 && (module.exports = {
205
+ aliasLessImportPath
206
+ });
File without changes