@winner-fed/bundler-esbuild 0.19.4 → 1.0.0-rc.0
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
|
@@ -0,0 +1,21 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
9
|
+
key = keys[i];
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
11
|
+
get: ((k) => from[k]).bind(null, key),
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
18
|
+
value: mod,
|
|
19
|
+
enumerable: true
|
|
20
|
+
}) : target, mod));
|
|
21
|
+
exports.__toESM = __toESM;
|
package/dist/build.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { IBabelPlugin, IConfig } from "./types.js";
|
|
2
|
+
import { BuildOptions, Format } from "@winner-fed/bundler-utils/compiled/esbuild";
|
|
3
3
|
interface IOpts {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
cwd: string;
|
|
5
|
+
entry: Record<string, string>;
|
|
6
|
+
config: IConfig;
|
|
7
|
+
mode?: string;
|
|
8
|
+
onBuildComplete?: Function;
|
|
9
|
+
clean?: boolean;
|
|
10
|
+
format?: Format;
|
|
11
|
+
sourcemap?: boolean | 'inline' | 'external' | 'both';
|
|
12
|
+
beforeBabelPlugins?: any[];
|
|
13
|
+
beforeBabelPresets?: any[];
|
|
14
|
+
extraBabelPlugins?: IBabelPlugin[];
|
|
15
|
+
extraBabelPresets?: IBabelPlugin[];
|
|
16
|
+
inlineStyle?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export declare function build(opts: IOpts): Promise<import("@winner-fed/bundler-utils/compiled/esbuild").BuildResult<BuildOptions>>;
|
|
19
|
-
export {};
|
package/dist/build.js
CHANGED
|
@@ -1,102 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
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;
|
|
18
|
-
};
|
|
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/build.ts
|
|
30
|
-
var build_exports = {};
|
|
31
|
-
__export(build_exports, {
|
|
32
|
-
build: () => build
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(build_exports);
|
|
35
|
-
var import_esbuild = require("@winner-fed/bundler-utils/compiled/esbuild");
|
|
36
|
-
var import_utils = require("@winner-fed/utils");
|
|
37
|
-
var import_path = require("path");
|
|
38
|
-
var import_alias = __toESM(require("./plugins/alias"));
|
|
39
|
-
var import_externals = __toESM(require("./plugins/externals"));
|
|
40
|
-
var import_less = __toESM(require("./plugins/less"));
|
|
41
|
-
var import_style = require("./plugins/style");
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_plugins_alias = require("./plugins/alias.js");
|
|
3
|
+
const require_plugins_externals = require("./plugins/externals.js");
|
|
4
|
+
const require_plugins_less = require("./plugins/less.js");
|
|
5
|
+
const require_plugins_style = require("./plugins/style.js");
|
|
6
|
+
let _winner_fed_bundler_utils_compiled_esbuild = require("@winner-fed/bundler-utils/compiled/esbuild");
|
|
7
|
+
let _winner_fed_utils = require("@winner-fed/utils");
|
|
8
|
+
let path = require("path");
|
|
42
9
|
async function build(opts) {
|
|
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
|
-
|
|
84
|
-
...opts.config.loader
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
await ((_b = (_a = opts.config).modifyConfig) == null ? void 0 : _b.call(_a, config));
|
|
88
|
-
const result = await (0, import_esbuild.build)(config);
|
|
89
|
-
return result;
|
|
10
|
+
var _opts$config$modifyCo, _opts$config;
|
|
11
|
+
const outputPath = opts.config.outputPath || (0, path.join)(opts.cwd, "dist");
|
|
12
|
+
if (opts.clean) _winner_fed_utils.rimraf.sync(outputPath);
|
|
13
|
+
const config = {
|
|
14
|
+
entryPoints: opts.entry,
|
|
15
|
+
bundle: true,
|
|
16
|
+
format: opts.format || "iife",
|
|
17
|
+
logLevel: "error",
|
|
18
|
+
sourcemap: opts.sourcemap,
|
|
19
|
+
outdir: outputPath,
|
|
20
|
+
metafile: true,
|
|
21
|
+
plugins: [
|
|
22
|
+
require_plugins_less.default({
|
|
23
|
+
modifyVars: opts.config.theme,
|
|
24
|
+
javascriptEnabled: true,
|
|
25
|
+
alias: opts.config.alias,
|
|
26
|
+
inlineStyle: opts.inlineStyle,
|
|
27
|
+
config: opts.config,
|
|
28
|
+
...opts.config.lessLoader
|
|
29
|
+
}),
|
|
30
|
+
opts.config.alias && require_plugins_alias(addCwdPrefix(opts.config.alias, opts.cwd)),
|
|
31
|
+
opts.config.externals && require_plugins_externals(opts.config.externals),
|
|
32
|
+
require_plugins_style.style({
|
|
33
|
+
inlineStyle: opts.inlineStyle,
|
|
34
|
+
config: opts.config
|
|
35
|
+
})
|
|
36
|
+
].filter(Boolean),
|
|
37
|
+
define: {
|
|
38
|
+
__dirname: JSON.stringify("__dirname"),
|
|
39
|
+
"process.env.NODE_ENV": JSON.stringify(opts.mode || "development"),
|
|
40
|
+
...opts.config.define
|
|
41
|
+
},
|
|
42
|
+
loader: {
|
|
43
|
+
".svg": "dataurl",
|
|
44
|
+
".ttf": "dataurl",
|
|
45
|
+
".wasm": "dataurl",
|
|
46
|
+
...opts.config.loader
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
await ((_opts$config$modifyCo = (_opts$config = opts.config).modifyConfig) === null || _opts$config$modifyCo === void 0 ? void 0 : _opts$config$modifyCo.call(_opts$config, config));
|
|
50
|
+
return await (0, _winner_fed_bundler_utils_compiled_esbuild.build)(config);
|
|
90
51
|
}
|
|
91
52
|
function addCwdPrefix(obj, cwd) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
return obj;
|
|
53
|
+
Object.keys(obj).forEach((key) => {
|
|
54
|
+
if (obj[key].startsWith(".")) obj[key] = (0, _winner_fed_utils.winPath)((0, path.join)(cwd, obj[key]));
|
|
55
|
+
});
|
|
56
|
+
return obj;
|
|
98
57
|
}
|
|
99
|
-
|
|
100
|
-
0 && (module.exports = {
|
|
101
|
-
build
|
|
102
|
-
});
|
|
58
|
+
exports.build = build;
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
package/dist/cli.js
CHANGED
|
@@ -1,74 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
|
|
24
|
-
// src/cli.ts
|
|
25
|
-
var import_esbuild = __toESM(require("@winner-fed/bundler-utils/compiled/esbuild"));
|
|
26
|
-
var import_utils = require("@winner-fed/utils");
|
|
27
|
-
var import_assert = __toESM(require("assert"));
|
|
28
|
-
var import_fs = require("fs");
|
|
29
|
-
var import_path = require("path");
|
|
30
|
-
var import_build = require("./build");
|
|
31
|
-
var args = (0, import_utils.yParser)(process.argv.slice(2), {});
|
|
32
|
-
var command = args._[0];
|
|
33
|
-
var cwd = process.cwd();
|
|
34
|
-
var entry = (0, import_utils.tryPaths)([
|
|
35
|
-
(0, import_path.join)(cwd, "src/index.tsx"),
|
|
36
|
-
(0, import_path.join)(cwd, "src/index.ts"),
|
|
37
|
-
(0, import_path.join)(cwd, "index.tsx"),
|
|
38
|
-
(0, import_path.join)(cwd, "index.ts")
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_build = require("./build.js");
|
|
3
|
+
let _winner_fed_bundler_utils_compiled_esbuild = require("@winner-fed/bundler-utils/compiled/esbuild");
|
|
4
|
+
_winner_fed_bundler_utils_compiled_esbuild = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_esbuild);
|
|
5
|
+
let _winner_fed_utils = require("@winner-fed/utils");
|
|
6
|
+
let path = require("path");
|
|
7
|
+
let fs = require("fs");
|
|
8
|
+
let assert = require("assert");
|
|
9
|
+
assert = require_runtime.__toESM(assert);
|
|
10
|
+
const args = (0, _winner_fed_utils.yParser)(process.argv.slice(2), {});
|
|
11
|
+
const command = args._[0];
|
|
12
|
+
const cwd = process.cwd();
|
|
13
|
+
const entry = (0, _winner_fed_utils.tryPaths)([
|
|
14
|
+
(0, path.join)(cwd, "src/index.tsx"),
|
|
15
|
+
(0, path.join)(cwd, "src/index.ts"),
|
|
16
|
+
(0, path.join)(cwd, "index.tsx"),
|
|
17
|
+
(0, path.join)(cwd, "index.ts")
|
|
39
18
|
]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
import_utils.register.clearFiles();
|
|
46
|
-
if ((0, import_fs.existsSync)(configFile)) {
|
|
47
|
-
config = require(configFile).default;
|
|
48
|
-
}
|
|
19
|
+
let config = {};
|
|
20
|
+
const configFile = (0, path.join)(cwd, args.config || "config.ts");
|
|
21
|
+
_winner_fed_utils.register.register({ implementor: _winner_fed_bundler_utils_compiled_esbuild.default });
|
|
22
|
+
_winner_fed_utils.register.clearFiles();
|
|
23
|
+
if ((0, fs.existsSync)(configFile)) config = require(configFile).default;
|
|
49
24
|
Object.assign(config, args);
|
|
50
|
-
if (command === "build") {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
})();
|
|
66
|
-
} else {
|
|
67
|
-
error(`Unsupported command ${command}.`);
|
|
68
|
-
}
|
|
25
|
+
if (command === "build") (async () => {
|
|
26
|
+
process.env.NODE_ENV = "production";
|
|
27
|
+
(0, assert.default)(entry, `Build failed: entry not found.`);
|
|
28
|
+
try {
|
|
29
|
+
await require_build.build({
|
|
30
|
+
config,
|
|
31
|
+
cwd,
|
|
32
|
+
entry: { [getEntryKey(entry)]: entry }
|
|
33
|
+
});
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error(e);
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
38
|
+
else error(`Unsupported command ${command}.`);
|
|
69
39
|
function error(msg) {
|
|
70
|
-
|
|
40
|
+
console.error(_winner_fed_utils.chalk.red(msg));
|
|
71
41
|
}
|
|
72
|
-
function getEntryKey(path) {
|
|
73
|
-
|
|
42
|
+
function getEntryKey(path$1) {
|
|
43
|
+
return (0, path.basename)(path$1, (0, path.extname)(path$1));
|
|
74
44
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { build } from "./build.js";
|
|
2
|
+
export { build };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/index.ts
|
|
17
|
-
var src_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(src_exports);
|
|
19
|
-
__reExport(src_exports, require("./build"), module.exports);
|
|
20
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
-
0 && (module.exports = {
|
|
22
|
-
...require("./build")
|
|
23
|
-
});
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_build = require("./build.js");
|
|
3
|
+
exports.build = require_build.build;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "@winner-fed/bundler-utils/compiled/esbuild";
|
|
2
2
|
export declare function Sample(): Plugin;
|
package/dist/plugins/__sample.js
CHANGED
|
@@ -1,32 +1,8 @@
|
|
|
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/__sample.ts
|
|
20
|
-
var sample_exports = {};
|
|
21
|
-
__export(sample_exports, {
|
|
22
|
-
Sample: () => Sample
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(sample_exports);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
2
|
function Sample() {
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
return {
|
|
4
|
+
name: "",
|
|
5
|
+
setup() {}
|
|
6
|
+
};
|
|
28
7
|
}
|
|
29
|
-
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
Sample
|
|
32
|
-
});
|
|
8
|
+
exports.Sample = Sample;
|
package/dist/plugins/alias.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "@winner-fed/bundler-utils/compiled/esbuild";
|
|
2
2
|
declare const _default: (options?: Record<string, string>) => Plugin;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
package/dist/plugins/alias.js
CHANGED
|
@@ -1,110 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(alias_exports, {
|
|
32
|
-
default: () => alias_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(alias_exports);
|
|
35
|
-
var import_enhanced_resolve = __toESM(require("@winner-fed/utils/compiled/enhanced-resolve"));
|
|
36
|
-
var import_fs = require("fs");
|
|
37
|
-
var import_sortByAffix = require("../utils/sortByAffix");
|
|
38
|
-
var ORDERED_MAIN_FIELDS = ["browser", "module", "main"];
|
|
39
|
-
var SUPPORTED_EXTENSIONS = [
|
|
40
|
-
".wasm",
|
|
41
|
-
".mjs",
|
|
42
|
-
".js",
|
|
43
|
-
".jsx",
|
|
44
|
-
".ts",
|
|
45
|
-
".tsx",
|
|
46
|
-
".json",
|
|
47
|
-
".cjs"
|
|
48
|
-
];
|
|
49
|
-
var EXPORTS_FIELDS = ["exports"];
|
|
50
|
-
var CONDITION_NAMES = ["browser", "import", "module", "require", "node"];
|
|
51
|
-
var resolver = import_enhanced_resolve.default.create({
|
|
52
|
-
mainFields: ORDERED_MAIN_FIELDS,
|
|
53
|
-
extensions: SUPPORTED_EXTENSIONS,
|
|
54
|
-
exportsFields: EXPORTS_FIELDS,
|
|
55
|
-
conditionNames: CONDITION_NAMES,
|
|
56
|
-
symlinks: false
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_utils_sortByAffix = require("../utils/sortByAffix.js");
|
|
3
|
+
let _winner_fed_utils_compiled_enhanced_resolve = require("@winner-fed/utils/compiled/enhanced-resolve");
|
|
4
|
+
_winner_fed_utils_compiled_enhanced_resolve = require_runtime.__toESM(_winner_fed_utils_compiled_enhanced_resolve);
|
|
5
|
+
let fs = require("fs");
|
|
6
|
+
const resolver = _winner_fed_utils_compiled_enhanced_resolve.default.create({
|
|
7
|
+
mainFields: [
|
|
8
|
+
"browser",
|
|
9
|
+
"module",
|
|
10
|
+
"main"
|
|
11
|
+
],
|
|
12
|
+
extensions: [
|
|
13
|
+
".wasm",
|
|
14
|
+
".mjs",
|
|
15
|
+
".js",
|
|
16
|
+
".jsx",
|
|
17
|
+
".ts",
|
|
18
|
+
".tsx",
|
|
19
|
+
".json",
|
|
20
|
+
".cjs"
|
|
21
|
+
],
|
|
22
|
+
exportsFields: ["exports"],
|
|
23
|
+
conditionNames: [
|
|
24
|
+
"browser",
|
|
25
|
+
"import",
|
|
26
|
+
"module",
|
|
27
|
+
"require",
|
|
28
|
+
"node"
|
|
29
|
+
],
|
|
30
|
+
symlinks: false
|
|
57
31
|
});
|
|
58
32
|
async function resolve(context, path) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
path,
|
|
63
|
-
(err, result) => err ? reject(err) : resolve2(result)
|
|
64
|
-
);
|
|
65
|
-
});
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
|
|
35
|
+
});
|
|
66
36
|
}
|
|
67
37
|
var alias_default = (options = {}) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onResolve({ filter: filter2 }, async (args) => {
|
|
92
|
-
const path = await resolve(
|
|
93
|
-
args.importer,
|
|
94
|
-
args.path.replace(filter2, addSlashAffix(value))
|
|
95
|
-
);
|
|
96
|
-
return {
|
|
97
|
-
path
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
};
|
|
38
|
+
return {
|
|
39
|
+
name: "alias",
|
|
40
|
+
setup({ onResolve }) {
|
|
41
|
+
require_utils_sortByAffix.sortByAffix({
|
|
42
|
+
arr: Object.keys(options),
|
|
43
|
+
affix: "$"
|
|
44
|
+
}).forEach((key) => {
|
|
45
|
+
let value = options[key];
|
|
46
|
+
let filter;
|
|
47
|
+
if (key.endsWith("$")) filter = new RegExp(`^${key}`);
|
|
48
|
+
else filter = new RegExp(`^${key}$`);
|
|
49
|
+
onResolve({ filter }, async (args) => {
|
|
50
|
+
return { path: await resolve(args.importer, args.path.replace(filter, value)) };
|
|
51
|
+
});
|
|
52
|
+
if (!key.endsWith("/") && (0, fs.existsSync)(value) && (0, fs.statSync)(value).isDirectory()) {
|
|
53
|
+
const filter = new RegExp(`^${addSlashAffix(key)}`);
|
|
54
|
+
onResolve({ filter }, async (args) => {
|
|
55
|
+
return { path: await resolve(args.importer, args.path.replace(filter, addSlashAffix(value))) };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
104
61
|
};
|
|
105
62
|
function addSlashAffix(key) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
return `${key}/`;
|
|
63
|
+
if (key.endsWith("/")) return key;
|
|
64
|
+
return `${key}/`;
|
|
110
65
|
}
|
|
66
|
+
module.exports = alias_default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "@winner-fed/bundler-utils/compiled/esbuild";
|
|
2
2
|
declare const _default: (options?: Record<string, string>) => Plugin;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|