@vxrn/compiler 1.1.397 → 1.1.398
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/configure.cjs +1 -0
- package/dist/cjs/configure.js +1 -0
- package/dist/cjs/configure.js.map +1 -1
- package/dist/cjs/index.cjs +57 -7
- package/dist/cjs/index.js +51 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/refresh-runtime.cjs +1 -3
- package/dist/cjs/refresh-runtime.js +1 -1
- package/dist/cjs/refresh-runtime.js.map +1 -1
- package/dist/cjs/transformBabel.cjs +22 -18
- package/dist/cjs/transformBabel.js +19 -22
- package/dist/cjs/transformBabel.js.map +1 -1
- package/dist/cjs/transformSWC.cjs +77 -76
- package/dist/cjs/transformSWC.js +76 -76
- package/dist/cjs/transformSWC.js.map +1 -1
- package/dist/esm/configure.js +1 -0
- package/dist/esm/configure.js.map +1 -1
- package/dist/esm/configure.mjs +1 -0
- package/dist/esm/configure.mjs.map +1 -1
- package/dist/esm/index.js +53 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +58 -8
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/refresh-runtime.js +1 -1
- package/dist/esm/refresh-runtime.js.map +1 -1
- package/dist/esm/refresh-runtime.mjs +1 -3
- package/dist/esm/refresh-runtime.mjs.map +1 -1
- package/dist/esm/transformBabel.js +19 -21
- package/dist/esm/transformBabel.js.map +1 -1
- package/dist/esm/transformBabel.mjs +22 -18
- package/dist/esm/transformBabel.mjs.map +1 -1
- package/dist/esm/transformSWC.js +77 -77
- package/dist/esm/transformSWC.js.map +1 -1
- package/dist/esm/transformSWC.mjs +78 -77
- package/dist/esm/transformSWC.mjs.map +1 -1
- package/package.json +10 -8
- package/src/configure.ts +2 -0
- package/src/index.ts +108 -11
- package/src/refresh-runtime.js +1 -1
- package/src/transformBabel.ts +36 -17
- package/src/transformSWC.ts +102 -102
- package/types/configure.d.ts +1 -0
- package/types/configure.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/transformBabel.d.ts +1 -1
- package/types/transformBabel.d.ts.map +1 -1
- package/types/transformSWC.d.ts +4 -1
- package/types/transformSWC.d.ts.map +1 -1
- package/dist/cjs/configure.native.js +0 -35
- package/dist/cjs/configure.native.js.map +0 -6
- package/dist/cjs/constants.native.js +0 -65
- package/dist/cjs/constants.native.js.map +0 -6
- package/dist/cjs/index.native.js +0 -123
- package/dist/cjs/index.native.js.map +0 -6
- package/dist/cjs/refresh-runtime.native.js +0 -316
- package/dist/cjs/refresh-runtime.native.js.map +0 -6
- package/dist/cjs/transformBabel.native.js +0 -152
- package/dist/cjs/transformBabel.native.js.map +0 -6
- package/dist/cjs/transformSWC.native.js +0 -275
- package/dist/cjs/transformSWC.native.js.map +0 -6
- package/dist/cjs/types.native.js +0 -15
- package/dist/cjs/types.native.js.map +0 -6
- package/dist/esm/configure.native.js +0 -13
- package/dist/esm/configure.native.js.map +0 -6
- package/dist/esm/constants.native.js +0 -41
- package/dist/esm/constants.native.js.map +0 -6
- package/dist/esm/index.native.js +0 -104
- package/dist/esm/index.native.js.map +0 -6
- package/dist/esm/refresh-runtime.native.js +0 -290
- package/dist/esm/refresh-runtime.native.js.map +0 -6
- package/dist/esm/transformBabel.native.js +0 -125
- package/dist/esm/transformBabel.native.js.map +0 -6
- package/dist/esm/transformSWC.native.js +0 -257
- package/dist/esm/transformSWC.native.js.map +0 -6
- package/dist/esm/types.native.js +0 -1
- package/dist/esm/types.native.js.map +0 -6
|
@@ -29,25 +29,25 @@ 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 enableNativeCSS = import_configure.configuration.enableNativeCSS
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
!id.includes("node_modules"),
|
|
40
|
-
refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX,
|
|
37
|
+
const enableNativeCSS = import_configure.configuration.enableNativeCSS;
|
|
38
|
+
id.includes("node_modules");
|
|
39
|
+
const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX,
|
|
41
40
|
reactConfig = {
|
|
42
41
|
refresh,
|
|
43
42
|
development: !options.forceJSX && !options.production,
|
|
44
43
|
runtime: "automatic",
|
|
45
44
|
importSource: "react",
|
|
46
45
|
...(enableNativeCSS ? {
|
|
47
|
-
importSource: "
|
|
48
|
-
pragma:
|
|
46
|
+
importSource: "nativewind"
|
|
47
|
+
// pragma: 'createInteropElement',
|
|
48
|
+
// pragmaFrag: '_InteropFragment',
|
|
49
49
|
// swc doesnt actually change the import right
|
|
50
|
-
runtime:
|
|
50
|
+
// runtime: 'classic',
|
|
51
51
|
} : {})
|
|
52
52
|
},
|
|
53
53
|
transformOptions = (() => {
|
|
@@ -122,9 +122,9 @@ ${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(cod
|
|
|
122
122
|
throw e;
|
|
123
123
|
}
|
|
124
124
|
})();
|
|
125
|
-
enableNativeCSS && result.code.includes("createInteropElement") && (result.code = `import { createInteropElement } from 'react-native-css-interop/jsx-dev-runtime'
|
|
125
|
+
enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
|
|
126
126
|
${result.code}`);
|
|
127
|
-
const
|
|
127
|
+
const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
|
|
128
128
|
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
129
129
|
const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
130
130
|
if (typeExportsMatch) for (const typeExport of Array.from(typeExportsMatch)) {
|
|
@@ -138,38 +138,16 @@ ${fakeExport}
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
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";
|
|
141
|
+
return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
|
|
164
142
|
}
|
|
165
|
-
function wrapSourceInRefreshRuntime(id, result, options,
|
|
166
|
-
return options.environment === "
|
|
143
|
+
function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
|
|
144
|
+
return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
|
|
167
145
|
}
|
|
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}";
|
|
146
|
+
function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
|
|
147
|
+
const sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
148
|
+
return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
171
149
|
|
|
172
|
-
${result.code}`,
|
|
150
|
+
${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
151
|
const prevRefreshReg = window.$RefreshReg$;
|
|
174
152
|
const prevRefreshSig = window.$RefreshSig$;
|
|
175
153
|
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
@@ -188,49 +166,72 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
|
188
166
|
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
189
167
|
});
|
|
190
168
|
});
|
|
191
|
-
|
|
169
|
+
`, {
|
|
170
|
+
code: result.code,
|
|
171
|
+
map: sourceMap
|
|
172
|
+
};
|
|
192
173
|
}
|
|
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) {
|
|
174
|
+
function wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {
|
|
175
|
+
const postfixCode = `if (module.hot) {
|
|
228
176
|
if (module.hot.accept) {
|
|
229
177
|
module.hot.accept((nextExports) => {
|
|
230
178
|
RefreshRuntime.performReactRefresh()
|
|
231
179
|
});
|
|
232
180
|
}
|
|
233
181
|
}`;
|
|
182
|
+
if (hasRefreshRuntime) {
|
|
183
|
+
const prefixCode = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
184
|
+
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
185
|
+
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
186
|
+
console.info("no react refresh setup!")
|
|
187
|
+
return (x) => x
|
|
188
|
+
});
|
|
189
|
+
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
190
|
+
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
191
|
+
module.url = '${id}'
|
|
192
|
+
module.hot = createHotContext(module.url)`,
|
|
193
|
+
sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
194
|
+
if (sourceMap) {
|
|
195
|
+
const prefixLen = prefixCode.split(`
|
|
196
|
+
`).length + 1;
|
|
197
|
+
sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
code: `${prefixCode}
|
|
201
|
+
${result.code}
|
|
202
|
+
|
|
203
|
+
if (module.hot) {
|
|
204
|
+
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
205
|
+
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
206
|
+
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
${postfixCode}
|
|
210
|
+
`,
|
|
211
|
+
map: sourceMap
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return result.code += postfixCode, result;
|
|
215
|
+
}
|
|
216
|
+
const SWC_ENV = {
|
|
217
|
+
targets: {
|
|
218
|
+
node: "4"
|
|
219
|
+
},
|
|
220
|
+
// debug: true,
|
|
221
|
+
include: [],
|
|
222
|
+
// this breaks the uniswap app for any file with a ...spread
|
|
223
|
+
exclude: ["transform-spread", "transform-destructuring", "transform-object-rest-spread",
|
|
224
|
+
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
225
|
+
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
226
|
+
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
227
|
+
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
228
|
+
"transform-async-to-generator", "transform-regenerator"
|
|
229
|
+
// Similar to above
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
233
|
+
function shouldSourceMap() {
|
|
234
|
+
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
234
235
|
}
|
|
235
236
|
function getParser(id, forceJSX = !1) {
|
|
236
237
|
if (id.endsWith("one-entry-native")) return import_constants.parsers[".tsx"];
|
package/dist/cjs/transformSWC.js
CHANGED
|
@@ -19,24 +19,26 @@ __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 enableNativeCSS = import_configure.configuration.enableNativeCSS
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const enableNativeCSS = import_configure.configuration.enableNativeCSS;
|
|
30
|
+
id.includes("node_modules");
|
|
31
|
+
const refresh = options.environment !== "ssr" && !options.production && !options.noHMR && !options.forceJSX, reactConfig = {
|
|
31
32
|
refresh,
|
|
32
33
|
development: !options.forceJSX && !options.production,
|
|
33
34
|
runtime: "automatic",
|
|
34
35
|
importSource: "react",
|
|
35
36
|
...enableNativeCSS ? {
|
|
36
|
-
importSource: "
|
|
37
|
-
pragma:
|
|
37
|
+
importSource: "nativewind"
|
|
38
|
+
// pragma: 'createInteropElement',
|
|
39
|
+
// pragmaFrag: '_InteropFragment',
|
|
38
40
|
// swc doesnt actually change the import right
|
|
39
|
-
runtime:
|
|
41
|
+
// runtime: 'classic',
|
|
40
42
|
} : {}
|
|
41
43
|
}, transformOptions = (() => {
|
|
42
44
|
if (options.environment === "client" || options.environment === "ssr")
|
|
@@ -107,9 +109,9 @@ ${JSON.stringify(finalOptions, null, 2)}`), await (0, import_core.transform)(cod
|
|
|
107
109
|
throw e;
|
|
108
110
|
}
|
|
109
111
|
})();
|
|
110
|
-
enableNativeCSS && result.code.includes("createInteropElement") && (result.code = `import { createInteropElement } from 'react-native-css-interop/jsx-dev-runtime'
|
|
112
|
+
enableNativeCSS && result.code.includes("createInteropElement(") && (result.code = `import { createInteropElement, Fragment as _InteropFragment } from 'react-native-css-interop/jsx-dev-runtime'
|
|
111
113
|
${result.code}`);
|
|
112
|
-
const
|
|
114
|
+
const hasRefreshRuntime = refresh && refreshContentRE.test(result.code);
|
|
113
115
|
if (options.fixNonTypeSpecificImports || id.includes("node_modules") && parser.syntax === "typescript") {
|
|
114
116
|
const typeExportsMatch = code.match(/^\s*export\s+type\s+([^\s]+)/gi);
|
|
115
117
|
if (typeExportsMatch)
|
|
@@ -128,39 +130,16 @@ ${fakeExport}
|
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
|
-
return
|
|
133
|
+
return result && !options.production && !options.noHMR ? wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) : result;
|
|
132
134
|
}
|
|
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);
|
|
135
|
+
function wrapSourceInRefreshRuntime(id, result, options, hasRefreshRuntime) {
|
|
136
|
+
return options.environment === "ssr" ? result : options.environment === "client" ? wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) : wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime);
|
|
158
137
|
}
|
|
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}";
|
|
138
|
+
function wrapSourceInRefreshRuntimeWeb(id, result, hasRefreshRuntime) {
|
|
139
|
+
const sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
140
|
+
return sourceMap && (sourceMap.mappings = ";;" + sourceMap.mappings), result.code = `import * as RefreshRuntime from "${import_constants.runtimePublicPath}";
|
|
162
141
|
|
|
163
|
-
${result.code}`,
|
|
142
|
+
${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
143
|
const prevRefreshReg = window.$RefreshReg$;
|
|
165
144
|
const prevRefreshSig = window.$RefreshSig$;
|
|
166
145
|
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${id}");
|
|
@@ -179,50 +158,71 @@ RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
|
179
158
|
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
180
159
|
});
|
|
181
160
|
});
|
|
182
|
-
|
|
161
|
+
`, { code: result.code, map: sourceMap };
|
|
183
162
|
}
|
|
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) {
|
|
163
|
+
function wrapSourceInRefreshRuntimeNative(id, result, options, hasRefreshRuntime) {
|
|
164
|
+
const postfixCode = `if (module.hot) {
|
|
220
165
|
if (module.hot.accept) {
|
|
221
166
|
module.hot.accept((nextExports) => {
|
|
222
167
|
RefreshRuntime.performReactRefresh()
|
|
223
168
|
});
|
|
224
169
|
}
|
|
225
170
|
}`;
|
|
171
|
+
if (hasRefreshRuntime) {
|
|
172
|
+
const prefixCode = `const RefreshRuntime = __cachedModules["react-refresh/cjs/react-refresh-runtime.development"];
|
|
173
|
+
const prevRefreshReg = globalThis.$RefreshReg$;
|
|
174
|
+
const prevRefreshSig = globalThis.$RefreshSig$ || (() => {
|
|
175
|
+
console.info("no react refresh setup!")
|
|
176
|
+
return (x) => x
|
|
177
|
+
});
|
|
178
|
+
globalThis.$RefreshReg$ = (type, id) => RefreshRuntime.register(type, "${id}" + " " + id);
|
|
179
|
+
globalThis.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
180
|
+
module.url = '${id}'
|
|
181
|
+
module.hot = createHotContext(module.url)`, sourceMap = result.map ? JSON.parse(result.map) : void 0;
|
|
182
|
+
if (sourceMap) {
|
|
183
|
+
const prefixLen = prefixCode.split(`
|
|
184
|
+
`).length + 1;
|
|
185
|
+
sourceMap.mappings = new Array(prefixLen).fill(";").join("") + sourceMap.mappings;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
code: `${prefixCode}
|
|
189
|
+
${result.code}
|
|
190
|
+
|
|
191
|
+
if (module.hot) {
|
|
192
|
+
globalThis.$RefreshReg$ = prevRefreshReg;
|
|
193
|
+
globalThis.$RefreshSig$ = prevRefreshSig;
|
|
194
|
+
globalThis['lastHmrExports'] = JSON.stringify(Object.keys(exports))
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
${postfixCode}
|
|
198
|
+
`,
|
|
199
|
+
map: sourceMap
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return result.code += postfixCode, result;
|
|
203
|
+
}
|
|
204
|
+
const SWC_ENV = {
|
|
205
|
+
targets: {
|
|
206
|
+
node: "4"
|
|
207
|
+
},
|
|
208
|
+
// debug: true,
|
|
209
|
+
include: [],
|
|
210
|
+
// this breaks the uniswap app for any file with a ...spread
|
|
211
|
+
exclude: [
|
|
212
|
+
"transform-spread",
|
|
213
|
+
"transform-destructuring",
|
|
214
|
+
"transform-object-rest-spread",
|
|
215
|
+
// `transform-async-to-generator` is relying on `transform-destructuring`.
|
|
216
|
+
// If we exclude `transform-destructuring` but not `transform-async-to-generator`, the SWC binary will panic
|
|
217
|
+
// with error: `called `Option::unwrap()` on a `None` value`.
|
|
218
|
+
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
219
|
+
"transform-async-to-generator",
|
|
220
|
+
"transform-regenerator"
|
|
221
|
+
// Similar to above
|
|
222
|
+
]
|
|
223
|
+
}, refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
224
|
+
function shouldSourceMap() {
|
|
225
|
+
return process.env.VXRN_ENABLE_SOURCE_MAP === "1";
|
|
226
226
|
}
|
|
227
227
|
function getParser(id, forceJSX = !1) {
|
|
228
228
|
if (id.endsWith("one-entry-native"))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/transformSWC.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAMO,sBAEP,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAMO,sBAEP,mBAA6B,sBAC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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").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,OAAO,YAAY,oBAAoB;AAE7C,WADa,KAAK,MAAM,MAAM,SAAS,MAAM,OAAO,CAAC,EACzC;AAAA,EACd,GAAG,GAEG,WAAW;AAAA,IACf,KAAK;AAAA,IACL,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,KAAK;AAAA,EACP;AAEA,WAAS,WAAW,MAAc;AAChC,QAAI,CAAC,SAAS,IAAI,EAAG,OAAM,IAAI,MAAM,gBAAgB,IAAI,EAAE;AAC3D,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,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