@vxrn/compiler 1.27.1 → 2.0.0-0.canary.1791056568702

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.
Files changed (105) hide show
  1. package/dist/cjs/cache.cjs +106 -117
  2. package/dist/cjs/configure.cjs +26 -28
  3. package/dist/cjs/constants.cjs +56 -60
  4. package/dist/cjs/index.cjs +422 -443
  5. package/dist/cjs/reactNativeCodegen.cjs +105 -114
  6. package/dist/cjs/reactNativeViewConfig.cjs +362 -381
  7. package/dist/cjs/refresh-runtime.cjs +390 -397
  8. package/dist/cjs/transformBabel.cjs +288 -263
  9. package/dist/cjs/transformHermesAsync.cjs +36 -47
  10. package/dist/cjs/transformHermesClasses.cjs +51 -0
  11. package/dist/cjs/transformHermesLoops.cjs +279 -281
  12. package/dist/cjs/transformSWC.cjs +183 -200
  13. package/dist/cjs/transformWorklets.cjs +107 -95
  14. package/dist/cjs/types.cjs +9 -11
  15. package/dist/cjs/worklets/autoworklet.cjs +277 -222
  16. package/dist/cjs/worklets/globals.cjs +145 -60
  17. package/dist/cjs/worklets/hash.cjs +23 -27
  18. package/dist/cjs/worklets/scope.cjs +338 -359
  19. package/dist/cjs/worklets/serialize.cjs +73 -75
  20. package/dist/cjs/worklets/transform.cjs +217 -222
  21. package/dist/cjs/worklets/types.cjs +9 -11
  22. package/dist/esm/cache.mjs +90 -97
  23. package/dist/esm/cache.mjs.map +1 -1
  24. package/dist/esm/configure.mjs +11 -10
  25. package/dist/esm/configure.mjs.map +1 -1
  26. package/dist/esm/constants.mjs +41 -41
  27. package/dist/esm/constants.mjs.map +1 -1
  28. package/dist/esm/index.js +420 -425
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/index.mjs +420 -425
  31. package/dist/esm/index.mjs.map +1 -1
  32. package/dist/esm/reactNativeCodegen.mjs +90 -88
  33. package/dist/esm/reactNativeCodegen.mjs.map +1 -1
  34. package/dist/esm/reactNativeViewConfig.mjs +347 -362
  35. package/dist/esm/reactNativeViewConfig.mjs.map +1 -1
  36. package/dist/esm/refresh-runtime.mjs +372 -376
  37. package/dist/esm/refresh-runtime.mjs.map +1 -1
  38. package/dist/esm/transformBabel.mjs +270 -237
  39. package/dist/esm/transformBabel.mjs.map +1 -1
  40. package/dist/esm/transformHermesAsync.mjs +20 -21
  41. package/dist/esm/transformHermesAsync.mjs.map +1 -1
  42. package/dist/esm/transformHermesClasses.mjs +25 -0
  43. package/dist/esm/transformHermesClasses.mjs.map +1 -0
  44. package/dist/esm/transformHermesLoops.mjs +264 -255
  45. package/dist/esm/transformHermesLoops.mjs.map +1 -1
  46. package/dist/esm/transformSWC.mjs +163 -171
  47. package/dist/esm/transformSWC.mjs.map +1 -1
  48. package/dist/esm/transformWorklets.mjs +89 -69
  49. package/dist/esm/transformWorklets.mjs.map +1 -1
  50. package/dist/esm/types.mjs +0 -2
  51. package/dist/esm/worklets/autoworklet.mjs +258 -200
  52. package/dist/esm/worklets/autoworklet.mjs.map +1 -1
  53. package/dist/esm/worklets/globals.mjs +130 -42
  54. package/dist/esm/worklets/globals.mjs.map +1 -1
  55. package/dist/esm/worklets/hash.mjs +10 -9
  56. package/dist/esm/worklets/hash.mjs.map +1 -1
  57. package/dist/esm/worklets/scope.mjs +325 -341
  58. package/dist/esm/worklets/scope.mjs.map +1 -1
  59. package/dist/esm/worklets/serialize.mjs +60 -58
  60. package/dist/esm/worklets/serialize.mjs.map +1 -1
  61. package/dist/esm/worklets/transform.mjs +201 -197
  62. package/dist/esm/worklets/transform.mjs.map +1 -1
  63. package/dist/esm/worklets/types.mjs +0 -2
  64. package/package.json +10 -6
  65. package/src/index.ts +6 -0
  66. package/src/transformBabel.test.ts +100 -18
  67. package/src/transformBabel.ts +55 -13
  68. package/src/transformHermesClasses.ts +34 -0
  69. package/src/transformSWC.ts +12 -1
  70. package/src/transformWorklets.test.ts +80 -5
  71. package/src/worklets/autoworklet.ts +5 -2
  72. package/src/worklets/globals.ts +23 -0
  73. package/src/worklets/serialize.ts +1 -1
  74. package/types/index.d.ts +1 -0
  75. package/types/index.d.ts.map +1 -1
  76. package/types/transformBabel.d.ts +12 -0
  77. package/types/transformBabel.d.ts.map +1 -1
  78. package/types/transformHermesClasses.d.ts +5 -0
  79. package/types/transformHermesClasses.d.ts.map +1 -0
  80. package/types/transformSWC.d.ts +1 -4
  81. package/types/transformSWC.d.ts.map +1 -1
  82. package/types/worklets/autoworklet.d.ts.map +1 -1
  83. package/types/worklets/globals.d.ts.map +1 -1
  84. package/dist/cjs/transformBabel.test.cjs +0 -652
  85. package/dist/cjs/transformHermesLoops.test.cjs +0 -257
  86. package/dist/cjs/transformSWC.test.cjs +0 -117
  87. package/dist/cjs/transformWorklets.test.cjs +0 -604
  88. package/dist/esm/transformBabel.test.mjs +0 -629
  89. package/dist/esm/transformBabel.test.mjs.map +0 -1
  90. package/dist/esm/transformHermesLoops.test.mjs +0 -234
  91. package/dist/esm/transformHermesLoops.test.mjs.map +0 -1
  92. package/dist/esm/transformSWC.test.mjs +0 -118
  93. package/dist/esm/transformSWC.test.mjs.map +0 -1
  94. package/dist/esm/transformWorklets.test.mjs +0 -581
  95. package/dist/esm/transformWorklets.test.mjs.map +0 -1
  96. package/dist/esm/types.mjs.map +0 -1
  97. package/dist/esm/worklets/types.mjs.map +0 -1
  98. package/types/transformBabel.test.d.ts +0 -2
  99. package/types/transformBabel.test.d.ts.map +0 -1
  100. package/types/transformHermesLoops.test.d.ts +0 -2
  101. package/types/transformHermesLoops.test.d.ts.map +0 -1
  102. package/types/transformSWC.test.d.ts +0 -2
  103. package/types/transformSWC.test.d.ts.map +0 -1
  104. package/types/transformWorklets.test.d.ts +0 -2
  105. package/types/transformWorklets.test.d.ts.map +0 -1
