@vxrn/compiler 1.1.397 → 1.1.398
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/cjs/configure.cjs +1 -0
- package/dist/cjs/configure.js +1 -0
- package/dist/cjs/configure.js.map +1 -1
- package/dist/cjs/index.cjs +57 -7
- package/dist/cjs/index.js +51 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/refresh-runtime.cjs +1 -3
- package/dist/cjs/refresh-runtime.js +1 -1
- package/dist/cjs/refresh-runtime.js.map +1 -1
- package/dist/cjs/transformBabel.cjs +22 -18
- package/dist/cjs/transformBabel.js +19 -22
- package/dist/cjs/transformBabel.js.map +1 -1
- package/dist/cjs/transformSWC.cjs +77 -76
- package/dist/cjs/transformSWC.js +76 -76
- package/dist/cjs/transformSWC.js.map +1 -1
- package/dist/esm/configure.js +1 -0
- package/dist/esm/configure.js.map +1 -1
- package/dist/esm/configure.mjs +1 -0
- package/dist/esm/configure.mjs.map +1 -1
- package/dist/esm/index.js +53 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +58 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/refresh-runtime.js +1 -1
- package/dist/esm/refresh-runtime.js.map +1 -1
- package/dist/esm/refresh-runtime.mjs +1 -3
- package/dist/esm/refresh-runtime.mjs.map +1 -1
- package/dist/esm/transformBabel.js +19 -21
- package/dist/esm/transformBabel.js.map +1 -1
- package/dist/esm/transformBabel.mjs +22 -18
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformSWC.js +77 -77
- package/dist/esm/transformSWC.js.map +1 -1
- package/dist/esm/transformSWC.mjs +78 -77
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/package.json +10 -8
- package/src/configure.ts +2 -0
- package/src/index.ts +108 -11
- package/src/refresh-runtime.js +1 -1
- package/src/transformBabel.ts +36 -17
- package/src/transformSWC.ts +102 -102
- package/types/configure.d.ts +1 -0
- package/types/configure.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/transformBabel.d.ts +1 -1
- package/types/transformBabel.d.ts.map +1 -1
- package/types/transformSWC.d.ts +4 -1
- package/types/transformSWC.d.ts.map +1 -1
- package/dist/cjs/configure.native.js +0 -35
- package/dist/cjs/configure.native.js.map +0 -6
- package/dist/cjs/constants.native.js +0 -65
- package/dist/cjs/constants.native.js.map +0 -6
- package/dist/cjs/index.native.js +0 -123
- package/dist/cjs/index.native.js.map +0 -6
- package/dist/cjs/refresh-runtime.native.js +0 -316
- package/dist/cjs/refresh-runtime.native.js.map +0 -6
- package/dist/cjs/transformBabel.native.js +0 -152
- package/dist/cjs/transformBabel.native.js.map +0 -6
- package/dist/cjs/transformSWC.native.js +0 -275
- package/dist/cjs/transformSWC.native.js.map +0 -6
- package/dist/cjs/types.native.js +0 -15
- package/dist/cjs/types.native.js.map +0 -6
- package/dist/esm/configure.native.js +0 -13
- package/dist/esm/configure.native.js.map +0 -6
- package/dist/esm/constants.native.js +0 -41
- package/dist/esm/constants.native.js.map +0 -6
- package/dist/esm/index.native.js +0 -104
- package/dist/esm/index.native.js.map +0 -6
- package/dist/esm/refresh-runtime.native.js +0 -290
- package/dist/esm/refresh-runtime.native.js.map +0 -6
- package/dist/esm/transformBabel.native.js +0 -125
- package/dist/esm/transformBabel.native.js.map +0 -6
- package/dist/esm/transformSWC.native.js +0 -257
- package/dist/esm/transformSWC.native.js.map +0 -6
- package/dist/esm/types.native.js +0 -1
- package/dist/esm/types.native.js.map +0 -6
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
22
|
-
mod
|
|
23
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
24
|
-
var transformBabel_exports = {};
|
|
25
|
-
__export(transformBabel_exports, {
|
|
26
|
-
getBabelOptions: () => getBabelOptions,
|
|
27
|
-
transformBabel: () => transformBabel
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(transformBabel_exports);
|
|
30
|
-
var import_core = __toESM(require("@babel/core"), 1), import_node_path = require("node:path"), import_configure = require("./configure"), import_constants = require("./constants");
|
|
31
|
-
function getBabelOptions(props) {
|
|
32
|
-
if (props.userSetting === "babel")
|
|
33
|
-
return {
|
|
34
|
-
plugins: getPlugins(props, !0)
|
|
35
|
-
};
|
|
36
|
-
if (typeof props.userSetting > "u" || typeof props.userSetting == "object" && props.userSetting.transform === "babel") {
|
|
37
|
-
var _props_userSetting;
|
|
38
|
-
if (!((_props_userSetting = props.userSetting) === null || _props_userSetting === void 0) && _props_userSetting.excludeDefaultPlugins)
|
|
39
|
-
return props.userSetting;
|
|
40
|
-
var plugins = getPlugins(props);
|
|
41
|
-
if (plugins.length)
|
|
42
|
-
return {
|
|
43
|
-
plugins
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
var getPlugins = function(props) {
|
|
49
|
-
var force = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1, plugins = [];
|
|
50
|
-
return (force || shouldBabelGenerators(props)) && (plugins = getBasePlugins(props)), shouldBabelReanimated(props) && (import_constants.debug === null || import_constants.debug === void 0 || (0, import_constants.debug)("Using babel reanimated on file"), plugins.push("react-native-reanimated/plugin")), shouldBabelReactCompiler(props) && (import_constants.debug === null || import_constants.debug === void 0 || (0, import_constants.debug)("Using babel react compiler on file"), plugins.push(getBabelReactCompilerPlugin(props))), shouldBabelReactNativeCodegen(props) && (import_constants.debug === null || import_constants.debug === void 0 || (0, import_constants.debug)("Using babel @react-native/babel-plugin-codegen on file"), plugins.push("@react-native/babel-plugin-codegen")), plugins;
|
|
51
|
-
};
|
|
52
|
-
async function transformBabel(id, code, options) {
|
|
53
|
-
var _options_plugins, compilerPlugin = (_options_plugins = options.plugins) === null || _options_plugins === void 0 ? void 0 : _options_plugins.find(function(x) {
|
|
54
|
-
return x && x[0] === "babel-plugin-react-compiler";
|
|
55
|
-
}), out = await new Promise(function(res, rej) {
|
|
56
|
-
import_core.default.transform(code, {
|
|
57
|
-
filename: id,
|
|
58
|
-
compact: !1,
|
|
59
|
-
minified: !1,
|
|
60
|
-
presets: [
|
|
61
|
-
"@babel/preset-typescript"
|
|
62
|
-
],
|
|
63
|
-
...options
|
|
64
|
-
}, function(err, result) {
|
|
65
|
-
if (!result || err)
|
|
66
|
-
return rej(err || "no res");
|
|
67
|
-
res(result.code);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
return compilerPlugin && out.includes(compilerPlugin[1] === "18" ? "react-compiler-runtime" : "react/compiler-runtime") && console.info(` \u{1FA84} [compiler] ${(0, import_node_path.relative)(process.cwd(), id)}`), out;
|
|
71
|
-
}
|
|
72
|
-
var getBasePlugins = function(param) {
|
|
73
|
-
var { development } = param;
|
|
74
|
-
return [
|
|
75
|
-
[
|
|
76
|
-
"@babel/plugin-transform-destructuring"
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
"@babel/plugin-transform-react-jsx",
|
|
80
|
-
{
|
|
81
|
-
development
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
[
|
|
85
|
-
"@babel/plugin-transform-async-generator-functions"
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
"@babel/plugin-transform-async-to-generator"
|
|
89
|
-
],
|
|
90
|
-
[
|
|
91
|
-
"@babel/plugin-transform-runtime",
|
|
92
|
-
{
|
|
93
|
-
helpers: !0,
|
|
94
|
-
// NOTE THIS WAS SPELLED WRONG BEFOER THIS COMMIT MAYBE IT WAS UNINTENTIONALLY WORKING
|
|
95
|
-
regenerator: !1
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
];
|
|
99
|
-
}, NATIVE_COMPONENT_RE = /NativeComponent\.[jt]sx?$/, SPEC_FILE_RE = /[\/\\]specs?[\/\\]/, shouldBabelReactNativeCodegen = function(param) {
|
|
100
|
-
var { id, environment } = param;
|
|
101
|
-
return (environment === "ios" || environment === "android") && (NATIVE_COMPONENT_RE.test(id) || SPEC_FILE_RE.test(id));
|
|
102
|
-
}, shouldBabelReactCompiler = function(props) {
|
|
103
|
-
return !(!import_configure.configuration.enableCompiler || Array.isArray(import_configure.configuration.enableCompiler) && !import_configure.configuration.enableCompiler.includes(props.environment) || !/.*(.tsx?)$/.test(props.id) || props.code.startsWith("// disable-compiler"));
|
|
104
|
-
}, getBabelReactCompilerPlugin = function(props) {
|
|
105
|
-
var target = props.reactForRNVersion === "18" && (props.environment === "ios" || props.environment === "android") ? "18" : "19";
|
|
106
|
-
return [
|
|
107
|
-
"babel-plugin-react-compiler",
|
|
108
|
-
{
|
|
109
|
-
target
|
|
110
|
-
}
|
|
111
|
-
];
|
|
112
|
-
};
|
|
113
|
-
function shouldBabelGenerators(param) {
|
|
114
|
-
var { code } = param;
|
|
115
|
-
if (process.env.VXRN_USE_BABEL_FOR_GENERATORS)
|
|
116
|
-
return import_constants.asyncGeneratorRegex.test(code);
|
|
117
|
-
}
|
|
118
|
-
var REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
|
|
119
|
-
"worklet",
|
|
120
|
-
"useAnimatedGestureHandler",
|
|
121
|
-
"useAnimatedScrollHandler",
|
|
122
|
-
"useFrameCallback",
|
|
123
|
-
"useAnimatedStyle",
|
|
124
|
-
"useAnimatedProps",
|
|
125
|
-
"createAnimatedPropAdapter",
|
|
126
|
-
"useDerivedValue",
|
|
127
|
-
"useAnimatedReaction",
|
|
128
|
-
"useWorkletCallback",
|
|
129
|
-
"withTiming",
|
|
130
|
-
"withSpring",
|
|
131
|
-
"withDecay",
|
|
132
|
-
"withRepeat",
|
|
133
|
-
"runOnUI",
|
|
134
|
-
"executeOnUIRuntimeSync"
|
|
135
|
-
], REANIMATED_REGEX = new RegExp(REANIMATED_AUTOWORKLETIZATION_KEYWORDS.join("|")), REANIMATED_IGNORED_PATHS = [
|
|
136
|
-
// React and React Native libraries are not likely to use reanimated.
|
|
137
|
-
// This can also avoid the "[BABEL] Note: The code generator has deoptimised the styling of ... as it exceeds the max of 500KB" warning since the react-native source code also contains `useAnimatedProps`.
|
|
138
|
-
"react-native-prebuilt",
|
|
139
|
-
"node_modules/.vxrn/react-native"
|
|
140
|
-
], REANIMATED_IGNORED_PATHS_REGEX = new RegExp(REANIMATED_IGNORED_PATHS.map(function(s) {
|
|
141
|
-
return s.replace(/\//g, "/");
|
|
142
|
-
}).join("|"));
|
|
143
|
-
function shouldBabelReanimated(param) {
|
|
144
|
-
var { code, id } = param;
|
|
145
|
-
return import_configure.configuration.enableReanimated ? !!(!REANIMATED_IGNORED_PATHS_REGEX.test(id) && REANIMATED_REGEX.test(code)) : !1;
|
|
146
|
-
}
|
|
147
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
148
|
-
0 && (module.exports = {
|
|
149
|
-
getBabelOptions,
|
|
150
|
-
transformBabel
|
|
151
|
-
});
|
|
152
|
-
//# sourceMappingURL=transformBabel.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/one/packages/compiler/src/transformBabel.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;kBAAkB,oCAClB,mBAAyB,sBACzB,mBAA8B,wBAC9B,mBAA2C;AAOpC,SAASA,gBAAgBC,OAAY;AAC1C,MAAIA,MAAMC,gBAAgB;AACxB,WAAO;MACLC,SAASC,WAAWH,OAAO,EAAA;IAC7B;AAEF,MACE,OAAOA,MAAMC,cAAgB,OAC5B,OAAOD,MAAMC,eAAgB,YAAYD,MAAMC,YAAYG,cAAc,SAC1E;QACIJ;AAAJ,QAAIA,wBAAAA,MAAMC,iBAAW,QAAjBD,uBAAAA,WAAAA,mBAAmBK;AACrB,aAAOL,MAAMC;AAEf,QAAMC,UAAUC,WAAWH,KAAAA;AAC3B,QAAIE,QAAQI;AACV,aAAO;QACLJ;MACF;EAEJ;AACA,SAAO;AACT;AAEA,IAAMC,aAAa,SAACH,OAAAA;MAAcO,QAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAQ,IACpCL,UAA8B,CAAA;AAElC,UAAIK,SAASC,sBAAsBR,KAAAA,OACjCE,UAAUO,eAAeT,KAAAA,IAGvBU,sBAAsBV,KAAAA,MACxBW,2BAAAA,QAAAA,2BAAAA,cAAAA,wBAAQ,gCAAgC,GACxCT,QAAQU,KAAK,gCAAA,IAGXC,yBAAyBb,KAAAA,MAC3BW,2BAAAA,QAAAA,2BAAAA,cAAAA,wBAAQ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,SAACb,OAAAA;AAUhC,SATI,GAAC+C,+BAAcC,kBAGfC,MAAMC,QAAQH,+BAAcC,cAAc,KACxC,CAACD,+BAAcC,eAAed,SAASlC,MAAM6C,WAAW,KAI1D,CAAC,aAAaC,KAAK9C,MAAMiB,EAAE,KAC3BjB,MAAMkB,KAAKiC,WAAW,qBAAA;AAG5B,GAEMrC,8BAA8B,SAACd,OAAAA;AACnC,MAAMoD,SACJpD,MAAMqD,sBAAsB,SAC3BrD,MAAM6C,gBAAgB,SAAS7C,MAAM6C,gBAAgB,aAClD,OACA;AAEN,SAAO;IAAC;IAA+B;MAAEO;IAAO;;AAClD;AAMA,SAAS5C,sBAAsB,OAAe;MAAf,EAAEU,KAAI,IAAN;AAC7B,MAAIoB,QAAQgB,IAAIC;AACd,WAAOC,qCAAoBV,KAAK5B,IAAAA;AAEpC;AASA,IAAMuC,yCAAyC;EAC7C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;GAMIC,mBAAmB,IAAIC,OAAOF,uCAAuCG,KAAK,GAAA,CAAA,GAE1EC,2BAA2B;;;EAG/B;EACA;GAGIC,iCAAiC,IAAIH,OACzCE,yBAAyBE,IAAI,SAACC,GAAAA;SAAMA,EAAEC,QAAQ,OAAO,GAAA;GAAML,KAAK,GAAA,CAAA;AAGlE,SAASlD,sBAAsB,OAAmB;MAAnB,EAAEQ,MAAMD,GAAE,IAAV;AAC7B,SAAK8B,+BAAcmB,mBAGf,IAACJ,+BAA+BhB,KAAK7B,EAAAA,KAAOyC,iBAAiBZ,KAAK5B,IAAAA,KAF7D;AAOX;",
|
|
5
|
-
"names": ["getBabelOptions", "props", "userSetting", "plugins", "getPlugins", "transform", "excludeDefaultPlugins", "length", "force", "shouldBabelGenerators", "getBasePlugins", "shouldBabelReanimated", "debug", "push", "shouldBabelReactCompiler", "getBabelReactCompilerPlugin", "shouldBabelReactNativeCodegen", "transformBabel", "id", "code", "options", "compilerPlugin", "find", "x", "out", "Promise", "res", "rej", "babel", "filename", "compact", "minified", "presets", "err", "result", "includes", "console", "info", "relative", "process", "cwd", "development", "helpers", "regenerator", "NATIVE_COMPONENT_RE", "SPEC_FILE_RE", "environment", "test", "configuration", "enableCompiler", "Array", "isArray", "startsWith", "target", "reactForRNVersion", "env", "VXRN_USE_BABEL_FOR_GENERATORS", "asyncGeneratorRegex", "REANIMATED_AUTOWORKLETIZATION_KEYWORDS", "REANIMATED_REGEX", "RegExp", "join", "REANIMATED_IGNORED_PATHS", "REANIMATED_IGNORED_PATHS_REGEX", "map", "s", "replace", "enableReanimated"]
|
|
6
|
-
}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
16
|
-
var transformSWC_exports = {};
|
|
17
|
-
__export(transformSWC_exports, {
|
|
18
|
-
transformSWC: () => transformSWC,
|
|
19
|
-
transformSWCStripJSX: () => transformSWCStripJSX
|
|
20
|
-
});
|
|
21
|
-
module.exports = __toCommonJS(transformSWC_exports);
|
|
22
|
-
var import_core = require("@swc/core"), import_node_path = require("node:path"), import_ts_deepmerge = require("ts-deepmerge"), import_configure = require("./configure"), import_constants = require("./constants");
|
|
23
|
-
async function transformSWC(id, code, options, swcOptions) {
|
|
24
|
-
if (!id.includes(".vite") && (id = id.split("?")[0].replace(process.cwd(), ""), id !== import_constants.runtimePublicPath)) {
|
|
25
|
-
var parser = getParser(id, options.forceJSX);
|
|
26
|
-
if (parser) {
|
|
27
|
-
var enableNativeCSS = import_configure.configuration.enableNativeCSS && // temp fix idk why this error:
|
|
28
|
-
// node_modules/react-native-reanimated/src/component/LayoutAnimationConfig.tsx (19:9): "createInteropElement" is not exported by "../../node_modules/react-native-css-interop/dist/runtime/jsx-dev-runtime.js", imported by "node_modules/react-native-reanimated/src/component/LayoutAnimationConfig.tsx
|
|
29
|
-
!id.includes("node_modules"), refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX, reactConfig = {
|
|
30
|
-
refresh,
|
|
31
|
-
development: !options.forceJSX && !options.production,
|
|
32
|
-
runtime: "automatic",
|
|
33
|
-
importSource: "react",
|
|
34
|
-
...enableNativeCSS ? {
|
|
35
|
-
importSource: "react-native-css-interop",
|
|
36
|
-
pragma: "createInteropElement",
|
|
37
|
-
// swc doesnt actually change the import right
|
|
38
|
-
runtime: "classic"
|
|
39
|
-
} : {}
|
|
40
|
-
}, transformOptions = function() {
|
|
41
|
-
if (options.environment === "client" || options.environment === "ssr")
|
|
42
|
-
return {
|
|
43
|
-
sourceMaps: !0,
|
|
44
|
-
jsc: {
|
|
45
|
-
target: "es2020",
|
|
46
|
-
parser,
|
|
47
|
-
transform: {
|
|
48
|
-
useDefineForClassFields: !0,
|
|
49
|
-
react: reactConfig
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var shouldEs5Transform = options.es5 || !process.env.VXRN_USE_BABEL_FOR_GENERATORS && import_constants.asyncGeneratorRegex.test(code), opts = shouldEs5Transform ? {
|
|
54
|
-
jsc: {
|
|
55
|
-
parser,
|
|
56
|
-
target: "es5",
|
|
57
|
-
transform: {
|
|
58
|
-
useDefineForClassFields: !0,
|
|
59
|
-
react: reactConfig
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} : {
|
|
63
|
-
...!options.forceJSX && {
|
|
64
|
-
env: SWC_ENV
|
|
65
|
-
},
|
|
66
|
-
jsc: {
|
|
67
|
-
...options.forceJSX && {
|
|
68
|
-
target: "esnext"
|
|
69
|
-
},
|
|
70
|
-
parser,
|
|
71
|
-
transform: {
|
|
72
|
-
useDefineForClassFields: !0,
|
|
73
|
-
react: reactConfig
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
sourceMaps: shouldSourceMap(),
|
|
79
|
-
module: {
|
|
80
|
-
importInterop: "none",
|
|
81
|
-
type: "nodenext"
|
|
82
|
-
},
|
|
83
|
-
...options.mode === "serve-cjs" && {
|
|
84
|
-
module: {
|
|
85
|
-
importInterop: "none",
|
|
86
|
-
type: "commonjs",
|
|
87
|
-
strict: !0
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
...opts
|
|
91
|
-
};
|
|
92
|
-
}(), finalOptions = (0, import_ts_deepmerge.merge)({
|
|
93
|
-
filename: id,
|
|
94
|
-
swcrc: !1,
|
|
95
|
-
configFile: !1,
|
|
96
|
-
...transformOptions
|
|
97
|
-
}, swcOptions || {}), result = await async function() {
|
|
98
|
-
try {
|
|
99
|
-
return import_constants.debug === null || import_constants.debug === void 0 || (0, import_constants.debug)(`transformSWC ${id} using options:
|
|
100
|
-
${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(code, finalOptions);
|
|
101
|
-
} catch (e) {
|
|
102
|
-
var message = e.message, fileStartIndex = message.indexOf("\u256D\u2500[");
|
|
103
|
-
if (fileStartIndex !== -1) {
|
|
104
|
-
var match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
|
|
105
|
-
match && (e.line = match[1], e.column = match[2]);
|
|
106
|
-
}
|
|
107
|
-
throw e;
|
|
108
|
-
}
|
|
109
|
-
}();
|
|
110
|
-
enableNativeCSS && result.code.includes("createInteropElement") && (result.code = `import { createInteropElement } from 'react-native-css-interop/jsx-dev-runtime'
|
|
111
|
-
${result.code}`);
|
|
112
|
-
var shouldHMR = refresh && refreshContentRE.test(result.code);
|
|
113
|
-
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
114
|
-
var typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
115
|
-
if (typeExportsMatch) {
|
|
116
|
-
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
117
|
-
try {
|
|
118
|
-
for (var _iterator = Array.from(typeExportsMatch)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
119
|
-
var typeExport = _step.value, [_export, _type, name] = typeExport.split(/\s+/);
|
|
120
|
-
if (!name.startsWith("{") && !name.includes("<")) {
|
|
121
|
-
var alreadyExported = new RegExp(`export (const|let|class|function) ${name}\\s+`).test(result.code);
|
|
122
|
-
if (!alreadyExported) {
|
|
123
|
-
var fakeExport = `export let ${name} = {};`;
|
|
124
|
-
console.info(` \u26A0\uFE0F Fixing non-type-specifc import in node_module, this should be fixed upstream: ${fakeExport} in ${id}`), result.code += `
|
|
125
|
-
${fakeExport}
|
|
126
|
-
`;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
} catch (err) {
|
|
131
|
-
_didIteratorError = !0, _iteratorError = err;
|
|
132
|
-
} finally {
|
|
133
|
-
try {
|
|
134
|
-
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
135
|
-
} finally {
|
|
136
|
-
if (_didIteratorError)
|
|
137
|
-
throw _iteratorError;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return !result || options.noHMR || !shouldHMR ? result : (wrapSourceInRefreshRuntime(id, result, options, shouldHMR), {
|
|
143
|
-
code: result.code
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
var SWC_ENV = {
|
|
149
|
-
targets: {
|
|
150
|
-
node: "4"
|
|
151
|
-
},
|
|
152
|
-
// debug: true,
|
|
153
|
-
include: [],
|
|
154
|
-
// this breaks the uniswap app for any file with a ...spread
|
|
155
|
-
exclude: [
|
|
156
|
-
"transform-spread",
|
|
157
|
-
"transform-destructuring",
|
|
158
|
-
"transform-object-rest-spread",
|
|
159
|
-
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
160
|
-
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
161
|
-
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
162
|
-
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
163
|
-
"transform-async-to-generator",
|
|
164
|
-
"transform-regenerator"
|
|
165
|
-
]
|
|
166
|
-
}, refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
167
|
-
function shouldSourceMap() {
|
|
168
|
-
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
169
|
-
}
|
|
170
|
-
function wrapSourceInRefreshRuntime(id, result, options, shouldHMR) {
|
|
171
|
-
return options.environment === "client" || options.environment === "ssr" ? wrapSourceInRefreshRuntimeWeb(id, result, shouldHMR) : wrapSourceInRefreshRuntimeNative(id, result, options, shouldHMR);
|
|
172
|
-
}
|
|
173
|
-
function wrapSourceInRefreshRuntimeWeb(id, result, shouldHMR) {
|
|
174
|
-
var sourceMap = JSON.parse(result.map);
|
|
175
|
-
sourceMap.mappings = ";;" + sourceMap.mappings, result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
176
|
-
|
|
177
|
-
${result.code}`, shouldHMR && (sourceMap.mappings = ";;;;;;" + sourceMap.mappings, result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
178
|
-
const prevRefreshReg = window.$RefreshReg$;
|
|
179
|
-
const prevRefreshSig = window.$RefreshSig$;
|
|
180
|
-
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
181
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
182
|
-
|
|
183
|
-
${result.code}
|
|
184
|
-
|
|
185
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
186
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
187
|
-
`), result.code += `
|
|
188
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
189
|
-
RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
|
|
190
|
-
import.meta.hot.accept((nextExports) => {
|
|
191
|
-
if (!nextExports) return;
|
|
192
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate("${id}", currentExports, nextExports);
|
|
193
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
198
|
-
function wrapSourceInRefreshRuntimeNative(id, result, options, shouldHMR) {
|
|
199
|
-
var prefixCode = options.mode === "build" ? `
|
|
200
|
-
import 'react-native'
|
|
201
|
-
import 'react'
|
|
202
|
-
import '@vxrn/vite-native-client'
|
|
203
|
-
` : "";
|
|
204
|
-
if (options.production)
|
|
205
|
-
return `
|
|
206
|
-
${prefixCode}
|
|
207
|
-
module.url = '${id}'
|
|
208
|
-
${result.code}
|
|
209
|
-
`;
|
|
210
|
-
shouldHMR && (result.code = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
211
|
-
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
212
|
-
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
213
|
-
console.info("no react refresh setup!")
|
|
214
|
-
return (x) => x
|
|
215
|
-
});
|
|
216
|
-
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
217
|
-
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
218
|
-
|
|
219
|
-
${prefixCode}
|
|
220
|
-
|
|
221
|
-
module.url = '${id}'
|
|
222
|
-
module.hot = createHotContext(module.url)
|
|
223
|
-
|
|
224
|
-
${result.code}
|
|
225
|
-
|
|
226
|
-
if (module.hot) {
|
|
227
|
-
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
228
|
-
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
229
|
-
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
230
|
-
}
|
|
231
|
-
`), result.code = `${result.code}
|
|
232
|
-
|
|
233
|
-
if (module.hot) {
|
|
234
|
-
if (module.hot.accept) {
|
|
235
|
-
module.hot.accept((nextExports) => {
|
|
236
|
-
RefreshRuntime.performReactRefresh()
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}`;
|
|
240
|
-
}
|
|
241
|
-
function getParser(id) {
|
|
242
|
-
var forceJSX = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
|
243
|
-
if (id.endsWith("one-entry-native"))
|
|
244
|
-
return import_constants.parsers[".tsx"];
|
|
245
|
-
var extension = (0, import_node_path.extname)(id), parser = extension ? import_constants.parsers[extension] : import_constants.parsers[".js"];
|
|
246
|
-
return extension === ".js" && (forceJSX && (parser = import_constants.parsers[".jsx"]), id.includes("expo-modules-core") && (parser = import_constants.parsers[".jsx"])), parser;
|
|
247
|
-
}
|
|
248
|
-
var transformSWCStripJSX = async function(id, code) {
|
|
249
|
-
var parser = getParser(id);
|
|
250
|
-
if (parser)
|
|
251
|
-
return await (0, import_core.transform)(code, {
|
|
252
|
-
filename: id,
|
|
253
|
-
swcrc: !1,
|
|
254
|
-
configFile: !1,
|
|
255
|
-
sourceMaps: shouldSourceMap(),
|
|
256
|
-
jsc: {
|
|
257
|
-
target: "es2019",
|
|
258
|
-
parser,
|
|
259
|
-
transform: {
|
|
260
|
-
useDefineForClassFields: !0,
|
|
261
|
-
react: {
|
|
262
|
-
development: !0,
|
|
263
|
-
runtime: "automatic",
|
|
264
|
-
refresh: !1
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
271
|
-
0 && (module.exports = {
|
|
272
|
-
transformSWC,
|
|
273
|
-
transformSWCStripJSX
|
|
274
|
-
});
|
|
275
|
-
//# sourceMappingURL=transformSWC.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/one/packages/compiler/src/transformSWC.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;kBAMO,sBAEP,mBAAwB,sBACxB,sBAAsB,yBACtB,mBAA8B,wBAC9B,mBAAuE;AAGvE,eAAsBA,aACpBC,IACAC,MACAC,SACAC,YAAuB;AAEvB,MAAIH,IAAGI,SAAS,OAAA,MAIhBJ,KAAKA,GACFK,MAAM,GAAA,EAAK,CAAA,EAEXC,QAAQC,QAAQC,IAAG,GAAI,EAAA,GAEtBR,OAAOS,qCAIX;QAAMC,SAASC,UAAUX,IAAIE,QAAQU,QAAQ;AAE7C,QAAKF,QAIL;UAAMG,kBACJC,+BAAcD;;MAGd,CAACb,GAAGI,SAAS,cAAA,GAETW,UACJb,QAAQc,gBAAgB,SAAS,CAACd,QAAQe,cAAc,CAACf,QAAQgB,SAAS,CAAChB,QAAQU,UAE/EO,cAAc;QAClBJ;QACAK,aAAa,CAAClB,QAAQU,YAAY,CAACV,QAAQe;QAC3CI,SAAS;QACTC,cAAc;QACd,GAAIT,kBACA;UACES,cAAc;UACdC,QAAQ;;UAERF,SAAS;QACX,IACA,CAAC;MACP,GAEMG,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OAAOjD,OAAO,GAAGiD,OAAOjD,IAAI;;;;;;;;;AAS9B;AAEA,SAASU,UAAUX,IAAU;MAAEY,WAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAW;AACxC,MAAIZ,GAAG4F,SAAS,kBAAA;AACd,WAAOC,yBAAQ,MAAA;AAGjB,MAAMC,gBAAYC,0BAAQ/F,EAAAA,GACtBU,SAAwBoF,YAA6BD,yBAAQC,SAAAA,IAAzBD,yBAAQ,KAAA;AAEhD,SAAIC,cAAc,UACZlF,aACFF,SAASmF,yBAAQ,MAAA,IAGf7F,GAAGI,SAAS,mBAAA,MACdM,SAASmF,yBAAQ,MAAA,KAIdnF;AACT;AAEO,IAAMsF,uBAAuB,eAAOhG,IAAYC,MAAAA;AACrD,MAAMS,SAASC,UAAUX,EAAAA;AACzB,MAAKU;AACL,WAAO,UAAMkB,uBAAU3B,MAAM;MAC3B8C,UAAU/C;MACVgD,OAAO;MACPC,YAAY;MACZxB,YAAYc,gBAAAA;MACZb,KAAK;QACHC,QAAQ;QACRjB;QACAkB,WAAW;UACTC,yBAAyB;UACzBC,OAAO;YACLV,aAAa;YACbC,SAAS;YACTN,SAAS;UACX;QACF;MACF;IACF,CAAA;AACF;",
|
|
5
|
-
"names": ["transformSWC", "id", "code", "options", "swcOptions", "includes", "split", "replace", "process", "cwd", "runtimePublicPath", "parser", "getParser", "forceJSX", "enableNativeCSS", "configuration", "refresh", "environment", "production", "noHMR", "reactConfig", "development", "runtime", "importSource", "pragma", "transformOptions", "sourceMaps", "jsc", "target", "transform", "useDefineForClassFields", "react", "shouldEs5Transform", "es5", "env", "VXRN_USE_BABEL_FOR_GENERATORS", "asyncGeneratorRegex", "test", "opts", "SWC_ENV", "shouldSourceMap", "module", "importInterop", "type", "mode", "strict", "finalOptions", "merge", "filename", "swcrc", "configFile", "result", "debug", "JSON", "stringify", "e", "message", "fileStartIndex", "indexOf", "match", "slice", "line", "column", "shouldHMR", "refreshContentRE", "fixNonTypeSpecificImports", "syntax", "typeExportsMatch", "Array", "from", "typeExport", "_export", "_type", "name", "startsWith", "alreadyExported", "RegExp", "fakeExport", "console", "info", "wrapSourceInRefreshRuntime", "targets", "node", "include", "exclude", "VXRN_ENABLE_SOURCE_MAP", "wrapSourceInRefreshRuntimeWeb", "wrapSourceInRefreshRuntimeNative", "sourceMap", "parse", "map", "mappings", "prefixCode", "endsWith", "parsers", "extension", "extname", "transformSWCStripJSX"]
|
|
6
|
-
}
|
package/dist/cjs/types.native.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
return to;
|
|
11
|
-
};
|
|
12
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
13
|
-
var types_exports = {};
|
|
14
|
-
module.exports = __toCommonJS(types_exports);
|
|
15
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var configuration = {
|
|
2
|
-
enableReanimated: !1,
|
|
3
|
-
enableCompiler: !1,
|
|
4
|
-
enableNativeCSS: !1
|
|
5
|
-
};
|
|
6
|
-
function configureVXRNCompilerPlugin(_) {
|
|
7
|
-
Object.assign(configuration, _);
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
configuration,
|
|
11
|
-
configureVXRNCompilerPlugin
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=configure.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/one/packages/compiler/src/configure.ts"],
|
|
4
|
-
"mappings": "AAQO,IAAMA,gBAAsB;EACjCC,kBAAkB;EAClBC,gBAAgB;EAChBC,iBAAiB;AACnB;AAEO,SAASC,4BAA4BC,GAAO;AACjDC,SAAOC,OAAOP,eAAeK,CAAAA;AAC/B;",
|
|
5
|
-
"names": ["configuration", "enableReanimated", "enableCompiler", "enableNativeCSS", "configureVXRNCompilerPlugin", "_", "Object", "assign"]
|
|
6
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createDebugger } from "@vxrn/utils";
|
|
2
|
-
var { debug } = createDebugger("vxrn:compiler-plugin"), runtimePublicPath = "/@react-refresh", asyncGeneratorRegex = /(async \*|async function\*|for await)/, parsers = {
|
|
3
|
-
".tsx": {
|
|
4
|
-
syntax: "typescript",
|
|
5
|
-
tsx: !0,
|
|
6
|
-
decorators: !0
|
|
7
|
-
},
|
|
8
|
-
".ts": {
|
|
9
|
-
syntax: "typescript",
|
|
10
|
-
tsx: !1,
|
|
11
|
-
decorators: !0
|
|
12
|
-
},
|
|
13
|
-
".jsx": {
|
|
14
|
-
syntax: "ecmascript",
|
|
15
|
-
jsx: !0
|
|
16
|
-
},
|
|
17
|
-
".js": {
|
|
18
|
-
syntax: "ecmascript"
|
|
19
|
-
},
|
|
20
|
-
".mjs": {
|
|
21
|
-
syntax: "ecmascript"
|
|
22
|
-
},
|
|
23
|
-
".cjs": {
|
|
24
|
-
syntax: "ecmascript"
|
|
25
|
-
},
|
|
26
|
-
".mdx": {
|
|
27
|
-
syntax: "ecmascript",
|
|
28
|
-
jsx: !0
|
|
29
|
-
}
|
|
30
|
-
}, validParsers = /* @__PURE__ */ new Set([
|
|
31
|
-
...Object.keys(parsers),
|
|
32
|
-
".css"
|
|
33
|
-
]);
|
|
34
|
-
export {
|
|
35
|
-
asyncGeneratorRegex,
|
|
36
|
-
debug,
|
|
37
|
-
parsers,
|
|
38
|
-
runtimePublicPath,
|
|
39
|
-
validParsers
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Users/n8/one/packages/compiler/src/constants.ts"],
|
|
4
|
-
"mappings": "AAEA,SAASA,sBAAsB;AAExB,IAAM,EAAEC,MAAK,IAAKD,eAAe,sBAAA,GAE3BE,oBAAoB,mBAEpBC,sBAAsB,yCAEtBC,UAAwC;EACnD,QAAQ;IAAEC,QAAQ;IAAcC,KAAK;IAAMC,YAAY;EAAK;EAC5D,OAAO;IAAEF,QAAQ;IAAcC,KAAK;IAAOC,YAAY;EAAK;EAC5D,QAAQ;IAAEF,QAAQ;IAAcG,KAAK;EAAK;EAC1C,OAAO;IAAEH,QAAQ;EAAa;EAC9B,QAAQ;IAAEA,QAAQ;EAAa;EAC/B,QAAQ;IAAEA,QAAQ;EAAa;EAC/B,QAAQ;IAAEA,QAAQ;IAAcG,KAAK;EAAK;AAC5C,GAEaC,eAAe,oBAAIC,IAAI;KAAIC,OAAOC,KAAKR,OAAAA;EAAU;CAAO;",
|
|
5
|
-
"names": ["createDebugger", "debug", "runtimePublicPath", "asyncGeneratorRegex", "parsers", "syntax", "tsx", "decorators", "jsx", "validParsers", "Set", "Object", "keys"]
|
|
6
|
-
}
|
package/dist/esm/index.native.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { resolvePath } from "@vxrn/utils";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { extname, join } from "node:path";
|
|
5
|
-
import { debug, runtimePublicPath, validParsers } from "./constants";
|
|
6
|
-
import { getBabelOptions, transformBabel } from "./transformBabel";
|
|
7
|
-
import { transformSWC } from "./transformSWC";
|
|
8
|
-
export * from "./configure";
|
|
9
|
-
export * from "./transformBabel";
|
|
10
|
-
export * from "./transformSWC";
|
|
11
|
-
async function createVXRNCompilerPlugin(optionsIn) {
|
|
12
|
-
var reactVersion = await async function() {
|
|
13
|
-
var path = resolvePath("react/package.json"), json = JSON.parse(await readFile(path, "utf-8"));
|
|
14
|
-
return json.version;
|
|
15
|
-
}(), envNames = {
|
|
16
|
-
ios: !0,
|
|
17
|
-
android: !0,
|
|
18
|
-
client: !0,
|
|
19
|
-
ssr: !0
|
|
20
|
-
};
|
|
21
|
-
function getEnvName(name) {
|
|
22
|
-
if (!envNames[name]) throw new Error(`Invalid env: ${name}`);
|
|
23
|
-
return name;
|
|
24
|
-
}
|
|
25
|
-
return [
|
|
26
|
-
{
|
|
27
|
-
name: "one:compiler-resolve-refresh-runtime",
|
|
28
|
-
apply: "serve",
|
|
29
|
-
enforce: "pre",
|
|
30
|
-
// Run before Vite default resolve to avoid syscalls
|
|
31
|
-
resolveId: function(id) {
|
|
32
|
-
return id === runtimePublicPath ? id : void 0;
|
|
33
|
-
},
|
|
34
|
-
load: function(id) {
|
|
35
|
-
return id === runtimePublicPath ? readFileSync(join(import.meta.dirname, "refresh-runtime.js"), "utf-8") : void 0;
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "one:compiler",
|
|
40
|
-
enforce: "pre",
|
|
41
|
-
config: function() {
|
|
42
|
-
var config = {
|
|
43
|
-
esbuild: !1,
|
|
44
|
-
optimizeDeps: {
|
|
45
|
-
noDiscovery: !0
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
49
|
-
environments: {
|
|
50
|
-
ios: config,
|
|
51
|
-
android: config
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
transform: {
|
|
56
|
-
order: "pre",
|
|
57
|
-
async handler(codeIn, _id) {
|
|
58
|
-
var _optionsIn_transform, code = codeIn, shouldDebug = process.env.NODE_ENV === "development" && codeIn.startsWith("// debug");
|
|
59
|
-
shouldDebug && (console.info(`[one] ${_id} input:`), console.info(codeIn));
|
|
60
|
-
var extension = extname(_id);
|
|
61
|
-
if (validParsers.has(extension)) {
|
|
62
|
-
var id = _id.split("?")[0], isPreProcess = id.startsWith("vxrn-swc-preprocess:");
|
|
63
|
-
if (isPreProcess && (id = id.replace("vxrn-swc-preprocess:", "")), !id.includes("virtual:")) {
|
|
64
|
-
var environment = getEnvName(this.environment.name), production = process.env.NODE_ENV === "production", transformProps = {
|
|
65
|
-
id,
|
|
66
|
-
code,
|
|
67
|
-
development: !production,
|
|
68
|
-
environment,
|
|
69
|
-
reactForRNVersion: reactVersion.split(".")[0]
|
|
70
|
-
}, userTransform = optionsIn == null || (_optionsIn_transform = optionsIn.transform) === null || _optionsIn_transform === void 0 ? void 0 : _optionsIn_transform.call(optionsIn, transformProps);
|
|
71
|
-
if (userTransform !== !1) {
|
|
72
|
-
if (!isPreProcess && userTransform !== "swc") {
|
|
73
|
-
var babelOptions = getBabelOptions({
|
|
74
|
-
...transformProps,
|
|
75
|
-
userSetting: userTransform
|
|
76
|
-
});
|
|
77
|
-
if (babelOptions) {
|
|
78
|
-
var babelOut = await transformBabel(id, code, babelOptions);
|
|
79
|
-
babelOut && (debug === null || debug === void 0 || debug(`[${id}] transformed with babel options: ${JSON.stringify(babelOptions)}`), code = babelOut);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
var swcOptions = {
|
|
83
|
-
environment,
|
|
84
|
-
mode: "serve",
|
|
85
|
-
production,
|
|
86
|
-
...optionsIn
|
|
87
|
-
}, out = await transformSWC(id, code, {
|
|
88
|
-
...swcOptions,
|
|
89
|
-
es5: !0,
|
|
90
|
-
noHMR: isPreProcess
|
|
91
|
-
});
|
|
92
|
-
return shouldDebug && (console.info("swcOptions", swcOptions), console.info("final output:", out?.code)), out;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
createVXRNCompilerPlugin
|
|
103
|
-
};
|
|
104
|
-
//# sourceMappingURL=index.js.map
|