@vxrn/compiler 1.1.397 → 1.1.399
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 +24 -18
- package/dist/cjs/transformBabel.js +20 -22
- package/dist/cjs/transformBabel.js.map +1 -1
- package/dist/cjs/transformSWC.cjs +76 -77
- package/dist/cjs/transformSWC.js +75 -77
- 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 +20 -21
- package/dist/esm/transformBabel.js.map +1 -1
- package/dist/esm/transformBabel.mjs +24 -18
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformSWC.js +76 -78
- package/dist/esm/transformSWC.js.map +1 -1
- package/dist/esm/transformSWC.mjs +77 -78
- 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 +38 -17
- package/src/transformSWC.ts +104 -106
- 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
|
@@ -29,25 +29,23 @@ var import_core = require("@swc/core"),
|
|
|
29
29
|
import_ts_deepmerge = require("ts-deepmerge"),
|
|
30
30
|
import_configure = require("./configure.cjs"),
|
|
31
31
|
import_constants = require("./constants.cjs");
|
|
32
|
+
const ignoreId = new RegExp(`node_modules\\${import_node_path.sep}(\\.vite|vite)\\${import_node_path.sep}`);
|
|
32
33
|
async function transformSWC(id, code, options, swcOptions) {
|
|
33
|
-
if (
|
|
34
|
+
if (ignoreId.test(id) || (id = id.split("?")[0].replace(process.cwd(), ""), id === import_constants.runtimePublicPath)) return;
|
|
34
35
|
const parser = getParser(id, options.forceJSX);
|
|
35
36
|
if (!parser) return;
|
|
36
|
-
const
|
|
37
|
-
// temp fix idk why this error:
|
|
38
|
-
// 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
|
|
39
|
-
!id.includes("node_modules"),
|
|
40
|
-
refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX,
|
|
37
|
+
const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX && !id.includes("node_modules"),
|
|
41
38
|
reactConfig = {
|
|
42
39
|
refresh,
|
|
43
40
|
development: !options.forceJSX && !options.production,
|
|
44
41
|
runtime: "automatic",
|
|
45
42
|
importSource: "react",
|
|
46
|
-
...(
|
|
47
|
-
importSource: "
|
|
48
|
-
pragma:
|
|
43
|
+
...(import_configure.configuration.enableNativewind && !id.includes("node_modules") ? {
|
|
44
|
+
importSource: "nativewind"
|
|
45
|
+
// pragma: 'createInteropElement',
|
|
46
|
+
// pragmaFrag: '_InteropFragment',
|
|
49
47
|
// swc doesnt actually change the import right
|
|
50
|
-
runtime:
|
|
48
|
+
// runtime: 'classic',
|
|
51
49
|
} : {})
|
|
52
50
|
},
|
|
53
51
|
transformOptions = (() => {
|
|
@@ -122,9 +120,9 @@ ${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(cod
|
|
|
122
120
|
throw e;
|
|
123
121
|
}
|
|
124
122
|
})();
|
|
125
|
-
enableNativeCSS && result.code.includes("createInteropElement") && (result.code = `import { createInteropElement } from 'react-native-css-interop/jsx-dev-runtime'
|
|
123
|
+
import_configure.configuration.enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
|
|
126
124
|
${result.code}`);
|
|
127
|
-
const
|
|
125
|
+
const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
|
|
128
126
|
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
129
127
|
const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
130
128
|
if (typeExportsMatch) for (const typeExport of Array.from(typeExportsMatch)) {
|
|
@@ -138,38 +136,16 @@ ${fakeExport}
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
}
|
|
141
|
-
return
|
|
142
|
-
code: result.code
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
const SWC_ENV = {
|
|
146
|
-
targets: {
|
|
147
|
-
node: "4"
|
|
148
|
-
},
|
|
149
|
-
// debug: true,
|
|
150
|
-
include: [],
|
|
151
|
-
// this breaks the uniswap app for any file with a ...spread
|
|
152
|
-
exclude: ["transform-spread", "transform-destructuring", "transform-object-rest-spread",
|
|
153
|
-
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
154
|
-
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
155
|
-
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
156
|
-
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
157
|
-
"transform-async-to-generator", "transform-regenerator"
|
|
158
|
-
// Similar to above
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
162
|
-
function shouldSourceMap() {
|
|
163
|
-
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
139
|
+
return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
|
|
164
140
|
}
|
|
165
|
-
function wrapSourceInRefreshRuntime(id, result, options,
|
|
166
|
-
return options.environment === "
|
|
141
|
+
function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
|
|
142
|
+
return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
|
|
167
143
|
}
|
|
168
|
-
function wrapSourceInRefreshRuntimeWeb(id, result,
|
|
169
|
-
const sourceMap = JSON.parse(result.map);
|
|
170
|
-
sourceMap.mappings = ";;" + sourceMap.mappings, result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
144
|
+
function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
|
|
145
|
+
const sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
146
|
+
return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
171
147
|
|
|
172
|
-
${result.code}`,
|
|
148
|
+
${result.code}`, hasRefreshRuntime && (sourceMap && (sourceMap.mappings = ";;;;;;" + sourceMap.mappings), result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
173
149
|
const prevRefreshReg = window.$RefreshReg$;
|
|
174
150
|
const prevRefreshSig = window.$RefreshSig$;
|
|
175
151
|
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
@@ -188,49 +164,72 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
|
188
164
|
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
189
165
|
});
|
|
190
166
|
});
|
|
191
|
-
|
|
167
|
+
`, {
|
|
168
|
+
code: result.code,
|
|
169
|
+
map: sourceMap
|
|
170
|
+
};
|
|
192
171
|
}
|
|
193
|
-
function wrapSourceInRefreshRuntimeNative(id, result, options,
|
|
194
|
-
const
|
|
195
|
-
import 'react-native'
|
|
196
|
-
import 'react'
|
|
197
|
-
import '@vxrn/vite-native-client'
|
|
198
|
-
` : "";
|
|
199
|
-
if (options.production) return `
|
|
200
|
-
${prefixCode}
|
|
201
|
-
module.url = '${id}'
|
|
202
|
-
${result.code}
|
|
203
|
-
`;
|
|
204
|
-
shouldHMR && (result.code = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
205
|
-
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
206
|
-
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
207
|
-
console.info("no react refresh setup!")
|
|
208
|
-
return (x) => x
|
|
209
|
-
});
|
|
210
|
-
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
211
|
-
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
212
|
-
|
|
213
|
-
${prefixCode}
|
|
214
|
-
|
|
215
|
-
module.url = '${id}'
|
|
216
|
-
module.hot = createHotContext(module.url)
|
|
217
|
-
|
|
218
|
-
${result.code}
|
|
219
|
-
|
|
220
|
-
if (module.hot) {
|
|
221
|
-
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
222
|
-
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
223
|
-
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
224
|
-
}
|
|
225
|
-
`), result.code = `${result.code}
|
|
226
|
-
|
|
227
|
-
if (module.hot) {
|
|
172
|
+
function wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {
|
|
173
|
+
const postfixCode = `if (module.hot) {
|
|
228
174
|
if (module.hot.accept) {
|
|
229
175
|
module.hot.accept((nextExports) => {
|
|
230
176
|
RefreshRuntime.performReactRefresh()
|
|
231
177
|
});
|
|
232
178
|
}
|
|
233
179
|
}`;
|
|
180
|
+
if (hasRefreshRuntime) {
|
|
181
|
+
const prefixCode = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
182
|
+
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
183
|
+
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
184
|
+
console.info("no react refresh setup!")
|
|
185
|
+
return (x) => x
|
|
186
|
+
});
|
|
187
|
+
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
188
|
+
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
189
|
+
module.url = '${id}'
|
|
190
|
+
module.hot = createHotContext(module.url)`,
|
|
191
|
+
sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
192
|
+
if (sourceMap) {
|
|
193
|
+
const prefixLen = prefixCode.split(`
|
|
194
|
+
`).length + 1;
|
|
195
|
+
sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
code: `${prefixCode}
|
|
199
|
+
${result.code}
|
|
200
|
+
|
|
201
|
+
if (module.hot) {
|
|
202
|
+
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
203
|
+
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
204
|
+
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
${postfixCode}
|
|
208
|
+
`,
|
|
209
|
+
map: sourceMap
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return result.code += postfixCode, result;
|
|
213
|
+
}
|
|
214
|
+
const SWC_ENV = {
|
|
215
|
+
targets: {
|
|
216
|
+
node: "4"
|
|
217
|
+
},
|
|
218
|
+
// debug: true,
|
|
219
|
+
include: [],
|
|
220
|
+
// this breaks the uniswap app for any file with a ...spread
|
|
221
|
+
exclude: ["transform-spread", "transform-destructuring", "transform-object-rest-spread",
|
|
222
|
+
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
223
|
+
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
224
|
+
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
225
|
+
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
226
|
+
"transform-async-to-generator", "transform-regenerator"
|
|
227
|
+
// Similar to above
|
|
228
|
+
]
|
|
229
|
+
},
|
|
230
|
+
refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
231
|
+
function shouldSourceMap() {
|
|
232
|
+
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
234
233
|
}
|
|
235
234
|
function getParser(id, forceJSX = !1) {
|
|
236
235
|
if (id.endsWith("one-entry-native")) return import_constants.parsers[".tsx"];
|
package/dist/cjs/transformSWC.js
CHANGED
|
@@ -19,24 +19,24 @@ __export(transformSWC_exports, {
|
|
|
19
19
|
});
|
|
20
20
|
module.exports = __toCommonJS(transformSWC_exports);
|
|
21
21
|
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");
|
|
22
|
+
const ignoreId = new RegExp(`node_modules\\${import_node_path.sep}(\\.vite|vite)\\${import_node_path.sep}`);
|
|
22
23
|
async function transformSWC(id, code, options, swcOptions) {
|
|
23
|
-
if (
|
|
24
|
+
if (ignoreId.test(id) || (id = id.split("?")[0].replace(process.cwd(), ""), id === import_constants.runtimePublicPath))
|
|
24
25
|
return;
|
|
25
26
|
const parser = getParser(id, options.forceJSX);
|
|
26
27
|
if (!parser)
|
|
27
28
|
return;
|
|
28
|
-
const
|
|
29
|
-
// 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
|
|
30
|
-
!id.includes("node_modules"), refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX, reactConfig = {
|
|
29
|
+
const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX && !id.includes("node_modules"), reactConfig = {
|
|
31
30
|
refresh,
|
|
32
31
|
development: !options.forceJSX && !options.production,
|
|
33
32
|
runtime: "automatic",
|
|
34
33
|
importSource: "react",
|
|
35
|
-
...
|
|
36
|
-
importSource: "
|
|
37
|
-
pragma:
|
|
34
|
+
...import_configure.configuration.enableNativewind && !id.includes("node_modules") ? {
|
|
35
|
+
importSource: "nativewind"
|
|
36
|
+
// pragma: 'createInteropElement',
|
|
37
|
+
// pragmaFrag: '_InteropFragment',
|
|
38
38
|
// swc doesnt actually change the import right
|
|
39
|
-
runtime:
|
|
39
|
+
// runtime: 'classic',
|
|
40
40
|
} : {}
|
|
41
41
|
}, transformOptions = (() => {
|
|
42
42
|
if (options.environment === "client" || options.environment === "ssr")
|
|
@@ -107,9 +107,9 @@ ${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(cod
|
|
|
107
107
|
throw e;
|
|
108
108
|
}
|
|
109
109
|
})();
|
|
110
|
-
enableNativeCSS && result.code.includes("createInteropElement") && (result.code = `import { createInteropElement } from 'react-native-css-interop/jsx-dev-runtime'
|
|
110
|
+
import_configure.configuration.enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
|
|
111
111
|
${result.code}`);
|
|
112
|
-
const
|
|
112
|
+
const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
|
|
113
113
|
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
114
114
|
const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
115
115
|
if (typeExportsMatch)
|
|
@@ -128,39 +128,16 @@ ${fakeExport}
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
return
|
|
131
|
+
return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
|
|
132
132
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
node: "4"
|
|
136
|
-
},
|
|
137
|
-
// debug: true,
|
|
138
|
-
include: [],
|
|
139
|
-
// this breaks the uniswap app for any file with a ...spread
|
|
140
|
-
exclude: [
|
|
141
|
-
"transform-spread",
|
|
142
|
-
"transform-destructuring",
|
|
143
|
-
"transform-object-rest-spread",
|
|
144
|
-
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
145
|
-
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
146
|
-
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
147
|
-
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
148
|
-
"transform-async-to-generator",
|
|
149
|
-
"transform-regenerator"
|
|
150
|
-
// Similar to above
|
|
151
|
-
]
|
|
152
|
-
}, refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
153
|
-
function shouldSourceMap() {
|
|
154
|
-
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
155
|
-
}
|
|
156
|
-
function wrapSourceInRefreshRuntime(id, result, options, shouldHMR) {
|
|
157
|
-
return options.environment === "client" || options.environment === "ssr" ? wrapSourceInRefreshRuntimeWeb(id, result, shouldHMR) : wrapSourceInRefreshRuntimeNative(id, result, options, shouldHMR);
|
|
133
|
+
function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
|
|
134
|
+
return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
|
|
158
135
|
}
|
|
159
|
-
function wrapSourceInRefreshRuntimeWeb(id, result,
|
|
160
|
-
const sourceMap = JSON.parse(result.map);
|
|
161
|
-
sourceMap.mappings = ";;" + sourceMap.mappings, result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
136
|
+
function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
|
|
137
|
+
const sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
138
|
+
return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
162
139
|
|
|
163
|
-
${result.code}`,
|
|
140
|
+
${result.code}`, hasRefreshRuntime && (sourceMap && (sourceMap.mappings = ";;;;;;" + sourceMap.mappings), result.code = `if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
164
141
|
const prevRefreshReg = window.$RefreshReg$;
|
|
165
142
|
const prevRefreshSig = window.$RefreshSig$;
|
|
166
143
|
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
@@ -179,50 +156,71 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
|
179
156
|
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
180
157
|
});
|
|
181
158
|
});
|
|
182
|
-
|
|
159
|
+
`, { code: result.code, map: sourceMap };
|
|
183
160
|
}
|
|
184
|
-
function wrapSourceInRefreshRuntimeNative(id, result, options,
|
|
185
|
-
const
|
|
186
|
-
import 'react-native'
|
|
187
|
-
import 'react'
|
|
188
|
-
import '@vxrn/vite-native-client'
|
|
189
|
-
` : "";
|
|
190
|
-
if (options.production)
|
|
191
|
-
return `
|
|
192
|
-
${prefixCode}
|
|
193
|
-
module.url = '${id}'
|
|
194
|
-
${result.code}
|
|
195
|
-
`;
|
|
196
|
-
shouldHMR && (result.code = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
197
|
-
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
198
|
-
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
199
|
-
console.info("no react refresh setup!")
|
|
200
|
-
return (x) => x
|
|
201
|
-
});
|
|
202
|
-
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
203
|
-
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
204
|
-
|
|
205
|
-
${prefixCode}
|
|
206
|
-
|
|
207
|
-
module.url = '${id}'
|
|
208
|
-
module.hot = createHotContext(module.url)
|
|
209
|
-
|
|
210
|
-
${result.code}
|
|
211
|
-
|
|
212
|
-
if (module.hot) {
|
|
213
|
-
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
214
|
-
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
215
|
-
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
216
|
-
}
|
|
217
|
-
`), result.code = `${result.code}
|
|
218
|
-
|
|
219
|
-
if (module.hot) {
|
|
161
|
+
function wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {
|
|
162
|
+
const postfixCode = `if (module.hot) {
|
|
220
163
|
if (module.hot.accept) {
|
|
221
164
|
module.hot.accept((nextExports) => {
|
|
222
165
|
RefreshRuntime.performReactRefresh()
|
|
223
166
|
});
|
|
224
167
|
}
|
|
225
168
|
}`;
|
|
169
|
+
if (hasRefreshRuntime) {
|
|
170
|
+
const prefixCode = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
171
|
+
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
172
|
+
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
173
|
+
console.info("no react refresh setup!")
|
|
174
|
+
return (x) => x
|
|
175
|
+
});
|
|
176
|
+
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
177
|
+
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
178
|
+
module.url = '${id}'
|
|
179
|
+
module.hot = createHotContext(module.url)`, sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
180
|
+
if (sourceMap) {
|
|
181
|
+
const prefixLen = prefixCode.split(`
|
|
182
|
+
`).length + 1;
|
|
183
|
+
sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
code: `${prefixCode}
|
|
187
|
+
${result.code}
|
|
188
|
+
|
|
189
|
+
if (module.hot) {
|
|
190
|
+
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
191
|
+
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
192
|
+
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
${postfixCode}
|
|
196
|
+
`,
|
|
197
|
+
map: sourceMap
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
return result.code += postfixCode, result;
|
|
201
|
+
}
|
|
202
|
+
const SWC_ENV = {
|
|
203
|
+
targets: {
|
|
204
|
+
node: "4"
|
|
205
|
+
},
|
|
206
|
+
// debug: true,
|
|
207
|
+
include: [],
|
|
208
|
+
// this breaks the uniswap app for any file with a ...spread
|
|
209
|
+
exclude: [
|
|
210
|
+
"transform-spread",
|
|
211
|
+
"transform-destructuring",
|
|
212
|
+
"transform-object-rest-spread",
|
|
213
|
+
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
214
|
+
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
215
|
+
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
216
|
+
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
217
|
+
"transform-async-to-generator",
|
|
218
|
+
"transform-regenerator"
|
|
219
|
+
// Similar to above
|
|
220
|
+
]
|
|
221
|
+
}, refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
222
|
+
function shouldSourceMap() {
|
|
223
|
+
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
226
224
|
}
|
|
227
225
|
function getParser(id, forceJSX = !1) {
|
|
228
226
|
if (id.endsWith("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A,EACF;AACF,GAEM,mBAAmB;AAEzB,SAAS,kBAAkB;AACzB,SAAO,QAAQ,IAAI,2BAA2B;AAChD;AAEA,SAAS,UAAU,IAAY,WAAW,IAAO;AAC/C,MAAI,GAAG,SAAS,kBAAkB;AAChC,WAAO,yBAAQ,MAAM;AAGvB,QAAM,gBAAY,0BAAQ,EAAE;AAC5B,MAAI,SAAwB,YAA6B,yBAAQ,SAAS,IAAlC,yBAAQ,KAAK;AAErD,SAAI,cAAc,UACZ,aACF,SAAS,yBAAQ,MAAM,IAGrB,GAAG,SAAS,mBAAmB,MACjC,SAAS,yBAAQ,MAAM,KAIpB;AACT;AAEO,MAAM,uBAAuB,OAAO,IAAY,SAAiB;AACtE,QAAM,SAAS,UAAU,EAAE;AAC3B,MAAK;AACL,WAAO,UAAM,uBAAU,MAAM;AAAA,MAC3B,UAAU;AAAA,MACV,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,YAAY,gBAAgB;AAAA,MAC5B,KAAK;AAAA,QACH,QAAQ;AAAA,QACR;AAAA,QACA,WAAW;AAAA,UACT,yBAAyB;AAAA,UACzB,OAAO;AAAA,YACL,aAAa;AAAA,YACb,SAAS;AAAA,YACT,SAAS;AAAA,UACX;AAAA,QACF;AAAA,MACF;AAAA,IACF,CAAC;AACH;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/configure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/configure.ts"],
|
|
4
|
-
"mappings": "
|
|
4
|
+
"mappings": "AASO,MAAM,gBAAsB;AAAA,EACjC,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,iBAAiB;AACnB;AAEO,SAAS,4BAA4B,GAAS;AACnD,SAAO,OAAO,eAAe,CAAC;AAChC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/configure.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["configuration","enableReanimated","enableCompiler","enableNativeCSS","configureVXRNCompilerPlugin","_","Object","assign"],"sources":["../../src/configure.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["configuration","enableNativewind","enableReanimated","enableCompiler","enableNativeCSS","configureVXRNCompilerPlugin","_","Object","assign"],"sources":["../../src/configure.ts"],"sourcesContent":[null],"mappings":"AASO,MAAMA,aAAA,GAAsB;EACjCC,gBAAA,EAAkB;EAClBC,gBAAA,EAAkB;EAClBC,cAAA,EAAgB;EAChBC,eAAA,EAAiB;AACnB;AAEO,SAASC,4BAA4BC,CAAA,EAAS;EACnDC,MAAA,CAAOC,MAAA,CAAOR,aAAA,EAAeM,CAAC;AAChC","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { resolvePath } from "@vxrn/utils";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
|
-
import { extname, join } from "node:path";
|
|
4
|
+
import { extname, join, sep } from "node:path";
|
|
5
|
+
import { cssToReactNativeRuntime } from "react-native-css-interop/css-to-rn/index.js";
|
|
6
|
+
import { configuration } from "./configure";
|
|
5
7
|
import { debug, runtimePublicPath, validParsers } from "./constants";
|
|
6
8
|
import { getBabelOptions, transformBabel } from "./transformBabel";
|
|
7
9
|
import { transformSWC } from "./transformSWC";
|
|
@@ -22,6 +24,7 @@ async function createVXRNCompilerPlugin(optionsIn) {
|
|
|
22
24
|
if (!envNames[name]) throw new Error(`Invalid env: ${name}`);
|
|
23
25
|
return name;
|
|
24
26
|
}
|
|
27
|
+
const reactForRNVersion = reactVersion.split(".")[0], cssTransformCache = /* @__PURE__ */ new Map(), rollupPath = resolvePath("rollup"), rollupNodeMods = rollupPath.slice(0, rollupPath.indexOf(sep + "node_modules"));
|
|
25
28
|
return [
|
|
26
29
|
{
|
|
27
30
|
name: "one:compiler-resolve-refresh-runtime",
|
|
@@ -31,6 +34,42 @@ async function createVXRNCompilerPlugin(optionsIn) {
|
|
|
31
34
|
resolveId: (id) => id === runtimePublicPath ? id : void 0,
|
|
32
35
|
load: (id) => id === runtimePublicPath ? readFileSync(join(import.meta.dirname, "refresh-runtime.js"), "utf-8") : void 0
|
|
33
36
|
},
|
|
37
|
+
{
|
|
38
|
+
name: "one:compiler-css-to-js",
|
|
39
|
+
transform(codeIn, id) {
|
|
40
|
+
const environment = getEnvName(this.environment.name);
|
|
41
|
+
if (configuration.enableNativeCSS && (environment === "ios" || environment === "android") && extname(id) === ".css") {
|
|
42
|
+
const code = `require("nativewind/dist/index.js").__require().StyleSheet.registerCompiled(${JSON.stringify(cssToReactNativeRuntime(codeIn, { inlineRem: 16 }))})`, newId = `${id}.js`, cssId = newId.replace(rollupNodeMods + sep, "");
|
|
43
|
+
return cssTransformCache.set(cssId, code), {
|
|
44
|
+
code,
|
|
45
|
+
id: newId,
|
|
46
|
+
map: null
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
generateBundle(_, bundle) {
|
|
51
|
+
const environment = getEnvName(this.environment.name);
|
|
52
|
+
if (configuration.enableNativeCSS && (environment === "ios" || environment === "android")) {
|
|
53
|
+
const rootJSName = Object.keys(bundle).find((i) => {
|
|
54
|
+
const chunk = bundle[i];
|
|
55
|
+
return chunk.type == "chunk" && chunk.fileName.match(/.[cm]?js(?:\?.+)?$/) != null;
|
|
56
|
+
});
|
|
57
|
+
if (!rootJSName)
|
|
58
|
+
throw new Error("Can't find root js, internal one error");
|
|
59
|
+
const rootJS = bundle[rootJSName], cssAssets = Object.keys(bundle).filter(
|
|
60
|
+
(i) => bundle[i].fileName.endsWith(".css.js")
|
|
61
|
+
);
|
|
62
|
+
for (const name of cssAssets) {
|
|
63
|
+
delete bundle[name];
|
|
64
|
+
const jsCSS = cssTransformCache.get(name);
|
|
65
|
+
rootJS.code = `
|
|
66
|
+
${jsCSS}
|
|
67
|
+
${rootJS.code}
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
34
73
|
{
|
|
35
74
|
name: "one:compiler",
|
|
36
75
|
enforce: "pre",
|
|
@@ -39,6 +78,9 @@ async function createVXRNCompilerPlugin(optionsIn) {
|
|
|
39
78
|
esbuild: !1,
|
|
40
79
|
optimizeDeps: {
|
|
41
80
|
noDiscovery: !0
|
|
81
|
+
},
|
|
82
|
+
define: {
|
|
83
|
+
"process.env.NATIVEWIND_OS": "native"
|
|
42
84
|
}
|
|
43
85
|
};
|
|
44
86
|
return {
|
|
@@ -52,21 +94,26 @@ async function createVXRNCompilerPlugin(optionsIn) {
|
|
|
52
94
|
order: "pre",
|
|
53
95
|
async handler(codeIn, _id) {
|
|
54
96
|
let code = codeIn;
|
|
97
|
+
const environment = getEnvName(this.environment.name), isNative = environment === "ios" || environment === "android", production = process.env.NODE_ENV === "production" || JSON.parse(this.environment.config?.define?.["process.env.NODE_ENV"] || '""') === "production";
|
|
98
|
+
if (_id.includes("one-entry-native"))
|
|
99
|
+
return isNative && !production && (code = `import '@vxrn/vite-native-client'
|
|
100
|
+
${code}`), isNative && configuration.enableNativewind && (code = `import * as x from 'nativewind'
|
|
101
|
+
${code}`), code;
|
|
55
102
|
const shouldDebug = process.env.NODE_ENV === "development" && codeIn.startsWith("// debug");
|
|
56
103
|
shouldDebug && (console.info(`[one] ${_id} input:`), console.info(codeIn));
|
|
57
104
|
const extension = extname(_id);
|
|
58
|
-
if (!validParsers.has(extension))
|
|
105
|
+
if (extension === ".css" || !validParsers.has(extension))
|
|
59
106
|
return;
|
|
60
107
|
let id = _id.split("?")[0];
|
|
61
108
|
const isPreProcess = id.startsWith("vxrn-swc-preprocess:");
|
|
62
109
|
if (isPreProcess && (id = id.replace("vxrn-swc-preprocess:", "")), id.includes("virtual:"))
|
|
63
110
|
return;
|
|
64
|
-
const
|
|
111
|
+
const transformProps = {
|
|
65
112
|
id,
|
|
66
113
|
code,
|
|
67
114
|
development: !production,
|
|
68
115
|
environment,
|
|
69
|
-
reactForRNVersion
|
|
116
|
+
reactForRNVersion
|
|
70
117
|
}, userTransform = optionsIn?.transform?.(transformProps);
|
|
71
118
|
if (userTransform === !1)
|
|
72
119
|
return;
|
|
@@ -77,12 +124,12 @@ async function createVXRNCompilerPlugin(optionsIn) {
|
|
|
77
124
|
});
|
|
78
125
|
if (babelOptions) {
|
|
79
126
|
const babelOut = await transformBabel(id, code, babelOptions);
|
|
80
|
-
babelOut && (debug?.(`[${id}] transformed with babel options: ${JSON.stringify(babelOptions)}`), code = babelOut);
|
|
127
|
+
babelOut?.code && (debug?.(`[${id}] transformed with babel options: ${JSON.stringify(babelOptions)}`), code = babelOut.code);
|
|
81
128
|
}
|
|
82
129
|
}
|
|
83
130
|
const swcOptions = {
|
|
84
131
|
environment,
|
|
85
|
-
mode: "serve",
|
|
132
|
+
mode: optionsIn?.mode || "serve",
|
|
86
133
|
production,
|
|
87
134
|
...optionsIn
|
|
88
135
|
}, out = await transformSWC(id, code, {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAKA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,SAAS,
|
|
4
|
+
"mappings": "AAKA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,SAAS,MAAM,WAAW;AACnC,SAAS,+BAA+B;AAGxC,SAAS,qBAAqB;AAC9B,SAAS,OAAO,mBAAmB,oBAAoB;AACvD,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,oBAAoB;AAG7B,cAAc;AACd,cAAc;AACd,cAAc;AAGd,eAAsB,yBACpB,WACyB;AACzB,QAAM,eAAe,OAAO,YAAY;AACtC,UAAM,OA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