@winner-fed/babel-preset-win 0.19.4-alpha.0 → 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/index.d.ts +15 -15
- package/dist/index.js +67 -183
- package/dist/plugins/autoCSSModules.d.ts +8 -7
- package/dist/plugins/autoCSSModules.js +23 -59
- package/dist/plugins/dynamicImportNode.d.ts +2 -2
- package/dist/plugins/dynamicImportNode.js +36 -74
- package/dist/plugins/lockCoreJS.d.ts +3 -2
- package/dist/plugins/lockCoreJS.js +15 -55
- package/dist/plugins/stripExports.d.ts +2 -2
- package/dist/plugins/stripExports.js +54 -98
- 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/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
interface IOpts {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
presetEnv: any;
|
|
3
|
+
presetReact: any;
|
|
4
|
+
presetTypeScript: any;
|
|
5
|
+
pluginTransformRuntime: any;
|
|
6
|
+
pluginLockCoreJS: any;
|
|
7
|
+
pluginDynamicImportNode: any;
|
|
8
|
+
pluginAutoCSSModules: any;
|
|
9
|
+
stripExports: {
|
|
10
|
+
exports: string[];
|
|
11
|
+
};
|
|
12
|
+
classPropertiesLoose: any;
|
|
13
|
+
pluginDecorators: any;
|
|
14
14
|
}
|
|
15
15
|
declare const _default: (_context: any, opts: IOpts) => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
presets: (false | any[])[];
|
|
17
|
+
plugins: any[];
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export = _default;
|
package/dist/index.js
CHANGED
|
@@ -1,185 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
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/index.ts
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
default: () => src_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
var import_utils = require("@winner-fed/utils");
|
|
36
|
-
var import_path = require("path");
|
|
37
|
-
var import_autoCSSModules = __toESM(require("./plugins/autoCSSModules"));
|
|
38
|
-
var import_dynamicImportNode = __toESM(require("./plugins/dynamicImportNode"));
|
|
39
|
-
var import_lockCoreJS = __toESM(require("./plugins/lockCoreJS"));
|
|
40
|
-
var import_stripExports = __toESM(require("./plugins/stripExports"));
|
|
1
|
+
const require_plugins_autoCSSModules = require("./plugins/autoCSSModules.js");
|
|
2
|
+
const require_plugins_dynamicImportNode = require("./plugins/dynamicImportNode.js");
|
|
3
|
+
const require_plugins_lockCoreJS = require("./plugins/lockCoreJS.js");
|
|
4
|
+
const require_plugins_stripExports = require("./plugins/stripExports.js");
|
|
5
|
+
let _winner_fed_utils = require("@winner-fed/utils");
|
|
6
|
+
let path = require("path");
|
|
41
7
|
var src_default = (_context, opts) => {
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// * @babel/plugin-proposal-private-property-in-object
|
|
103
|
-
// (when they are enabled)
|
|
104
|
-
// ref: https://github.com/facebook/create-react-app/issues/4263
|
|
105
|
-
// ref: https://github.com/mobxjs/mobx/issues/1471
|
|
106
|
-
// ref: https://github.com/umijs/umi/issues/9396
|
|
107
|
-
// 不移动到 feature 里的原因是因为 decorators 有顺序要求
|
|
108
|
-
opts.classPropertiesLoose && [
|
|
109
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-class-properties"),
|
|
110
|
-
{ loose: true }
|
|
111
|
-
],
|
|
112
|
-
opts.classPropertiesLoose && [
|
|
113
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-private-methods"),
|
|
114
|
-
{
|
|
115
|
-
loose: true
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
opts.classPropertiesLoose && [
|
|
119
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-private-property-in-object"),
|
|
120
|
-
{
|
|
121
|
-
loose: true
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
// do-expressions
|
|
125
|
-
[
|
|
126
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-do-expressions")
|
|
127
|
-
],
|
|
128
|
-
// export-default-from
|
|
129
|
-
[
|
|
130
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-export-default-from")
|
|
131
|
-
],
|
|
132
|
-
// export-namespace-from
|
|
133
|
-
[
|
|
134
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-export-namespace-from")
|
|
135
|
-
],
|
|
136
|
-
// function-bind
|
|
137
|
-
[
|
|
138
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-function-bind")
|
|
139
|
-
],
|
|
140
|
-
// function-sent
|
|
141
|
-
// partial-application
|
|
142
|
-
[
|
|
143
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-partial-application")
|
|
144
|
-
],
|
|
145
|
-
// pipeline-operator
|
|
146
|
-
[
|
|
147
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-pipeline-operator"),
|
|
148
|
-
{ proposal: "minimal" }
|
|
149
|
-
],
|
|
150
|
-
// throw-expressions
|
|
151
|
-
// record-and-tuple
|
|
152
|
-
[
|
|
153
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-record-and-tuple"),
|
|
154
|
-
{
|
|
155
|
-
syntaxType: "hash",
|
|
156
|
-
importPolyfill: true,
|
|
157
|
-
polyfillModuleName: (0, import_path.dirname)(
|
|
158
|
-
require.resolve("@bloomberg/record-tuple-polyfill/package")
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
],
|
|
162
|
-
opts.pluginTransformRuntime && [
|
|
163
|
-
require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-transform-runtime"),
|
|
164
|
-
{
|
|
165
|
-
helpers: true,
|
|
166
|
-
regenerator: true,
|
|
167
|
-
// 7.13 之后根据 exports 自动选择 esm 和 cjs,无需此配置
|
|
168
|
-
useESModules: false,
|
|
169
|
-
// lock the version of @babel/runtime
|
|
170
|
-
// make sure we are using the correct version
|
|
171
|
-
// ref: https://github.com/babel/babel/blob/v7.16.12/packages/babel-plugin-transform-runtime/src/get-runtime-path/index.ts#L19
|
|
172
|
-
// ref: https://github.com/umijs/umi/pull/7816
|
|
173
|
-
absoluteRuntime: (0, import_path.dirname)(require.resolve("../package.json")),
|
|
174
|
-
version: `^${require("@babel/runtime/package.json").version}`,
|
|
175
|
-
...opts.pluginTransformRuntime
|
|
176
|
-
}
|
|
177
|
-
],
|
|
178
|
-
// none official plugins
|
|
179
|
-
opts.pluginLockCoreJS && [import_lockCoreJS.default],
|
|
180
|
-
opts.pluginDynamicImportNode && [import_dynamicImportNode.default],
|
|
181
|
-
opts.pluginAutoCSSModules && [import_autoCSSModules.default],
|
|
182
|
-
opts.stripExports && [import_stripExports.default]
|
|
183
|
-
].filter(Boolean)
|
|
184
|
-
};
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/preset-env"), {
|
|
11
|
+
bugfixes: true,
|
|
12
|
+
spec: false,
|
|
13
|
+
loose: false,
|
|
14
|
+
modules: false,
|
|
15
|
+
debug: false,
|
|
16
|
+
useBuiltIns: "entry",
|
|
17
|
+
corejs: (0, _winner_fed_utils.getCorejsVersion)((0, path.join)(__dirname, "../package.json")),
|
|
18
|
+
forceAllTransforms: false,
|
|
19
|
+
ignoreBrowserslistConfig: true,
|
|
20
|
+
...opts.presetEnv
|
|
21
|
+
}],
|
|
22
|
+
opts.presetReact !== false && [require.resolve("@winner-fed/bundler-utils/compiled/babel/preset-react"), {
|
|
23
|
+
runtime: "automatic",
|
|
24
|
+
development: process.env.NODE_ENV === "development",
|
|
25
|
+
...opts.presetReact
|
|
26
|
+
}],
|
|
27
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/preset-typescript"), {
|
|
28
|
+
allowNamespaces: true,
|
|
29
|
+
allowDeclareFields: true,
|
|
30
|
+
onlyRemoveTypeImports: false,
|
|
31
|
+
optimizeConstEnums: true,
|
|
32
|
+
...opts.presetTypeScript
|
|
33
|
+
}]
|
|
34
|
+
].filter(Boolean),
|
|
35
|
+
plugins: [
|
|
36
|
+
opts.pluginDecorators !== false && [require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-decorators"), {
|
|
37
|
+
legacy: true,
|
|
38
|
+
...opts.pluginDecorators
|
|
39
|
+
}],
|
|
40
|
+
opts.classPropertiesLoose && [require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-class-properties"), { loose: true }],
|
|
41
|
+
opts.classPropertiesLoose && [require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-private-methods"), { loose: true }],
|
|
42
|
+
opts.classPropertiesLoose && [require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-private-property-in-object"), { loose: true }],
|
|
43
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-do-expressions")],
|
|
44
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-export-default-from")],
|
|
45
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-export-namespace-from")],
|
|
46
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-function-bind")],
|
|
47
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-partial-application")],
|
|
48
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-pipeline-operator"), { proposal: "minimal" }],
|
|
49
|
+
[require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-proposal-record-and-tuple"), {
|
|
50
|
+
syntaxType: "hash",
|
|
51
|
+
importPolyfill: true,
|
|
52
|
+
polyfillModuleName: (0, path.dirname)(require.resolve("@bloomberg/record-tuple-polyfill/package"))
|
|
53
|
+
}],
|
|
54
|
+
opts.pluginTransformRuntime && [require.resolve("@winner-fed/bundler-utils/compiled/babel/plugin-transform-runtime"), {
|
|
55
|
+
helpers: true,
|
|
56
|
+
regenerator: true,
|
|
57
|
+
useESModules: false,
|
|
58
|
+
absoluteRuntime: (0, path.dirname)(require.resolve("../package.json")),
|
|
59
|
+
version: `^${require("@babel/runtime/package.json").version}`,
|
|
60
|
+
...opts.pluginTransformRuntime
|
|
61
|
+
}],
|
|
62
|
+
opts.pluginLockCoreJS && [require_plugins_lockCoreJS],
|
|
63
|
+
opts.pluginDynamicImportNode && [require_plugins_dynamicImportNode],
|
|
64
|
+
opts.pluginAutoCSSModules && [require_plugins_autoCSSModules],
|
|
65
|
+
opts.stripExports && [require_plugins_stripExports]
|
|
66
|
+
].filter(Boolean)
|
|
67
|
+
};
|
|
185
68
|
};
|
|
69
|
+
module.exports = src_default;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as Babel from
|
|
2
|
-
import * as t from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import * as Babel from "@winner-fed/bundler-utils/compiled/babel/core.js";
|
|
2
|
+
import * as t from "@winner-fed/bundler-utils/compiled/babel/types.js";
|
|
3
|
+
declare function export_default(): {
|
|
4
|
+
visitor: {
|
|
5
|
+
ImportDeclaration(path: Babel.NodePath<t.ImportDeclaration>): void;
|
|
6
|
+
VariableDeclarator(path: Babel.NodePath<t.VariableDeclarator>): void;
|
|
7
|
+
};
|
|
8
8
|
};
|
|
9
|
+
export = export_default;
|
|
@@ -1,61 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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/plugins/autoCSSModules.ts
|
|
30
|
-
var autoCSSModules_exports = {};
|
|
31
|
-
__export(autoCSSModules_exports, {
|
|
32
|
-
default: () => autoCSSModules_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(autoCSSModules_exports);
|
|
35
|
-
var t = __toESM(require("@winner-fed/bundler-utils/compiled/babel/types.js"));
|
|
36
|
-
var import_path = require("path");
|
|
37
|
-
var CSS_EXT_NAMES = [".css", ".less", ".sass", ".scss", ".stylus", ".styl"];
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let path = require("path");
|
|
3
|
+
let _winner_fed_bundler_utils_compiled_babel_types_js = require("@winner-fed/bundler-utils/compiled/babel/types.js");
|
|
4
|
+
_winner_fed_bundler_utils_compiled_babel_types_js = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_babel_types_js);
|
|
5
|
+
const CSS_EXT_NAMES = [
|
|
6
|
+
".css",
|
|
7
|
+
".less",
|
|
8
|
+
".sass",
|
|
9
|
+
".scss",
|
|
10
|
+
".stylus",
|
|
11
|
+
".styl"
|
|
12
|
+
];
|
|
38
13
|
function autoCSSModules_default() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
// e.g.
|
|
52
|
-
// const styles = await import('./index.less');
|
|
53
|
-
VariableDeclarator(path) {
|
|
54
|
-
const { node } = path;
|
|
55
|
-
if (t.isAwaitExpression(node.init) && t.isCallExpression(node.init.argument) && t.isImport(node.init.argument.callee) && node.init.argument.arguments.length === 1 && t.isStringLiteral(node.init.argument.arguments[0]) && CSS_EXT_NAMES.includes((0, import_path.extname)(node.init.argument.arguments[0].value))) {
|
|
56
|
-
node.init.argument.arguments[0].value = `${node.init.argument.arguments[0].value}?modules`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
};
|
|
14
|
+
return { visitor: {
|
|
15
|
+
ImportDeclaration(path$1) {
|
|
16
|
+
const { specifiers, source, source: { value } } = path$1.node;
|
|
17
|
+
if (specifiers.length && CSS_EXT_NAMES.includes((0, path.extname)(value))) source.value = `${value}?modules`;
|
|
18
|
+
},
|
|
19
|
+
VariableDeclarator(path$2) {
|
|
20
|
+
const { node } = path$2;
|
|
21
|
+
if (_winner_fed_bundler_utils_compiled_babel_types_js.isAwaitExpression(node.init) && _winner_fed_bundler_utils_compiled_babel_types_js.isCallExpression(node.init.argument) && _winner_fed_bundler_utils_compiled_babel_types_js.isImport(node.init.argument.callee) && node.init.argument.arguments.length === 1 && _winner_fed_bundler_utils_compiled_babel_types_js.isStringLiteral(node.init.argument.arguments[0]) && CSS_EXT_NAMES.includes((0, path.extname)(node.init.argument.arguments[0].value))) node.init.argument.arguments[0].value = `${node.init.argument.arguments[0].value}?modules`;
|
|
22
|
+
}
|
|
23
|
+
} };
|
|
61
24
|
}
|
|
25
|
+
module.exports = autoCSSModules_default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as Babel from
|
|
1
|
+
import * as Babel from "@winner-fed/bundler-utils/compiled/babel/core.js";
|
|
2
2
|
declare const _default: () => Babel.PluginObj;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
|
@@ -1,81 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
};
|
|
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/plugins/dynamicImportNode.ts
|
|
30
|
-
var dynamicImportNode_exports = {};
|
|
31
|
-
__export(dynamicImportNode_exports, {
|
|
32
|
-
default: () => dynamicImportNode_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(dynamicImportNode_exports);
|
|
35
|
-
var import_template = __toESM(require("@winner-fed/bundler-utils/compiled/babel/template.js"));
|
|
36
|
-
var t = __toESM(require("@winner-fed/bundler-utils/compiled/babel/types.js"));
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _winner_fed_bundler_utils_compiled_babel_types_js = require("@winner-fed/bundler-utils/compiled/babel/types.js");
|
|
3
|
+
_winner_fed_bundler_utils_compiled_babel_types_js = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_babel_types_js);
|
|
4
|
+
let _winner_fed_bundler_utils_compiled_babel_template_js = require("@winner-fed/bundler-utils/compiled/babel/template.js");
|
|
5
|
+
_winner_fed_bundler_utils_compiled_babel_template_js = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_babel_template_js);
|
|
37
6
|
function getImportSource(callNode) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
7
|
+
const importArguments = callNode.arguments;
|
|
8
|
+
const [importPath] = importArguments;
|
|
9
|
+
if (_winner_fed_bundler_utils_compiled_babel_types_js.isStringLiteral(importPath) || _winner_fed_bundler_utils_compiled_babel_types_js.isTemplateLiteral(importPath)) {
|
|
10
|
+
_winner_fed_bundler_utils_compiled_babel_types_js.removeComments(importPath);
|
|
11
|
+
return importPath;
|
|
12
|
+
}
|
|
13
|
+
return _winner_fed_bundler_utils_compiled_babel_types_js.templateLiteral([_winner_fed_bundler_utils_compiled_babel_types_js.templateElement({
|
|
14
|
+
raw: "",
|
|
15
|
+
cooked: ""
|
|
16
|
+
}), _winner_fed_bundler_utils_compiled_babel_types_js.templateElement({
|
|
17
|
+
raw: "",
|
|
18
|
+
cooked: ""
|
|
19
|
+
}, true)], importArguments);
|
|
52
20
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
21
|
+
const builders = {
|
|
22
|
+
static: (0, _winner_fed_bundler_utils_compiled_babel_template_js.default)("Promise.resolve().then(() => INTEROP(require(SOURCE)))"),
|
|
23
|
+
dynamic: (0, _winner_fed_bundler_utils_compiled_babel_template_js.default)("Promise.resolve(SOURCE).then(s => INTEROP(require(s)))")
|
|
56
24
|
};
|
|
57
25
|
function isString(node) {
|
|
58
|
-
|
|
26
|
+
return _winner_fed_bundler_utils_compiled_babel_types_js.isStringLiteral(node) || _winner_fed_bundler_utils_compiled_babel_types_js.isTemplateLiteral(node) && node.expressions.length === 0;
|
|
59
27
|
}
|
|
60
28
|
var dynamicImportNode_default = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
SOURCE,
|
|
75
|
-
INTEROP: path.hub.addHelper("interopRequireWildcard")
|
|
76
|
-
});
|
|
77
|
-
path.parentPath.replaceWith(newImport);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
29
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
30
|
+
return { visitor: { Import(path) {
|
|
31
|
+
if (visited) {
|
|
32
|
+
if (visited.has(path)) return;
|
|
33
|
+
visited.add(path);
|
|
34
|
+
}
|
|
35
|
+
const SOURCE = getImportSource(path.parent);
|
|
36
|
+
const newImport = (isString(SOURCE) ? builders.static : builders.dynamic)({
|
|
37
|
+
SOURCE,
|
|
38
|
+
INTEROP: path.hub.addHelper("interopRequireWildcard")
|
|
39
|
+
});
|
|
40
|
+
path.parentPath.replaceWith(newImport);
|
|
41
|
+
} } };
|
|
81
42
|
};
|
|
43
|
+
module.exports = dynamicImportNode_default;
|
|
@@ -1,58 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (var name in all)
|
|
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/plugins/lockCoreJS.ts
|
|
30
|
-
var lockCoreJS_exports = {};
|
|
31
|
-
__export(lockCoreJS_exports, {
|
|
32
|
-
default: () => lockCoreJS_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(lockCoreJS_exports);
|
|
35
|
-
var t = __toESM(require("@winner-fed/bundler-utils/compiled/babel/types.js"));
|
|
36
|
-
var import_utils = require("@winner-fed/utils");
|
|
37
|
-
var import_path = require("path");
|
|
38
|
-
function addLastSlash(path) {
|
|
39
|
-
return path.endsWith("/") ? path : `${path}/`;
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _winner_fed_utils = require("@winner-fed/utils");
|
|
3
|
+
let path = require("path");
|
|
4
|
+
let _winner_fed_bundler_utils_compiled_babel_types_js = require("@winner-fed/bundler-utils/compiled/babel/types.js");
|
|
5
|
+
_winner_fed_bundler_utils_compiled_babel_types_js = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_babel_types_js);
|
|
6
|
+
function addLastSlash(path$2) {
|
|
7
|
+
return path$2.endsWith("/") ? path$2 : `${path$2}/`;
|
|
40
8
|
}
|
|
41
9
|
function lockCoreJS_default() {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
addLastSlash(
|
|
50
|
-
(0, import_utils.winPath)((0, import_path.dirname)(require.resolve("core-js/package.json")))
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
|
10
|
+
return { post({ path: path$1 }) {
|
|
11
|
+
path$1.node.body.forEach((node) => {
|
|
12
|
+
if (_winner_fed_bundler_utils_compiled_babel_types_js.isImportDeclaration(node)) {
|
|
13
|
+
if (node.source.value.startsWith("core-js/")) node.source.value = node.source.value.replace(/^core-js\//, addLastSlash((0, _winner_fed_utils.winPath)((0, path.dirname)(require.resolve("core-js/package.json")))));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
} };
|
|
58
17
|
}
|
|
18
|
+
module.exports = lockCoreJS_default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as Babel from
|
|
1
|
+
import * as Babel from "@winner-fed/bundler-utils/compiled/babel/core.js";
|
|
2
2
|
declare const _default: () => Babel.PluginObj;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
|
@@ -1,100 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
};
|
|
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/plugins/stripExports.ts
|
|
30
|
-
var stripExports_exports = {};
|
|
31
|
-
__export(stripExports_exports, {
|
|
32
|
-
default: () => stripExports_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(stripExports_exports);
|
|
35
|
-
var t = __toESM(require("@winner-fed/bundler-utils/compiled/babel/types.js"));
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let _winner_fed_bundler_utils_compiled_babel_types_js = require("@winner-fed/bundler-utils/compiled/babel/types.js");
|
|
3
|
+
_winner_fed_bundler_utils_compiled_babel_types_js = require_runtime.__toESM(_winner_fed_bundler_utils_compiled_babel_types_js);
|
|
36
4
|
var stripExports_default = () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
expressions.forEach((exp) => {
|
|
88
|
-
if (!t.isImportDeclaration(exp)) return;
|
|
89
|
-
const specifiers = exp.get("specifiers");
|
|
90
|
-
specifiers.forEach((s) => {
|
|
91
|
-
const name = s.get("local.name").node;
|
|
92
|
-
if (!s.scope.getBinding(name).referenced) s.remove();
|
|
93
|
-
});
|
|
94
|
-
if (exp.get("specifiers").length === 0) exp.remove();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
5
|
+
return { visitor: { Program: {
|
|
6
|
+
enter(path, { opts }) {
|
|
7
|
+
const expressions = path.get("body");
|
|
8
|
+
const exports = (opts === null || opts === void 0 ? void 0 : opts.exports) || [];
|
|
9
|
+
expressions.forEach((exp) => {
|
|
10
|
+
if (!(_winner_fed_bundler_utils_compiled_babel_types_js.isExportNamedDeclaration(exp) || _winner_fed_bundler_utils_compiled_babel_types_js.isExportDefaultDeclaration(exp))) return;
|
|
11
|
+
handleExportsIndividual(exp);
|
|
12
|
+
handleExportsList(exp);
|
|
13
|
+
handleExportsDefault(exp);
|
|
14
|
+
});
|
|
15
|
+
function handleExportsIndividual(path) {
|
|
16
|
+
if (!path.node) return;
|
|
17
|
+
if (!_winner_fed_bundler_utils_compiled_babel_types_js.isExportNamedDeclaration(path)) return;
|
|
18
|
+
if (!path.get("declaration").node) return;
|
|
19
|
+
const declaration = path.get("declaration");
|
|
20
|
+
if (_winner_fed_bundler_utils_compiled_babel_types_js.isVariableDeclaration(declaration)) declaration.get("declarations").forEach((variable) => {
|
|
21
|
+
exports.includes(variable.get("id.name").node) && variable.remove();
|
|
22
|
+
});
|
|
23
|
+
else exports.includes(declaration.get("id.name").node) && declaration.remove();
|
|
24
|
+
}
|
|
25
|
+
function handleExportsList(path) {
|
|
26
|
+
if (!path.node) return;
|
|
27
|
+
if (!_winner_fed_bundler_utils_compiled_babel_types_js.isExportNamedDeclaration(path)) return;
|
|
28
|
+
const specifiers = path.get("specifiers");
|
|
29
|
+
if (!specifiers || specifiers.length === 0) return;
|
|
30
|
+
specifiers.forEach((specifier) => {
|
|
31
|
+
if (exports.includes(specifier.get("exported.name").node)) specifier.remove();
|
|
32
|
+
});
|
|
33
|
+
if (path.get("specifiers").length === 0) path.remove();
|
|
34
|
+
}
|
|
35
|
+
function handleExportsDefault(path) {
|
|
36
|
+
if (!path.node) return;
|
|
37
|
+
if (!_winner_fed_bundler_utils_compiled_babel_types_js.isExportDefaultDeclaration(path)) return;
|
|
38
|
+
const declaration = path.get("declaration");
|
|
39
|
+
if (!declaration.node) return;
|
|
40
|
+
if (exports.includes(declaration.get("name").node)) declaration.remove();
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
exit(path) {
|
|
44
|
+
path.scope.crawl();
|
|
45
|
+
path.get("body").forEach((exp) => {
|
|
46
|
+
if (!_winner_fed_bundler_utils_compiled_babel_types_js.isImportDeclaration(exp)) return;
|
|
47
|
+
exp.get("specifiers").forEach((s) => {
|
|
48
|
+
const name = s.get("local.name").node;
|
|
49
|
+
if (!s.scope.getBinding(name).referenced) s.remove();
|
|
50
|
+
});
|
|
51
|
+
if (exp.get("specifiers").length === 0) exp.remove();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} } };
|
|
100
55
|
};
|
|
56
|
+
module.exports = stripExports_default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@winner-fed/babel-preset-win",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"description": "@winner-fed/babel-preset-win",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
"@babel/runtime": "7.26.10",
|
|
13
13
|
"@bloomberg/record-tuple-polyfill": "0.0.4",
|
|
14
14
|
"core-js": "~3.40.0",
|
|
15
|
-
"@winner-fed/bundler-utils": "0.
|
|
16
|
-
"@winner-fed/utils": "0.
|
|
15
|
+
"@winner-fed/bundler-utils": "1.0.0-rc.0",
|
|
16
|
+
"@winner-fed/utils": "1.0.0-rc.0"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "win-scripts
|
|
22
|
+
"build": "win-scripts tsdown build",
|
|
23
23
|
"build:deps": "win-scripts bundleDeps",
|
|
24
|
-
"dev": "win-scripts
|
|
25
|
-
"test": "
|
|
24
|
+
"dev": "win-scripts tsdown watch",
|
|
25
|
+
"test": "vitest run --root ../.. packages/babel-preset-win/"
|
|
26
26
|
}
|
|
27
27
|
}
|