@@ -5,39 +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
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
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
- 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;
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
22
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
29
- value: mod,
30
- enumerable: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
31
26
  }) : target, mod));
32
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
33
- value: true
34
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
28
  var index_exports = {};
36
29
  __export(index_exports, {
37
- JS_GLOBALS: () => import_globals.JS_GLOBALS,
38
- clearTransformCache: () => import_cache2.clearTransformCache,
39
- createVXRNCompilerPlugin: () => createVXRNCompilerPlugin,
40
- getClosureVariables: () => import_scope.getClosureVariables
30
+ JS_GLOBALS: () => import_globals.JS_GLOBALS,
31
+ clearTransformCache: () => import_cache2.clearTransformCache,
32
+ createVXRNCompilerPlugin: () => createVXRNCompilerPlugin,
33
+ getClosureVariables: () => import_scope.getClosureVariables
41
34
  });
42
35
  module.exports = __toCommonJS(index_exports);
43
36
  var import_node_fs = require("node:fs");
@@ -59,448 +52,433 @@ __reExport(index_exports, require("./transformWorklets.cjs"), module.exports);
59
52
  __reExport(index_exports, require("./reactNativeCodegen.cjs"), module.exports);
60
53
  __reExport(index_exports, require("./transformHermesLoops.cjs"), module.exports);
61
54
  __reExport(index_exports, require("./transformHermesAsync.cjs"), module.exports);
55
+ __reExport(index_exports, require("./transformHermesClasses.cjs"), module.exports);
62
56
  var import_cache2 = require("./cache.cjs");
63
57
  var import_globals = require("./worklets/globals.cjs");
64
58
  var import_scope = require("./worklets/scope.cjs");
65
59
  const import_meta = {};
66
60
  const perfStats = {
67
- babel: {
68
- totalCalls: 0,
69
- totalTransforms: 0,
70
- totalTime: 0,
71
- byEnvironment: {}
72
- },
73
- optimizeDeps: {
74
- byEnvironment: {}
75
- }
61
+ babel: {
62
+ totalCalls: 0,
63
+ totalTransforms: 0,
64
+ totalTime: 0,
65
+ byEnvironment: {}
66
+ },
67
+ optimizeDeps: { byEnvironment: {} }
76
68
  };
77
69
  function logPerfSummary() {
78
- if (!process.env.DEBUG_COMPILER_PERF) {
79
- return;
80
- }
81
- console.info("\n\u{1F4CA} [Compiler Performance Summary]");
82
- console.info(`Babel: ${perfStats.babel.totalTransforms} transforms / ${perfStats.babel.totalCalls} calls (${(perfStats.babel.totalTransforms / Math.max(perfStats.babel.totalCalls, 1) * 100).toFixed(1)}% transform rate)`);
83
- console.info(`Babel total time: ${perfStats.babel.totalTime}ms`);
84
- for (const [env, stats] of Object.entries(perfStats.babel.byEnvironment)) {
85
- if (stats.transforms > 0) {
86
- console.info(` ${env}: ${stats.transforms} transforms, ${stats.time}ms (${(stats.time / stats.transforms).toFixed(1)}ms avg)`);
87
- }
88
- }
89
- for (const [env, stats] of Object.entries(perfStats.optimizeDeps.byEnvironment)) {
90
- const elapsed = Date.now() - stats.startTime;
91
- console.info(`optimizeDeps ${env}: checked ${stats.filesChecked} files, transformed ${stats.filesTransformed} (${elapsed}ms)`);
92
- }
70
+ if (!process.env.DEBUG_COMPILER_PERF) {
71
+ return;
72
+ }
73
+ console.info("\n📊 [Compiler Performance Summary]");
74
+ console.info(`Babel: ${perfStats.babel.totalTransforms} transforms / ${perfStats.babel.totalCalls} calls (${(perfStats.babel.totalTransforms / Math.max(perfStats.babel.totalCalls, 1) * 100).toFixed(1)}% transform rate)`);
75
+ console.info(`Babel total time: ${perfStats.babel.totalTime}ms`);
76
+ for (const [env, stats] of Object.entries(perfStats.babel.byEnvironment)) {
77
+ if (stats.transforms > 0) {
78
+ console.info(` ${env}: ${stats.transforms} transforms, ${stats.time}ms (${(stats.time / stats.transforms).toFixed(1)}ms avg)`);
79
+ }
80
+ }
81
+ for (const [env, stats] of Object.entries(perfStats.optimizeDeps.byEnvironment)) {
82
+ const elapsed = Date.now() - stats.startTime;
83
+ console.info(`optimizeDeps ${env}: checked ${stats.filesChecked} files, transformed ${stats.filesTransformed} (${elapsed}ms)`);
84
+ }
93
85
  }
94
86
  const compilerLog = {
95
- compiled: 0,
96
- cached: 0,
97
- time: 0,
98
- // typed loose because the dom lib types setTimeout as number, but node gives
99
- // us a Timeout we need to unref so the debounce never holds the process open
100
- timer: null
87
+ compiled: 0,
88
+ cached: 0,
89
+ time: 0,
90
+ timer: null
101
91
  };
