vite-plugin-react-native 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/index.cjs +21 -1
- package/dist/index.js +21 -1
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -435,6 +435,8 @@ function reactNative() {
|
|
|
435
435
|
const pluginDir = path2__default.default.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
436
436
|
const require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
437
437
|
let buildMode = "development";
|
|
438
|
+
let useRolldown = false;
|
|
439
|
+
let transformWithOxcFn = null;
|
|
438
440
|
return {
|
|
439
441
|
name: "react-native",
|
|
440
442
|
enforce: "pre",
|
|
@@ -448,7 +450,7 @@ function reactNative() {
|
|
|
448
450
|
routerDomEntry = fs__default.default.existsSync(path2__default.default.join(routerDomDir, "src/index.ts")) ? path2__default.default.join(routerDomDir, "src/index.ts") : path2__default.default.join(routerDomDir, "dist/index.mjs");
|
|
449
451
|
} catch {
|
|
450
452
|
}
|
|
451
|
-
|
|
453
|
+
useRolldown = getViteMajorVersion(projectRoot, require2) >= 8;
|
|
452
454
|
const resolveExtensions = userConfig.resolve?.extensions ?? [...RESOLVE_EXTENSIONS];
|
|
453
455
|
const installedInclude = getInstalledOptimizeDepsInclude(projectRoot, routerDomEntry);
|
|
454
456
|
const partial = buildViteConfig({
|
|
@@ -486,6 +488,24 @@ function reactNative() {
|
|
|
486
488
|
const reanimated = transformReanimatedWebUtils(resultCode, id, buildMode === "production");
|
|
487
489
|
if (reanimated.changed) resultCode = reanimated.code;
|
|
488
490
|
if (id.includes("node_modules/@react-native") && /\.js$/.test(idPath) && /<[A-Za-z]/.test(resultCode)) {
|
|
491
|
+
if (useRolldown) {
|
|
492
|
+
if (transformWithOxcFn === null) {
|
|
493
|
+
try {
|
|
494
|
+
const vite = await import('vite');
|
|
495
|
+
if (typeof vite.transformWithOxc === "function") {
|
|
496
|
+
transformWithOxcFn = vite.transformWithOxc;
|
|
497
|
+
}
|
|
498
|
+
} catch {
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (transformWithOxcFn) {
|
|
502
|
+
const result2 = await transformWithOxcFn(resultCode, idPath, {
|
|
503
|
+
lang: "jsx",
|
|
504
|
+
sourcemap: true
|
|
505
|
+
});
|
|
506
|
+
return { code: result2.code, map: result2.map ?? null };
|
|
507
|
+
}
|
|
508
|
+
}
|
|
489
509
|
const result = await vite.transformWithEsbuild(resultCode, idPath, {
|
|
490
510
|
loader: "jsx",
|
|
491
511
|
jsx: "automatic"
|
package/dist/index.js
CHANGED
|
@@ -426,6 +426,8 @@ function reactNative() {
|
|
|
426
426
|
const pluginDir = path2.dirname(fileURLToPath(import.meta.url));
|
|
427
427
|
const require2 = createRequire(import.meta.url);
|
|
428
428
|
let buildMode = "development";
|
|
429
|
+
let useRolldown = false;
|
|
430
|
+
let transformWithOxcFn = null;
|
|
429
431
|
return {
|
|
430
432
|
name: "react-native",
|
|
431
433
|
enforce: "pre",
|
|
@@ -439,7 +441,7 @@ function reactNative() {
|
|
|
439
441
|
routerDomEntry = fs.existsSync(path2.join(routerDomDir, "src/index.ts")) ? path2.join(routerDomDir, "src/index.ts") : path2.join(routerDomDir, "dist/index.mjs");
|
|
440
442
|
} catch {
|
|
441
443
|
}
|
|
442
|
-
|
|
444
|
+
useRolldown = getViteMajorVersion(projectRoot, require2) >= 8;
|
|
443
445
|
const resolveExtensions = userConfig.resolve?.extensions ?? [...RESOLVE_EXTENSIONS];
|
|
444
446
|
const installedInclude = getInstalledOptimizeDepsInclude(projectRoot, routerDomEntry);
|
|
445
447
|
const partial = buildViteConfig({
|
|
@@ -477,6 +479,24 @@ function reactNative() {
|
|
|
477
479
|
const reanimated = transformReanimatedWebUtils(resultCode, id, buildMode === "production");
|
|
478
480
|
if (reanimated.changed) resultCode = reanimated.code;
|
|
479
481
|
if (id.includes("node_modules/@react-native") && /\.js$/.test(idPath) && /<[A-Za-z]/.test(resultCode)) {
|
|
482
|
+
if (useRolldown) {
|
|
483
|
+
if (transformWithOxcFn === null) {
|
|
484
|
+
try {
|
|
485
|
+
const vite = await import('vite');
|
|
486
|
+
if (typeof vite.transformWithOxc === "function") {
|
|
487
|
+
transformWithOxcFn = vite.transformWithOxc;
|
|
488
|
+
}
|
|
489
|
+
} catch {
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (transformWithOxcFn) {
|
|
493
|
+
const result2 = await transformWithOxcFn(resultCode, idPath, {
|
|
494
|
+
lang: "jsx",
|
|
495
|
+
sourcemap: true
|
|
496
|
+
});
|
|
497
|
+
return { code: result2.code, map: result2.map ?? null };
|
|
498
|
+
}
|
|
499
|
+
}
|
|
480
500
|
const result = await transformWithEsbuild(resultCode, idPath, {
|
|
481
501
|
loader: "jsx",
|
|
482
502
|
jsx: "automatic"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-native",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Vite plugin for React Native web compatibility",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"@types/node": "^20.0.0",
|
|
47
47
|
"tsup": "^8.5.1",
|
|
48
48
|
"typescript": "^5.0.0",
|
|
49
|
-
"vite": "^
|
|
49
|
+
"vite": "^8.0.0"
|
|
50
50
|
}
|
|
51
51
|
}
|