@vxrn/compiler 1.27.1 → 2.0.0-beta.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cache.cjs +106 -117
- package/dist/cjs/configure.cjs +26 -28
- package/dist/cjs/constants.cjs +56 -60
- package/dist/cjs/index.cjs +420 -443
- package/dist/cjs/reactNativeCodegen.cjs +105 -114
- package/dist/cjs/reactNativeViewConfig.cjs +362 -381
- package/dist/cjs/refresh-runtime.cjs +390 -397
- package/dist/cjs/transformBabel.cjs +273 -263
- package/dist/cjs/transformHermesAsync.cjs +36 -47
- package/dist/cjs/transformHermesLoops.cjs +279 -281
- package/dist/cjs/transformSWC.cjs +183 -200
- package/dist/cjs/transformWorklets.cjs +107 -95
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/worklets/autoworklet.cjs +277 -222
- package/dist/cjs/worklets/globals.cjs +124 -60
- package/dist/cjs/worklets/hash.cjs +23 -27
- package/dist/cjs/worklets/scope.cjs +338 -359
- package/dist/cjs/worklets/serialize.cjs +73 -75
- package/dist/cjs/worklets/transform.cjs +217 -222
- package/dist/cjs/worklets/types.cjs +9 -11
- package/dist/esm/cache.mjs +90 -97
- package/dist/esm/cache.mjs.map +1 -1
- package/dist/esm/configure.mjs +11 -10
- package/dist/esm/configure.mjs.map +1 -1
- package/dist/esm/constants.mjs +41 -41
- package/dist/esm/constants.mjs.map +1 -1
- package/dist/esm/index.js +417 -425
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +417 -425
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/reactNativeCodegen.mjs +90 -88
- package/dist/esm/reactNativeCodegen.mjs.map +1 -1
- package/dist/esm/reactNativeViewConfig.mjs +347 -362
- package/dist/esm/reactNativeViewConfig.mjs.map +1 -1
- package/dist/esm/refresh-runtime.mjs +372 -376
- package/dist/esm/refresh-runtime.mjs.map +1 -1
- package/dist/esm/transformBabel.mjs +255 -237
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformHermesAsync.mjs +20 -21
- package/dist/esm/transformHermesAsync.mjs.map +1 -1
- package/dist/esm/transformHermesLoops.mjs +264 -255
- package/dist/esm/transformHermesLoops.mjs.map +1 -1
- package/dist/esm/transformSWC.mjs +163 -171
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/dist/esm/transformWorklets.mjs +89 -69
- package/dist/esm/transformWorklets.mjs.map +1 -1
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/worklets/autoworklet.mjs +258 -200
- package/dist/esm/worklets/autoworklet.mjs.map +1 -1
- package/dist/esm/worklets/globals.mjs +109 -42
- package/dist/esm/worklets/globals.mjs.map +1 -1
- package/dist/esm/worklets/hash.mjs +10 -9
- package/dist/esm/worklets/hash.mjs.map +1 -1
- package/dist/esm/worklets/scope.mjs +325 -341
- package/dist/esm/worklets/scope.mjs.map +1 -1
- package/dist/esm/worklets/serialize.mjs +60 -58
- package/dist/esm/worklets/serialize.mjs.map +1 -1
- package/dist/esm/worklets/transform.mjs +201 -197
- package/dist/esm/worklets/transform.mjs.map +1 -1
- package/dist/esm/worklets/types.mjs +0 -2
- package/package.json +7 -6
- package/src/transformBabel.test.ts +77 -17
- package/src/transformBabel.ts +28 -12
- package/types/transformBabel.d.ts +12 -0
- package/types/transformBabel.d.ts.map +1 -1
- package/types/transformSWC.d.ts +1 -4
- package/types/transformSWC.d.ts.map +1 -1
- package/dist/cjs/transformBabel.test.cjs +0 -652
- package/dist/cjs/transformHermesLoops.test.cjs +0 -257
- package/dist/cjs/transformSWC.test.cjs +0 -117
- package/dist/cjs/transformWorklets.test.cjs +0 -604
- package/dist/esm/transformBabel.test.mjs +0 -629
- package/dist/esm/transformBabel.test.mjs.map +0 -1
- package/dist/esm/transformHermesLoops.test.mjs +0 -234
- package/dist/esm/transformHermesLoops.test.mjs.map +0 -1
- package/dist/esm/transformSWC.test.mjs +0 -118
- package/dist/esm/transformSWC.test.mjs.map +0 -1
- package/dist/esm/transformWorklets.test.mjs +0 -581
- package/dist/esm/transformWorklets.test.mjs.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/worklets/types.mjs.map +0 -1
- package/types/transformBabel.test.d.ts +0 -2
- package/types/transformBabel.test.d.ts.map +0 -1
- package/types/transformHermesLoops.test.d.ts +0 -2
- package/types/transformHermesLoops.test.d.ts.map +0 -1
- package/types/transformSWC.test.d.ts +0 -2
- package/types/transformSWC.test.d.ts.map +0 -1
- package/types/transformWorklets.test.d.ts +0 -2
- package/types/transformWorklets.test.d.ts.map +0 -1
|
@@ -5,38 +5,32 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
30
25
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var transformBabel_exports = {};
|
|
35
28
|
__export(transformBabel_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
findUserBabelConfig: () => findUserBabelConfig,
|
|
30
|
+
getBabelOptions: () => getBabelOptions,
|
|
31
|
+
stripFlowTypes: () => stripFlowTypes,
|
|
32
|
+
transformBabel: () => transformBabel,
|
|
33
|
+
transformOxcReactCompiler: () => transformOxcReactCompiler
|
|
40
34
|
});
|
|
41
35
|
module.exports = __toCommonJS(transformBabel_exports);
|
|
42
36
|
var import_node_fs = require("node:fs");
|
|
@@ -45,260 +39,276 @@ var import_utils = require("@vxrn/utils");
|
|
|
45
39
|
var import_vite = require("vite");
|
|
46
40
|
var import_configure = require("./configure.cjs");
|
|
47
41
|
var import_constants = require("./constants.cjs");
|
|
48
|
-
const USER_BABEL_CONFIG_FILES = [
|
|
49
|
-
|
|
42
|
+
const USER_BABEL_CONFIG_FILES = [
|
|
43
|
+
"babel.config.js",
|
|
44
|
+
"babel.config.cjs",
|
|
45
|
+
"babel.config.mjs",
|
|
46
|
+
"babel.config.json",
|
|
47
|
+
".babelrc",
|
|
48
|
+
".babelrc.js",
|
|
49
|
+
".babelrc.json"
|
|
50
|
+
];
|
|
51
|
+
const ONE_GENERATED_MARKER = "@one/generated bundler-config";
|
|
50
52
|
function findUserBabelConfig(projectRoot) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
if (!projectRoot) return null;
|
|
54
|
+
for (const name of USER_BABEL_CONFIG_FILES) {
|
|
55
|
+
const fullPath = (0, import_node_path.join)(projectRoot, name);
|
|
56
|
+
if ((0, import_node_fs.existsSync)(fullPath)) {
|
|
57
|
+
try {
|
|
58
|
+
const content = (0, import_node_fs.readFileSync)(fullPath, "utf8");
|
|
59
|
+
if (content.includes(ONE_GENERATED_MARKER)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
return fullPath;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
67
69
|
}
|
|
68
70
|
function getBabelOptions(props) {
|
|
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
|
-
|
|
71
|
+
props = {
|
|
72
|
+
...props,
|
|
73
|
+
id: (0, import_vite.normalizePath)(props.id.split("?")[0])
|
|
74
|
+
};
|
|
75
|
+
const isProjectFile = !props.id.includes("node_modules");
|
|
76
|
+
const userBabelConfig = isProjectFile && props.projectRoot ? findUserBabelConfig(props.projectRoot) : null;
|
|
77
|
+
if (props.userSetting === "babel") {
|
|
78
|
+
return getOptions(props, true, userBabelConfig);
|
|
79
|
+
}
|
|
80
|
+
if (typeof props.userSetting === "undefined" || typeof props.userSetting === "object" && props.userSetting.transform === "babel") {
|
|
81
|
+
if (props.userSetting?.excludeDefaultPlugins) {
|
|
82
|
+
return {
|
|
83
|
+
...props.userSetting,
|
|
84
|
+
...userBabelConfig ? {
|
|
85
|
+
configFile: userBabelConfig,
|
|
86
|
+
babelrc: true
|
|
87
|
+
} : {}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return getOptions(props, false, userBabelConfig);
|
|
91
|
+
}
|
|
92
|
+
const userSetting = props.userSetting;
|
|
93
|
+
if (userSetting === "swc" || userSetting === "oxc" || userSetting === false || typeof userSetting === "object" && userSetting !== null && (userSetting.transform === "swc" || userSetting.transform === "oxc")) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (userBabelConfig) {
|
|
97
|
+
return getOptions(props, false, userBabelConfig);
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
98
100
|
}
|
|
99
101
|
const getOptions = (props, force = false, userBabelConfig = null) => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} : {})
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
return null;
|
|
102
|
+
let plugins = [];
|
|
103
|
+
if (force || shouldBabelGenerators(props)) {
|
|
104
|
+
plugins = getBasePlugins(props);
|
|
105
|
+
}
|
|
106
|
+
const enableNativewind = import_configure.configuration.enableNativewind && (props.environment === "ios" || props.environment === "android") && !/node_modules/.test(props.id) && props.code.includes("createElement");
|
|
107
|
+
if (enableNativewind) {
|
|
108
|
+
if (!props.id.includes("node_modules")) {
|
|
109
|
+
plugins.push((0, import_utils.resolvePath)("react-native-css-interop/dist/babel-plugin.js"));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (enableNativewind || shouldBabelReanimated(props)) {
|
|
113
|
+
try {
|
|
114
|
+
const workletsPlugin = (0, import_utils.resolvePath)("react-native-worklets/plugin", props.projectRoot);
|
|
115
|
+
(0, import_constants.debug)?.(`Using babel worklets on file ${props.id}`);
|
|
116
|
+
plugins.push(workletsPlugin);
|
|
117
|
+
} catch {}
|
|
118
|
+
}
|
|
119
|
+
if (shouldBabelReactCompiler(props)) {
|
|
120
|
+
(0, import_constants.debug)?.(`Using babel react compiler on file`);
|
|
121
|
+
plugins.push(getBabelReactCompilerPlugin(props));
|
|
122
|
+
}
|
|
123
|
+
if (plugins.length || userBabelConfig) {
|
|
124
|
+
return {
|
|
125
|
+
plugins,
|
|
126
|
+
...userBabelConfig ? {
|
|
127
|
+
configFile: userBabelConfig,
|
|
128
|
+
babelrc: true
|
|
129
|
+
} : {}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
135
133
|
};
|
|
136
134
|
async function transformOxcReactCompiler(id, code, optionsOrTarget = "19", sourceMap = false) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
code: result.code,
|
|
164
|
-
map: sourceMap ? result.map : void 0
|
|
165
|
-
};
|
|
135
|
+
const { transform } = await import("oxc-transform-react");
|
|
136
|
+
const compilerOptions = typeof optionsOrTarget === "string" ? { target: optionsOrTarget } : optionsOrTarget || {};
|
|
137
|
+
const target = compilerOptions.target ?? "19";
|
|
138
|
+
const result = await transform(id, code, {
|
|
139
|
+
jsx: "preserve",
|
|
140
|
+
sourcemap: sourceMap,
|
|
141
|
+
reactCompiler: {
|
|
142
|
+
target,
|
|
143
|
+
...compilerOptions,
|
|
144
|
+
environment: {
|
|
145
|
+
enableCustomTypeDefinitionForReanimated: true,
|
|
146
|
+
...compilerOptions.environment
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
if (result.fatal) {
|
|
151
|
+
throw new Error(`[vxrn:compiler] oxc react compiler failed on ${id}: ${(result.errors ?? []).map((e) => e.message ?? String(e)).join(", ")}`);
|
|
152
|
+
}
|
|
153
|
+
if (result.errors?.length) {
|
|
154
|
+
(0, import_constants.debug)?.(`[compiler/bailout] ${id}: ${result.errors.map((e) => e.message ?? String(e)).join(", ")}`);
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
code: result.code,
|
|
158
|
+
map: sourceMap ? result.map : void 0
|
|
159
|
+
};
|
|
166
160
|
}
|
|
167
161
|
async function transformBabel(id, code, options) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
res(result);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
162
|
+
const [{ default: babelCore }, { default: hermesParserPlugin }] = await Promise.all([import("@babel/core"), import("babel-plugin-syntax-hermes-parser")]);
|
|
163
|
+
const extension = (0, import_node_path.extname)(id);
|
|
164
|
+
const isTSX = extension === ".tsx";
|
|
165
|
+
const isTS = isTSX || extension === ".ts";
|
|
166
|
+
const babelOptions = {
|
|
167
|
+
filename: id,
|
|
168
|
+
compact: false,
|
|
169
|
+
babelrc: options.babelrc ?? false,
|
|
170
|
+
configFile: options.configFile ?? false,
|
|
171
|
+
sourceMaps: false,
|
|
172
|
+
minified: false,
|
|
173
|
+
...options,
|
|
174
|
+
caller: {
|
|
175
|
+
name: "vxrn",
|
|
176
|
+
supportsStaticESM: true,
|
|
177
|
+
supportsDynamicImport: true
|
|
178
|
+
},
|
|
179
|
+
presets: [isTS ? ["@babel/preset-typescript", {
|
|
180
|
+
isTSX,
|
|
181
|
+
allExtensions: isTSX
|
|
182
|
+
}] : "", ...options.presets || []].filter(Boolean),
|
|
183
|
+
plugins: [
|
|
184
|
+
...isTS ? [] : [[hermesParserPlugin, {
|
|
185
|
+
parseLangTypes: "flow",
|
|
186
|
+
reactRuntimeTarget: "19"
|
|
187
|
+
}], "babel-plugin-transform-flow-enums"],
|
|
188
|
+
...options.plugins || [],
|
|
189
|
+
...isTS ? [] : ["@babel/plugin-transform-flow-strip-types"]
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
return await new Promise((res, rej) => {
|
|
193
|
+
babelCore.transform(code, babelOptions, (err, result) => {
|
|
194
|
+
if (!result || err) {
|
|
195
|
+
return rej(err || new Error(`[vxrn:compiler] babel returned no result for ${id}`));
|
|
196
|
+
}
|
|
197
|
+
res(result);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
209
200
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
201
|
+
async function stripFlowTypes(id, code, sourceMaps = true) {
|
|
202
|
+
const result = await transformBabel(id, code, { sourceMaps });
|
|
203
|
+
return {
|
|
204
|
+
code: result.code,
|
|
205
|
+
map: result.map
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const getBasePlugins = ({ development }) => [
|
|
209
|
+
["@babel/plugin-transform-destructuring"],
|
|
210
|
+
["@babel/plugin-transform-react-jsx", { development }],
|
|
211
|
+
["@babel/plugin-transform-async-generator-functions"],
|
|
212
|
+
["@babel/plugin-transform-async-to-generator"],
|
|
213
|
+
["@babel/plugin-transform-runtime", {
|
|
214
|
+
helpers: true,
|
|
215
|
+
regenerator: false
|
|
216
|
+
}]
|
|
217
|
+
];
|
|
218
|
+
const shouldBabelReactCompiler = (props) => {
|
|
219
|
+
if (props.environment === "ssr") {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (!import_configure.configuration.enableCompiler) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const { enableCompiler } = import_configure.configuration;
|
|
226
|
+
if (typeof enableCompiler === "object" && !Array.isArray(enableCompiler) && !(enableCompiler instanceof RegExp)) {
|
|
227
|
+
const isNative = props.environment === "ios" || props.environment === "android";
|
|
228
|
+
const filter = isNative ? enableCompiler.native : enableCompiler.web;
|
|
229
|
+
if (!filter) return false;
|
|
230
|
+
return applyCompilerFilter(filter, props);
|
|
231
|
+
}
|
|
232
|
+
if (typeof enableCompiler === "function") {
|
|
233
|
+
return enableCompiler(props.id, props.environment);
|
|
234
|
+
}
|
|
235
|
+
if (enableCompiler instanceof RegExp) {
|
|
236
|
+
return enableCompiler.test(props.id);
|
|
237
|
+
}
|
|
238
|
+
if (Array.isArray(enableCompiler)) {
|
|
239
|
+
if (!enableCompiler.includes(props.environment)) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return applyDefaultFilters(props);
|
|
247
244
|
};
|
|
248
245
|
function applyCompilerFilter(filter, props) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
246
|
+
if (typeof filter === "function") {
|
|
247
|
+
return filter(props.id, props.environment);
|
|
248
|
+
}
|
|
249
|
+
if (filter instanceof RegExp) {
|
|
250
|
+
return filter.test(props.id);
|
|
251
|
+
}
|
|
252
|
+
if (filter === true) {
|
|
253
|
+
return applyDefaultFilters(props);
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
259
256
|
}
|
|
260
257
|
function applyDefaultFilters(props) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
258
|
+
if (!/(\.tsx?)$/.test(props.id)) return false;
|
|
259
|
+
if (props.id.includes("node_modules")) return false;
|
|
260
|
+
if (props.id.includes("+api.")) return false;
|
|
261
|
+
if (props.code.startsWith("// disable-compiler")) return false;
|
|
262
|
+
return true;
|
|
266
263
|
}
|
|
267
|
-
const getBabelReactCompilerPlugin = props => {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
target
|
|
271
|
-
}];
|
|
264
|
+
const getBabelReactCompilerPlugin = (props) => {
|
|
265
|
+
const target = props.reactForRNVersion === "18" && (props.environment === "ios" || props.environment === "android") ? "18" : "19";
|
|
266
|
+
return ["babel-plugin-react-compiler", { target }];
|
|
272
267
|
};
|
|
273
|
-
function shouldBabelGenerators({
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return import_constants.asyncGeneratorRegex.test(code);
|
|
278
|
-
}
|
|
268
|
+
function shouldBabelGenerators({ code }) {
|
|
269
|
+
if (process.env.VXRN_USE_BABEL_FOR_GENERATORS) {
|
|
270
|
+
return import_constants.asyncGeneratorRegex.test(code);
|
|
271
|
+
}
|
|
279
272
|
}
|
|
280
|
-
const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
|
|
273
|
+
const REANIMATED_AUTOWORKLETIZATION_KEYWORDS = [
|
|
274
|
+
"worklet",
|
|
275
|
+
"useAnimatedGestureHandler",
|
|
276
|
+
"useAnimatedScrollHandler",
|
|
277
|
+
"useFrameCallback",
|
|
278
|
+
"useAnimatedStyle",
|
|
279
|
+
"useAnimatedProps",
|
|
280
|
+
"createAnimatedPropAdapter",
|
|
281
|
+
"useDerivedValue",
|
|
282
|
+
"useAnimatedReaction",
|
|
283
|
+
"useWorkletCallback",
|
|
284
|
+
"withTiming",
|
|
285
|
+
"withSpring",
|
|
286
|
+
"withDecay",
|
|
287
|
+
"withRepeat",
|
|
288
|
+
"runOnUI",
|
|
289
|
+
"executeOnUIRuntimeSync"
|
|
290
|
+
];
|
|
281
291
|
const REANIMATED_REGEX = new RegExp(REANIMATED_AUTOWORKLETIZATION_KEYWORDS.join("|"));
|
|
282
292
|
const REANIMATED_IGNORED_PATHS = [
|
|
283
|
-
|
|
284
|
-
"
|
|
285
|
-
|
|
286
|
-
"node_modules/react
|
|
293
|
+
"react-native-prebuilt",
|
|
294
|
+
"node_modules/.vxrn/react-native",
|
|
295
|
+
"node_modules/react/",
|
|
296
|
+
"node_modules/react-dom/",
|
|
297
|
+
"node_modules/react-native/",
|
|
298
|
+
"node_modules/react-native-web/"
|
|
299
|
+
];
|
|
287
300
|
const REANIMATED_IGNORED_PATHS_REGEX = new RegExp(REANIMATED_IGNORED_PATHS.join("|"));
|
|
288
|
-
function shouldBabelReanimated({
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
return false;
|
|
304
|
-
}
|
|
301
|
+
function shouldBabelReanimated({ code, id }) {
|
|
302
|
+
if (!import_configure.configuration.enableReanimated) {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (REANIMATED_IGNORED_PATHS_REGEX.test(id)) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
if (REANIMATED_REGEX.test(code)) {
|
|
309
|
+
const location = id.includes("node_modules") ? "node_modules" : "user-code";
|
|
310
|
+
(0, import_constants.debug)?.(` \u{1FA84} [reanimated/${location}] ${(0, import_node_path.relative)(process.cwd(), id)}`);
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|