102
92
  function logCompiled(cached, ms) {
103
- if (cached) {
104
- compilerLog.cached++;
105
- } else {
106
- compilerLog.compiled++;
107
- compilerLog.time += ms;
108
- }
109
- if (compilerLog.timer) clearTimeout(compilerLog.timer);
110
- compilerLog.timer = setTimeout(() => {
111
- const total = compilerLog.compiled + compilerLog.cached;
112
- const detail = compilerLog.compiled ? `${compilerLog.compiled} compiled in ${compilerLog.time}ms${compilerLog.cached ? `, ${compilerLog.cached} cached` : ""}` : `all cached`;
113
- console.info(` \u{1FA84} [compiler] ${total} file${total === 1 ? "" : "s"} (${detail})`);
114
- compilerLog.compiled = 0;
115
- compilerLog.cached = 0;
116
- compilerLog.time = 0;
117
- compilerLog.timer = null;
118
- }, 500);
119
- compilerLog.timer.unref?.();
93
+ if (cached) {
94
+ compilerLog.cached++;
95
+ } else {
96
+ compilerLog.compiled++;
97
+ compilerLog.time += ms;
98
+ }
99
+ if (compilerLog.timer) clearTimeout(compilerLog.timer);
100
+ compilerLog.timer = setTimeout(() => {
101
+ const total = compilerLog.compiled + compilerLog.cached;
102
+ const detail = compilerLog.compiled ? `${compilerLog.compiled} compiled in ${compilerLog.time}ms${compilerLog.cached ? `, ${compilerLog.cached} cached` : ""}` : `all cached`;
103
+ console.info(` \u{1FA84} [compiler] ${total} file${total === 1 ? "" : "s"} (${detail})`);
104
+ compilerLog.compiled = 0;
105
+ compilerLog.cached = 0;
106
+ compilerLog.time = 0;
107
+ compilerLog.timer = null;
108
+ }, 500);
109
+ compilerLog.timer.unref?.();
120
110
  }
