@winner-fed/bundler-esbuild 0.19.4 → 1.0.0-rc.1
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/_virtual/_rolldown/runtime.js +21 -0
- package/dist/build.d.ts +15 -16
- package/dist/build.js +54 -98
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +39 -69
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -23
- package/dist/plugins/__sample.d.ts +1 -1
- package/dist/plugins/__sample.js +6 -30
- package/dist/plugins/alias.d.ts +2 -2
- package/dist/plugins/alias.js +59 -103
- package/dist/plugins/externals.d.ts +2 -2
- package/dist/plugins/externals.js +20 -42
- package/dist/plugins/less-plugin-alias/index.d.ts +6 -6
- package/dist/plugins/less-plugin-alias/index.js +50 -96
- package/dist/plugins/less-plugin-alias/types.d.ts +2 -2
- package/dist/plugins/less-plugin-alias/types.js +0 -17
- package/dist/plugins/less-plugin-alias/utils.d.ts +1 -1
- package/dist/plugins/less-plugin-alias/utils.js +25 -56
- package/dist/plugins/less.d.ts +6 -6
- package/dist/plugins/less.js +158 -202
- package/dist/plugins/nodeGlobalsPolyfill.d.ts +1 -1
- package/dist/plugins/nodeGlobalsPolyfill.js +8 -36
- package/dist/plugins/style.d.ts +15 -15
- package/dist/plugins/style.js +116 -159
- package/dist/plugins/watchRebuild.d.ts +2 -2
- package/dist/plugins/watchRebuild.js +27 -61
- package/dist/types.d.ts +49 -49
- package/dist/types.js +13 -40
- package/dist/utils/getBrowserlist.js +5 -31
- package/dist/utils/postcssProcess.d.ts +2 -2
- package/dist/utils/postcssProcess.js +17 -56
- package/dist/utils/sortByAffix.d.ts +2 -2
- package/dist/utils/sortByAffix.js +8 -34
- package/package.json +6 -6
|
@@ -1,44 +1,22 @@
|
|
|
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
1
|
var externals_default = (options) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
2
|
+
return {
|
|
3
|
+
name: "externals",
|
|
4
|
+
setup({ onLoad, onResolve }) {
|
|
5
|
+
if (!options || Object.keys(options).length === 0) return;
|
|
6
|
+
Object.keys(options).forEach((key) => {
|
|
7
|
+
onResolve({ filter: new RegExp(`^${key}$`) }, (args) => ({
|
|
8
|
+
path: args.path,
|
|
9
|
+
namespace: key
|
|
10
|
+
}));
|
|
11
|
+
onLoad({
|
|
12
|
+
filter: /.*/,
|
|
13
|
+
namespace: key
|
|
14
|
+
}, () => ({
|
|
15
|
+
contents: `module.export=${options[key]}`,
|
|
16
|
+
loader: "js"
|
|
17
|
+
}));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
44
21
|
};
|
|
22
|
+
module.exports = externals_default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
interface Options {
|
|
2
|
-
|
|
2
|
+
alias: Record<string, string>;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
declare class LessAliasPlugin {
|
|
5
|
+
private options;
|
|
6
|
+
constructor(options: Options);
|
|
7
|
+
install(less: LessStatic, pluginManager: Less.PluginManager): void;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export = LessAliasPlugin;
|
|
@@ -1,100 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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("@winner-fed/utils");
|
|
26
|
-
var import_utils2 = require("./utils");
|
|
1
|
+
const require_plugins_less_plugin_alias_utils = require("./utils.js");
|
|
2
|
+
let _winner_fed_utils = require("@winner-fed/utils");
|
|
27
3
|
function matches(pattern, importee) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
if (importee === pattern) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
return importee.startsWith(pattern + "/");
|
|
4
|
+
if (pattern instanceof RegExp) return pattern.test(importee);
|
|
5
|
+
if (importee.length < pattern.length) return false;
|
|
6
|
+
if (importee === pattern) return true;
|
|
7
|
+
return importee.startsWith(pattern + "/");
|
|
38
8
|
}
|
|
39
9
|
var LessAliasPlugin = class {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
}
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
install(less, pluginManager) {
|
|
14
|
+
const alias = require_plugins_less_plugin_alias_utils.parseAlias(this.options.alias);
|
|
15
|
+
function resolveId(filename) {
|
|
16
|
+
if (!filename) return null;
|
|
17
|
+
const matchedEntry = alias.find((entry) => matches(entry.find, filename));
|
|
18
|
+
if (!matchedEntry) return filename;
|
|
19
|
+
return filename.replace(matchedEntry.find, matchedEntry.replacement);
|
|
20
|
+
}
|
|
21
|
+
class AliasePlugin extends less.FileManager {
|
|
22
|
+
loadFile(filename, currentDirectory, options, enviroment) {
|
|
23
|
+
let resolved;
|
|
24
|
+
try {
|
|
25
|
+
resolved = resolveId(filename);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
_winner_fed_utils.logger.error(error);
|
|
28
|
+
}
|
|
29
|
+
if (!resolved) {
|
|
30
|
+
const error = /* @__PURE__ */ new Error(`[less-plugin-alias]: '${filename}' not found.`);
|
|
31
|
+
_winner_fed_utils.logger.error(error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
return super.loadFile(resolved, currentDirectory, options, enviroment);
|
|
35
|
+
}
|
|
36
|
+
loadFileSync(filename, currentDirectory, options, enviroment) {
|
|
37
|
+
let resolved;
|
|
38
|
+
try {
|
|
39
|
+
resolved = resolveId(filename);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
_winner_fed_utils.logger.error(error);
|
|
42
|
+
}
|
|
43
|
+
if (!resolved) {
|
|
44
|
+
const error = /* @__PURE__ */ new Error(`[less-plugin-alias]: '${filename}' not found.`);
|
|
45
|
+
_winner_fed_utils.logger.error(error);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
return super.loadFileSync(resolved, currentDirectory, options, enviroment);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
pluginManager.addFileManager(new AliasePlugin());
|
|
52
|
+
}
|
|
100
53
|
};
|
|
54
|
+
module.exports = LessAliasPlugin;
|
|
@@ -1,17 +0,0 @@
|
|
|
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);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Alias } from
|
|
1
|
+
import { Alias } from "./types.js";
|
|
2
2
|
export declare function parseAlias(alias: Record<string, string>): Alias[];
|
|
@@ -1,60 +1,29 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
2
|
function hoistAlias(alias) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
alias.forEach((rule, index, alias2) => {
|
|
41
|
-
rule.replacement = getFinalReplacement(alias2, rule.replacement, index);
|
|
42
|
-
});
|
|
43
|
-
return alias;
|
|
3
|
+
function getFinalReplacement(oAlias, replacement, index) {
|
|
4
|
+
const newAlias = oAlias.slice();
|
|
5
|
+
newAlias.splice(index, 1);
|
|
6
|
+
for (let i = 0; i < newAlias.length; i++) if (newAlias[i].find.test(replacement)) {
|
|
7
|
+
replacement = replacement.replace(newAlias[i].find, newAlias[i].replacement);
|
|
8
|
+
return getFinalReplacement(newAlias, replacement, i);
|
|
9
|
+
}
|
|
10
|
+
return replacement;
|
|
11
|
+
}
|
|
12
|
+
alias.forEach((rule, index, alias) => {
|
|
13
|
+
rule.replacement = getFinalReplacement(alias, rule.replacement, index);
|
|
14
|
+
});
|
|
15
|
+
return alias;
|
|
44
16
|
}
|
|
45
17
|
function parseAlias(alias) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
18
|
+
const wholeAlias = [{
|
|
19
|
+
find: /^~/,
|
|
20
|
+
replacement: ""
|
|
21
|
+
}];
|
|
22
|
+
const userAlias = Object.entries(alias).map(([name, target]) => ({
|
|
23
|
+
find: new RegExp(`^~?${name.replace(/(?<!\$)$/, "(?=/|$)")}`),
|
|
24
|
+
replacement: target
|
|
25
|
+
}));
|
|
26
|
+
wholeAlias.unshift(...userAlias);
|
|
27
|
+
return hoistAlias(wholeAlias);
|
|
56
28
|
}
|
|
57
|
-
|
|
58
|
-
0 && (module.exports = {
|
|
59
|
-
parseAlias
|
|
60
|
-
});
|
|
29
|
+
exports.parseAlias = parseAlias;
|
package/dist/plugins/less.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IConfig } from "../types.js";
|
|
2
|
+
import { Plugin } from "@winner-fed/bundler-utils/compiled/esbuild";
|
|
3
3
|
export declare const aliasLessImportPath: (filePath: string, alias: Record<string, string>, importer: string) => Promise<string | null>;
|
|
4
4
|
declare const _default: (options?: Less.Options & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
alias?: Record<string, string>;
|
|
6
|
+
inlineStyle?: boolean;
|
|
7
|
+
config?: IConfig;
|
|
8
8
|
}) => Plugin;
|
|
9
|
-
export default
|
|
9
|
+
export { _default as default };
|