121
- async function performBabelTransform({
122
- id,
123
- code,
124
- projectRoot,
125
- environment,
126
- production,
127
- reactForRNVersion,
128
- optionsIn
129
- }) {
130
- perfStats.babel.totalCalls++;
131
- if (!perfStats.babel.byEnvironment[environment]) {
132
- perfStats.babel.byEnvironment[environment] = {
133
- calls: 0,
134
- transforms: 0,
135
- time: 0
136
- };
137
- }
138
- perfStats.babel.byEnvironment[environment].calls++;
139
- const transformProps = {
140
- id,
141
- code,
142
- projectRoot,
143
- development: !production,
144
- environment,
145
- reactForRNVersion
146
- };
147
- const userTransform = optionsIn?.transform?.(transformProps);
148
- if (userTransform === false) {
149
- return null;
150
- }
151
- if (userTransform !== "swc" && userTransform !== "oxc") {
152
- const babelOptions = (0, import_transformBabel.getBabelOptions)({
153
- ...transformProps,
154
- userSetting: userTransform
155
- });
156
- if (babelOptions) {
157
- const hasCompilerPlugin = babelOptions.plugins?.some(x => Array.isArray(x) && x[0] === "babel-plugin-react-compiler");
158
- const userBabelConfigPath = typeof babelOptions.configFile === "string" ? babelOptions.configFile : null;
159
- const cached = (0, import_cache.getCachedTransform)(id, code, environment, userBabelConfigPath);
160
- if (cached) {
161
- perfStats.babel.byEnvironment[environment].transforms++;
162
- if (hasCompilerPlugin && (cached.code.includes("react/compiler-runtime") || cached.code.includes("react-compiler-runtime"))) {
163
- (0, import_constants.debug)?.(` \u{1FA84} [compiler] ${(0, import_node_path.relative)(process.cwd(), id)} (cached)`);
164
- logCompiled(true, 0);
165
- }
166
- (0, import_constants.debug)?.(`[babel/cached] ${id}`);
167
- return cached;
168
- }
169
- const isWorkletPlugin = entry => {
170
- if (!entry) return false;
171
- const name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
172
- return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
173
- };
174
- const workletEntry = babelOptions.plugins?.find(isWorkletPlugin);
175
- const workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
176
- const useWorklets = (0, import_configure.isNativeWorkletsEnabled)() && (Boolean(workletEntry) || (0, import_transformWorklets.shouldTransformWorklets)({
177
- id,
178
- code
179
- }));
180
- let curCode = code;
181
- let workletPreparation = null;
182
- let compilerOut = null;
183
- const compilerPluginIndex = babelOptions.plugins?.findIndex(x => Array.isArray(x) && x[0] === "babel-plugin-react-compiler") ?? -1;
184
- if (compilerPluginIndex !== -1) {
185
- const compilerPluginConfig = babelOptions.plugins[compilerPluginIndex];
186
- const compilerPluginOptions = compilerPluginConfig[1] || {};
187
- const useBabelCompiler = compilerPluginOptions.compiler === "babel" || process.env.ONE_REACT_COMPILER === "babel" || process.env.VXRN_REACT_COMPILER === "babel";
188
- if (!useBabelCompiler) {
189
- if (useWorklets) {
190
- workletPreparation = (0, import_transformWorklets.prepareWorkletsForReactCompiler)(id, curCode, (0, import_transformSWC.shouldSourceMap)());
191
- if (workletPreparation) curCode = workletPreparation.code;
192
- }
193
- compilerOut = await (0, import_transformBabel.transformOxcReactCompiler)(id, curCode, compilerPluginOptions, (0, import_transformSWC.shouldSourceMap)());
194
- if (compilerOut) curCode = compilerOut.code;
195
- babelOptions.plugins.splice(compilerPluginIndex, 1);
196
- }
197
- }
198
- let workletsOut = null;
199
- if (useWorklets) {
200
- workletsOut = await (0, import_transformWorklets.transformWorklets)(id, curCode, (0, import_transformSWC.shouldSourceMap)(), {
201
- projectRoot,
202
- ...workletPluginOptions
203
- });
204
- babelOptions.plugins = babelOptions.plugins?.filter(entry => !isWorkletPlugin(entry));
205
- curCode = workletsOut.code;
206
- }
207
- const startTime = Date.now();
208
- let babelOut = null;
209
- if (babelOptions.plugins?.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) {
210
- let finalMap = void 0;
211
- if ((0, import_transformSWC.shouldSourceMap)()) {
212
- const intermediateMaps = [workletPreparation?.map, compilerOut?.map, workletsOut?.map].filter(Boolean);
213
- if (intermediateMaps.length === 1) {
214
- finalMap = intermediateMaps[0];
215
- } else if (intermediateMaps.length > 1) {
216
- const remapping = (await import("@jridgewell/remapping")).default;
217
- finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
218
- }
219
- }
220
- babelOut = {
221
- code: curCode,
222
- map: finalMap
223
- };
224
- } else {
225
- const babelOptsWithMap = (0, import_transformSWC.shouldSourceMap)() && (workletsOut?.map || compilerOut?.map || workletPreparation?.map) ? {
226
- ...babelOptions,
227
- sourceMaps: true
228
- } : babelOptions;
229
- babelOut = await (0, import_transformBabel.transformBabel)(id, curCode, babelOptsWithMap);
230
- if ((0, import_transformSWC.shouldSourceMap)() && babelOut?.map) {
231
- const priorMaps = [workletPreparation?.map, compilerOut?.map, workletsOut?.map].filter(Boolean);
232
- if (priorMaps.length > 0) {
233
- const remapping = (await import("@jridgewell/remapping")).default;
234
- babelOut.map = remapping([babelOut.map, ...priorMaps.slice().reverse()], () => null);
235
- }
236
- }
237
- }
238
- const babelTime = Date.now() - startTime;
239
- if (babelOut?.code) {
240
- perfStats.babel.totalTransforms++;
241
- perfStats.babel.totalTime += babelTime;
242
- perfStats.babel.byEnvironment[environment].transforms++;
243
- perfStats.babel.byEnvironment[environment].time += babelTime;
244
- if (hasCompilerPlugin && (babelOut.code.includes("react/compiler-runtime") || babelOut.code.includes("react-compiler-runtime"))) {
245
- (0, import_constants.debug)?.(` \u{1FA84} [compiler] ${(0, import_node_path.relative)(process.cwd(), id)} (${babelTime}ms)`);
246
- logCompiled(false, babelTime);
247
- }
248
- (0, import_constants.debug)?.(`[babel] ${id}`);
249
- const outCode = `${babelOut.code}
111
+ async function performBabelTransform({ id, code, projectRoot, environment, production, reactForRNVersion, optionsIn }) {
112
+ perfStats.babel.totalCalls++;
113
+ if (!perfStats.babel.byEnvironment[environment]) {
114
+ perfStats.babel.byEnvironment[environment] = {
115
+ calls: 0,
116
+ transforms: 0,
117
+ time: 0
118
+ };
119
+ }
120
+ perfStats.babel.byEnvironment[environment].calls++;
121
+ const transformProps = {
122
+ id,
123
+ code,
124
+ projectRoot,
125
+ development: !production,
126
+ environment,
127
+ reactForRNVersion
128
+ };
129
+ const userTransform = optionsIn?.transform?.(transformProps);
130
+ if (userTransform === false) {
131
+ return null;
132
+ }
133
+ if (userTransform !== "swc" && userTransform !== "oxc") {
134
+ const babelOptions = (0, import_transformBabel.getBabelOptions)({
135
+ ...transformProps,
136
+ userSetting: userTransform
137
+ });
138
+ if (babelOptions) {
139
+ const hasCompilerPlugin = babelOptions.plugins?.some((x) => Array.isArray(x) && x[0] === "babel-plugin-react-compiler");
140
+ const userBabelConfigPath = typeof babelOptions.configFile === "string" ? babelOptions.configFile : null;
141
+ const cached = (0, import_cache.getCachedTransform)(id, code, environment, userBabelConfigPath);
142
+ if (cached) {
143
+ perfStats.babel.byEnvironment[environment].transforms++;
144
+ if (hasCompilerPlugin && (cached.code.includes("react/compiler-runtime") || cached.code.includes("react-compiler-runtime"))) {
145
+ (0, import_constants.debug)?.(` \u{1FA84} [compiler] ${(0, import_node_path.relative)(process.cwd(), id)} (cached)`);
146
+ logCompiled(true, 0);
147
+ }
148
+ (0, import_constants.debug)?.(`[babel/cached] ${id}`);
149
+ return cached;
150
+ }
151
+ const isWorkletPlugin = (entry) => {
152
+ if (!entry) return false;
153
+ const name = typeof entry === "string" ? entry : Array.isArray(entry) ? entry[0] : null;
154
+ return typeof name === "string" && (name.includes("react-native-worklets") || name.includes("react-native-reanimated"));
155
+ };
156
+ const workletEntry = babelOptions.plugins?.find(isWorkletPlugin);
157
+ const workletPluginOptions = Array.isArray(workletEntry) ? workletEntry[1] : void 0;
158
+ const useWorklets = (0, import_configure.isNativeWorkletsEnabled)() && (Boolean(workletEntry) || (0, import_transformWorklets.shouldTransformWorklets)({
159
+ id,
160
+ code
161
+ }));
162
+ let curCode = code;
163
+ let workletPreparation = null;
164
+ let compilerOut = null;
165
+ const compilerPluginIndex = babelOptions.plugins?.findIndex((x) => Array.isArray(x) && x[0] === "babel-plugin-react-compiler") ?? -1;
166
+ if (compilerPluginIndex !== -1) {
167
+ const compilerPluginConfig = babelOptions.plugins[compilerPluginIndex];
168
+ const compilerPluginOptions = compilerPluginConfig[1] || {};
169
+ const useBabelCompiler = compilerPluginOptions.compiler === "babel" || process.env.ONE_REACT_COMPILER === "babel" || process.env.VXRN_REACT_COMPILER === "babel";
170
+ if (!useBabelCompiler) {
171
+ if (useWorklets) {
172
+ workletPreparation = (0, import_transformWorklets.prepareWorkletsForReactCompiler)(id, curCode, (0, import_transformSWC.shouldSourceMap)());
173
+ if (workletPreparation) curCode = workletPreparation.code;
174
+ }
175
+ compilerOut = await (0, import_transformBabel.transformOxcReactCompiler)(id, curCode, compilerPluginOptions, (0, import_transformSWC.shouldSourceMap)());
176
+ if (compilerOut) curCode = compilerOut.code;
177
+ babelOptions.plugins.splice(compilerPluginIndex, 1);
178
+ }
179
+ }
180
+ let workletsOut = null;
181
+ if (useWorklets) {
182
+ workletsOut = await (0, import_transformWorklets.transformWorklets)(id, curCode, (0, import_transformSWC.shouldSourceMap)(), {
183
+ projectRoot,
184
+ ...workletPluginOptions
185
+ });
186
+ babelOptions.plugins = babelOptions.plugins?.filter((entry) => !isWorkletPlugin(entry));
187
+ curCode = workletsOut.code;
188
+ }
189
+ const startTime = Date.now();
190
+ let babelOut = null;
191
+ if (babelOptions.plugins?.length === 0 && !babelOptions.configFile && !babelOptions.babelrc) {
192
+ let finalMap = void 0;
193
+ if ((0, import_transformSWC.shouldSourceMap)()) {
194
+ const intermediateMaps = [
195
+ workletPreparation?.map,
196
+ compilerOut?.map,
197
+ workletsOut?.map
198
+ ].filter(Boolean);
199
+ if (intermediateMaps.length === 1) {
200
+ finalMap = intermediateMaps[0];
201
+ } else if (intermediateMaps.length > 1) {
202
+ const remapping = (await import("@jridgewell/remapping")).default;
203
+ finalMap = remapping(intermediateMaps.slice().reverse(), () => null);
204
+ }
205
+ }
206
+ babelOut = {
207
+ code: curCode,
208
+ map: finalMap
209
+ };
210
+ } else {
211
+ const babelOptsWithMap = (0, import_transformSWC.shouldSourceMap)() && (workletsOut?.map || compilerOut?.map || workletPreparation?.map) ? {
212
+ ...babelOptions,
213
+ sourceMaps: true
214
+ } : babelOptions;
215
+ babelOut = await (0, import_transformBabel.transformBabel)(id, curCode, babelOptsWithMap);
216
+ if ((0, import_transformSWC.shouldSourceMap)() && babelOut?.map) {
217
+ const priorMaps = [
218
+ workletPreparation?.map,
219
+ compilerOut?.map,
220
+ workletsOut?.map
221
+ ].filter(Boolean);
222
+ if (priorMaps.length > 0) {
223
+ const remapping = (await import("@jridgewell/remapping")).default;
224
+ babelOut.map = remapping([babelOut.map, ...priorMaps.slice().reverse()], () => null);
225
+ }
226
+ }
227
+ }
228
+ const babelTime = Date.now() - startTime;
229
+ if (babelOut?.code) {
230
+ perfStats.babel.totalTransforms++;
231
+ perfStats.babel.totalTime += babelTime;
232
+ perfStats.babel.byEnvironment[environment].transforms++;
233
+ perfStats.babel.byEnvironment[environment].time += babelTime;
234
+ if (hasCompilerPlugin && (babelOut.code.includes("react/compiler-runtime") || babelOut.code.includes("react-compiler-runtime"))) {
235
+ (0, import_constants.debug)?.(` \u{1FA84} [compiler] ${(0, import_node_path.relative)(process.cwd(), id)} (${babelTime}ms)`);
236
+ logCompiled(false, babelTime);
237
+ }
238
+ (0, import_constants.debug)?.(`[babel] ${id}`);
239
+ const outCode = `${babelOut.code}
250
240
  // vxrn-did-babel`;
251
- const result = {
252
- code: outCode,
253
- map: babelOut.map
254
- };
255
- (0, import_cache.setCachedTransform)(id, code, result, environment, userBabelConfigPath);
256
- return result;
257
- }
258
- }
259
- }
260
- return null;
241
+ const result = {
242
+ code: outCode,
243
+ map: babelOut.map
244
+ };
245
+ (0, import_cache.setCachedTransform)(id, code, result, environment, userBabelConfigPath);
246
+ return result;
247
+ }
248
+ }
249
+ }
250
+ return null;
261
251
  }
262
252
  async function createVXRNCompilerPlugin(optionsIn) {
263
- const reactVersion = await (async () => {
264
- const path = (0, import_utils.resolvePath)("react/package.json");
265
- const json = JSON.parse(await (0, import_promises.readFile)(path, "utf-8"));
266
- return json.version;
267
- })();
268
- const envNames = {
269
- ios: true,
270
- android: true,
271
- client: true,
272
- ssr: true
273
- };
274
- function getEnvName(name) {
275
- if (name === "worker") return "ssr";
276
- if (!envNames[name]) throw new Error(`Invalid env: ${name}`);
277
- return name;
278
- }
279
- const reactForRNVersion = reactVersion.split(".")[0];
280
- const cssTransformCache = /* @__PURE__ */new Map();
281
- const rolldownPath = (0, import_utils.resolvePath)("rolldown");
282
- const rolldownNodeMods = rolldownPath.slice(0, rolldownPath.indexOf(import_node_path.sep + "node_modules"));
283
- let config;
284
- return [{
285
- name: "one:compiler-resolve-refresh-runtime",
286
- apply: "serve",
287
- enforce: "pre",
288
- // Run before Vite default resolve to avoid syscalls
289
- resolveId: id => id === import_constants.runtimePublicPath || id === `${import_constants.runtimePublicPath}.map` ? id : void 0,
290
- load: id => {
291
- const basePath = (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
292
- if (id === import_constants.runtimePublicPath) {
293
- return (0, import_node_fs.readFileSync)((0, import_node_path.join)(basePath, "refresh-runtime.mjs"), "utf-8").replace(/\/\/# sourceMappingURL=.*/, "");
294
- }
295
- if (id === `${import_constants.runtimePublicPath}.map`) {
296
- return JSON.stringify({
297
- version: 3,
298
- sources: [],
299
- mappings: ""
300
- });
301
- }
302
- return void 0;
303
- }
304
- }, {
305
- name: `one:compiler-css-to-js`,
306
- // only .css files can match, so let rust reject everything else
307
- transform: {
308
- filter: {
309
- id: /\.css$/
310
- },
311
- handler(codeIn, id) {
312
- const environment = getEnvName(this.environment.name);
313
- if (import_configure.configuration.enableNativeCSS && (environment === "ios" || environment === "android")) {
314
- {
315
- const data = JSON.stringify((0, import_css_to_rn.cssToReactNativeRuntime)(codeIn, {
316
- inlineRem: 16
317
- }));
318
- const code = `require("nativewind/dist/index.js").__require().StyleSheet.registerCompiled(${data})`;
319
- const newId = `${id}.js`;
320
- const cssId = newId.replace(rolldownNodeMods + import_node_path.sep, "");
321
- cssTransformCache.set(cssId, code);
322
- return {
323
- code,
324
- id: newId,
325
- map: null
326
- };
327
- }
328
- }
329
- }
330
- },
331
- generateBundle(_, bundle) {
332
- const environment = getEnvName(this.environment.name);
333
- if (import_configure.configuration.enableNativeCSS && (environment === "ios" || environment === "android")) {
334
- const rootJSName = Object.keys(bundle).find(i => {
335
- const chunk = bundle[i];
336
- return chunk.type == "chunk" && chunk.fileName.match(/.[cm]?js(?:\?.+)?$/) != null;
337
- });
338
- if (!rootJSName) {
339
- throw new Error(`Can't find root js, internal one error`);
340
- }
341
- const rootJS = bundle[rootJSName];
342
- const cssAssets = Object.keys(bundle).filter(i => bundle[i].fileName.endsWith(".css.js"));
343
- for (const name of cssAssets) {
344
- delete bundle[name];
345
- const jsCSS = cssTransformCache.get(name);
346
- rootJS.code = `
253
+ const reactVersion = await (async () => {
254
+ const path = (0, import_utils.resolvePath)("react/package.json");
255
+ const json = JSON.parse(await (0, import_promises.readFile)(path, "utf-8"));
256
+ return json.version;
257
+ })();
258
+ const envNames = {
259
+ ios: true,
260
+ android: true,
261
+ client: true,
262
+ ssr: true
263
+ };
264
+ function getEnvName(name) {
265
+ if (name === "worker") return "ssr";
266
+ if (!envNames[name]) throw new Error(`Invalid env: ${name}`);
267
+ return name;
268
+ }
269
+ const reactForRNVersion = reactVersion.split(".")[0];
270
+ const cssTransformCache = /* @__PURE__ */ new Map();
271
+ const rolldownPath = (0, import_utils.resolvePath)("rolldown");
272
+ const rolldownNodeMods = rolldownPath.slice(0, rolldownPath.indexOf(import_node_path.sep + "node_modules"));
273
+ let config;
274
+ return [
275
+ {
276
+ name: "one:compiler-resolve-refresh-runtime",
277
+ apply: "serve",
278
+ enforce: "pre",
279
+ resolveId: (id) => id === import_constants.runtimePublicPath || id === `${import_constants.runtimePublicPath}.map` ? id : void 0,
280
+ load: (id) => {
281
+ const basePath = (0, import_node_path.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
282
+ if (id === import_constants.runtimePublicPath) {
283
+ return (0, import_node_fs.readFileSync)((0, import_node_path.join)(basePath, "refresh-runtime.mjs"), "utf-8").replace(/\/\/# sourceMappingURL=.*/, "");
284
+ }
285
+ if (id === `${import_constants.runtimePublicPath}.map`) {
286
+ return JSON.stringify({
287
+ version: 3,
288
+ sources: [],
289
+ mappings: ""
290
+ });
291
+ }
292
+ return void 0;
293
+ }
294
+ },
295
+ {
296
+ name: `one:compiler-css-to-js`,
297
+ transform: {
298
+ filter: { id: /\.css$/ },
299
+ handler(codeIn, id) {
300
+ const environment = getEnvName(this.environment.name);
301
+ if (import_configure.configuration.enableNativeCSS && (environment === "ios" || environment === "android")) {
302
+ {
303
+ const data = JSON.stringify((0, import_css_to_rn.cssToReactNativeRuntime)(codeIn, { inlineRem: 16 }));
304
+ const code = `require("nativewind/dist/index.js").__require().StyleSheet.registerCompiled(${data})`;
305
+ const newId = `${id}.js`;
306
+ const cssId = newId.replace(rolldownNodeMods + import_node_path.sep, "");
307
+ cssTransformCache.set(cssId, code);
308
+ return {
309
+ code,
310
+ id: newId,
311
+ map: null
312
+ };
313
+ }
314
+ }
315
+ }
316
+ },
317
+ generateBundle(_, bundle) {
318
+ const environment = getEnvName(this.environment.name);
319
+ if (import_configure.configuration.enableNativeCSS && (environment === "ios" || environment === "android")) {
320
+ const rootJSName = Object.keys(bundle).find((i) => {
321
+ const chunk = bundle[i];
322
+ return chunk.type == "chunk" && chunk.fileName.match(/.[cm]?js(?:\?.+)?$/) != null;
323
+ });
324
+ if (!rootJSName) {
325
+ throw new Error(`Can't find root js, internal one error`);
326
+ }
327
+ const rootJS = bundle[rootJSName];
328
+ const cssAssets = Object.keys(bundle).filter((i) => bundle[i].fileName.endsWith(".css.js"));
329
+ for (const name of cssAssets) {
330
+ delete bundle[name];
331
+ const jsCSS = cssTransformCache.get(name);
332
+ rootJS.code = `
347
333
  ${jsCSS}
348
334
  ${rootJS.code}
349
335
  `;
350
- }
351
- }
352
- }
353
- }, {
354
- name: "one:compiler",
355
- enforce: "pre",
356
- config: () => {
357
- const nodeModulesFilter = /node_modules[/\\].*\.(tsx?|jsx?|mjs|cjs)$/;
358
- const createEnvironmentConfig = environment => {
359
- if (!perfStats.optimizeDeps.byEnvironment[environment]) {
360
- perfStats.optimizeDeps.byEnvironment[environment] = {
361
- filesChecked: 0,
362
- filesTransformed: 0,
363
- startTime: Date.now()
364
- };
365
- }
366
- return {
367
- optimizeDeps: {
368
- rolldownOptions: {
369
- plugins: [{
370
- name: `transform-before-optimize-deps-${environment}`,
371
- async transform(code, id) {
372
- if (!nodeModulesFilter.test(id)) {
373
- return null;
374
- }
375
- perfStats.optimizeDeps.byEnvironment[environment].filesChecked++;
376
- const production = process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test";
377
- (0, import_constants.debug)?.(`[rolldown optimizeDeps] ${id}`);
378
- const result = await performBabelTransform({
379
- id,
380
- code,
381
- projectRoot: config.root,
382
- environment,
383
- production,
384
- reactForRNVersion,
385
- optionsIn
386
- });
387
- if (!result) {
388
- return null;
389
- }
390
- perfStats.optimizeDeps.byEnvironment[environment].filesTransformed++;
391
- return {
392
- code: result.code,
393
- map: result.map
394
- };
395
- },
396
- buildEnd() {
397
- if (process.env.DEBUG_COMPILER_PERF) {
398
- const stats = perfStats.optimizeDeps.byEnvironment[environment];
399
- const elapsed = Date.now() - stats.startTime;
400
- console.info(`[optimizeDeps ${environment}] Done: ${stats.filesChecked} files checked, ${stats.filesTransformed} transformed (${elapsed}ms)`);
401
- }
402
- const allDone = Object.keys(perfStats.optimizeDeps.byEnvironment).length >= 2;
403
- if (allDone) {
404
- (0, import_cache.logCacheStats)();
405
- logPerfSummary();
406
- }
407
- }
408
- }]
409
- }
410
- },
411
- define: {
412
- "process.env.NATIVEWIND_OS": JSON.stringify(environment === "ios" || environment === "android" ? "native" : "web")
413
- }
414
- };
415
- };
416
- return {
417
- environments: {
418
- ios: createEnvironmentConfig("ios"),
419
- android: createEnvironmentConfig("android"),
420
- client: createEnvironmentConfig("client"),
421
- ssr: createEnvironmentConfig("ssr")
422
- }
423
- };
424
- },
425
- configResolved(resolvedConfig) {
426
- config = resolvedConfig;
427
- },
428
- async transform(codeIn, _id) {
429
- let code = codeIn;
430
- const environment = getEnvName(this.environment.name);
431
- const isNative = environment === "ios" || environment === "android";
432
- const production = config.command === "build" || process.env.NODE_ENV === "production" || JSON.parse(this.environment.config?.define?.["process.env.NODE_ENV"] || '""') === "production";
433
- const isEntry = _id.includes("one-entry-native");
434
- if (isEntry) {
435
- if (isNative && !production) {
436
- code = `import '@vxrn/vite-native-client'
336
+ }
337
+ }
338
+ }
339
+ },
340
+ {
341
+ name: "one:compiler",
342
+ enforce: "pre",
343
+ config: () => {
344
+ const nodeModulesFilter = /node_modules[/\\].*\.(tsx?|jsx?|mjs|cjs)$/;
345
+ const createEnvironmentConfig = (environment) => {
346
+ if (!perfStats.optimizeDeps.byEnvironment[environment]) {
347
+ perfStats.optimizeDeps.byEnvironment[environment] = {
348
+ filesChecked: 0,
349
+ filesTransformed: 0,
350
+ startTime: Date.now()
351
+ };
352
+ }
353
+ return {
354
+ optimizeDeps: { rolldownOptions: { plugins: [{
355
+ name: `transform-before-optimize-deps-${environment}`,
356
+ async transform(code, id) {
357
+ if (!nodeModulesFilter.test(id)) {
358
+ return null;
359
+ }
360
+ perfStats.optimizeDeps.byEnvironment[environment].filesChecked++;
361
+ const production = process.env.NODE_ENV === "production" || process.env.NODE_ENV === "test";
362
+ (0, import_constants.debug)?.(`[rolldown optimizeDeps] ${id}`);
363
+ const result = await performBabelTransform({
364
+ id,
365
+ code,
366
+ projectRoot: config.root,
367
+ environment,
368
+ production,
369
+ reactForRNVersion,
370
+ optionsIn
371
+ });
372
+ if (!result) {
373
+ return null;
374
+ }
375
+ perfStats.optimizeDeps.byEnvironment[environment].filesTransformed++;
376
+ return {
377
+ code: result.code,
378
+ map: result.map
379
+ };
380
+ },
381
+ buildEnd() {
382
+ if (process.env.DEBUG_COMPILER_PERF) {
383
+ const stats = perfStats.optimizeDeps.byEnvironment[environment];
384
+ const elapsed = Date.now() - stats.startTime;
385
+ console.info(`[optimizeDeps ${environment}] Done: ${stats.filesChecked} files checked, ${stats.filesTransformed} transformed (${elapsed}ms)`);
386
+ }
387
+ const allDone = Object.keys(perfStats.optimizeDeps.byEnvironment).length >= 2;
388
+ if (allDone) {
389
+ (0, import_cache.logCacheStats)();
390
+ logPerfSummary();
391
+ }
392
+ }
393
+ }] } },
394
+ define: { "process.env.NATIVEWIND_OS": JSON.stringify(environment === "ios" || environment === "android" ? "native" : "web") }
395
+ };
396
+ };
397
+ return { environments: {
398
+ ios: createEnvironmentConfig("ios"),
399
+ android: createEnvironmentConfig("android"),
400
+ client: createEnvironmentConfig("client"),
401
+ ssr: createEnvironmentConfig("ssr")
402
+ } };
403
+ },
404
+ configResolved(resolvedConfig) {
405
+ config = resolvedConfig;
406
+ },
407
+ async transform(codeIn, _id) {
408
+ let code = codeIn;
409
+ const environment = getEnvName(this.environment.name);
410
+ const isNative = environment === "ios" || environment === "android";
411
+ const production = config.command === "build" || process.env.NODE_ENV === "production" || JSON.parse(this.environment.config?.define?.["process.env.NODE_ENV"] || "\"\"") === "production";
412
+ const isEntry = _id.includes("one-entry-native");
413
+ if (isEntry) {
414
+ if (isNative && !production) {
415
+ code = `import '@vxrn/vite-native-client'
437
416
  ${code}`;
438
- }
439
- if (isNative && import_configure.configuration.enableNativewind) {
440
- code = `import * as x from 'nativewind'
417
+ }
418
+ if (isNative && import_configure.configuration.enableNativewind) {
419
+ code = `import * as x from 'nativewind'
441
420
  ${code}`;
442
- }
443
- return code;
444
- }
445
- const id = _id.split("?")[0];
446
- const extension = (0, import_node_path.extname)(id);
447
- if (extension === ".css" || !import_constants.validParsers.has(extension)) {
448
- return;
449
- }
450
- if (id.includes(`virtual:`)) {
451
- return;
452
- }
453
- if (codeIn.endsWith(`// vxrn-did-babel`)) {
454
- (0, import_constants.debug)?.(`[skip babel] ${id}`);
455
- return;
456
- }
457
- return performBabelTransform({
458
- id,
459
- code: codeIn,
460
- projectRoot: config.root,
461
- environment,
462
- production,
463
- reactForRNVersion,
464
- optionsIn
465
- });
466
- }
467
- },
468
- // wraps client-side TSX/JSX with React Refresh preamble + import.meta.hot.accept
469
- // runs after vite:oxc (no enforce:'pre') so it sees the already-transformed code
470
- {
471
- name: "one:react-refresh-web",
472
- apply: "serve",
473
- transform(code, _id) {
474
- if (this.environment.name !== "client") return;
475
- if (code.includes(import_constants.runtimePublicPath)) return;
476
- const id = _id.split("?")[0];
477
- if (id.includes("node_modules")) return;
478
- if (id.includes("virtual:")) return;
479
- if (id === import_constants.runtimePublicPath) return;
480
- const ext = (0, import_node_path.extname)(id);
481
- if (ext !== ".tsx" && ext !== ".jsx") return;
482
- const hasRefreshCalls = /\$RefreshReg\$\(/.test(code);
483
- let out = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
421
+ }
422
+ return code;
423
+ }
424
+ const id = _id.split("?")[0];
425
+ const extension = (0, import_node_path.extname)(id);
426
+ if (extension === ".css" || !import_constants.validParsers.has(extension)) {
427
+ return;
428
+ }
429
+ if (id.includes(`virtual:`)) {
430
+ return;
431
+ }
432
+ if (codeIn.endsWith(`// vxrn-did-babel`)) {
433
+ (0, import_constants.debug)?.(`[skip babel] ${id}`);
434
+ return;
435
+ }
436
+ return performBabelTransform({
437
+ id,
438
+ code: codeIn,
439
+ projectRoot: config.root,
440
+ environment,
441
+ production,
442
+ reactForRNVersion,
443
+ optionsIn
444
+ });
445
+ }
446
+ },
447
+ {
448
+ name: "one:react-refresh-web",
449
+ apply: "serve",
450
+ transform(code, _id) {
451
+ if (this.environment.name !== "client") return;
452
+ if (code.includes(import_constants.runtimePublicPath)) return;
453
+ if (/[?&](?:worker|sharedworker|raw|url)\b/.test(_id)) return;
454
+ const id = _id.split("?")[0];
455
+ if (id.includes("node_modules")) return;
456
+ if (id.includes("virtual:")) return;
457
+ if (id === import_constants.runtimePublicPath) return;
458
+ const ext = (0, import_node_path.extname)(id);
459
+ if (ext !== ".tsx" && ext !== ".jsx") return;
460
+ const hasRefreshCalls = /\$RefreshReg\$\(/.test(code);
461
+ let out = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
484
462
 
485
463
  `;
486
- if (hasRefreshCalls) {
487
- out += `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
464
+ if (hasRefreshCalls) {
465
+ out += `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
488
466
  const prevRefreshReg = window.$RefreshReg$;
489
467
  const prevRefreshSig = window.$RefreshSig$;
490
468
  window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
491
469
  window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
492
470
 
493
471
  `;
494
- }
495
- out += code;
496
- if (hasRefreshCalls) {
497
- out += `
472
+ }
473
+ out += code;
474
+ if (hasRefreshCalls) {
475
+ out += `
498
476
 
499
477
  window.$RefreshReg$ = prevRefreshReg;
500
478
  window.$RefreshSig$ = prevRefreshSig;
501
479
  `;
502
- }
503
- out += `
480
+ }
481
+ out += `
504
482
  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
505
483
  RefreshRuntime.registerExportsForReactRefresh("${id}", currentExports);
506
484
  import.meta.hot.accept((nextExports) => {
@@ -510,10 +488,11 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
510
488
  });
511
489
  });
512
490
  `;
513
- return {
514
- code: out,
515
- map: null
516
- };
517
- }
518
- }];
519
- }
491
+ return {
492
+ code: out,
493
+ map: null
494
+ };
495
+ }
496
+ }
497
+ ];
498
+ }