vite-plugin-react-native-web 2.0.0 → 2.0.2
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 +1 -1
- package/dist/cjs/index.js +9 -6
- package/dist/es/index.js +9 -6
- package/package.json +4 -2
- package/types/index.d.ts +6 -7
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ export default defineConfig({
|
|
|
27
27
|
If you are getting errors please report them in the issues section.
|
|
28
28
|
|
|
29
29
|
The following variables are defined in the transformed files: (inferred during Vite's build process)
|
|
30
|
-
- `global` as `
|
|
30
|
+
- `global` as `self`
|
|
31
31
|
- `__DEV__` as `process.env.NODE_ENV === 'development'`
|
|
32
32
|
- `process.env.NODE_ENV` as `process.env.NODE_ENV`
|
|
33
33
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var vite = require('vite');
|
|
6
|
-
var flowRemoveTypes = require('flow-remove-types');
|
|
7
5
|
var fs = require('node:fs/promises');
|
|
6
|
+
var flowRemoveTypes = require('flow-remove-types');
|
|
7
|
+
var vite = require('vite');
|
|
8
8
|
|
|
9
9
|
// import type { ViteReactNativeWebOptions } from '../types'
|
|
10
10
|
const development = process.env.NODE_ENV === 'development';
|
|
@@ -44,9 +44,9 @@ const getLoader = (path) => {
|
|
|
44
44
|
const esbuildPlugin = () => ({
|
|
45
45
|
name: 'react-native-web',
|
|
46
46
|
setup: (build) => {
|
|
47
|
-
// We need to manually resolve .web files since the resolveExtensions option does not seem to work properly.
|
|
48
47
|
build.onLoad({ filter: scriptPathPattern }, async (args) => {
|
|
49
48
|
let path = args.path;
|
|
49
|
+
// We need to manually resolve .web files since the resolveExtensions option does not seem to work properly.
|
|
50
50
|
const webPath = args.path.replace(/(\.[^/.]+)$/, '.web$1');
|
|
51
51
|
try {
|
|
52
52
|
await fs.access(webPath);
|
|
@@ -56,7 +56,8 @@ const esbuildPlugin = () => ({
|
|
|
56
56
|
let contents = await fs.readFile(path, 'utf-8');
|
|
57
57
|
const loader = getLoader(path);
|
|
58
58
|
if (nativeLegacyScriptPathPattern.test(path) && flowPragmaPattern.test(contents)) {
|
|
59
|
-
|
|
59
|
+
const transformed = flowRemoveTypes(contents);
|
|
60
|
+
contents = transformed.toString();
|
|
60
61
|
}
|
|
61
62
|
return {
|
|
62
63
|
contents,
|
|
@@ -90,10 +91,12 @@ const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
|
|
|
90
91
|
if (!nativeLegacyScriptPathPattern.test(id)) {
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
94
|
+
let map = null;
|
|
93
95
|
if (flowPragmaPattern.test(code)) {
|
|
94
|
-
|
|
96
|
+
const transformed = flowRemoveTypes(code);
|
|
97
|
+
code = transformed.toString();
|
|
98
|
+
map = transformed.generateMap();
|
|
95
99
|
}
|
|
96
|
-
let map = null;
|
|
97
100
|
if (jsxElementPattern.test(code) || jsxSelfClosingPattern.test(code) || jsxFragmentPattern.test(code)) {
|
|
98
101
|
const loader = getLoader(id);
|
|
99
102
|
const result = await vite.transformWithEsbuild(code, id, {
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { transformWithEsbuild } from 'vite';
|
|
2
|
-
import flowRemoveTypes from 'flow-remove-types';
|
|
3
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import flowRemoveTypes from 'flow-remove-types';
|
|
3
|
+
import { transformWithEsbuild } from 'vite';
|
|
4
4
|
|
|
5
5
|
// import type { ViteReactNativeWebOptions } from '../types'
|
|
6
6
|
const development = process.env.NODE_ENV === 'development';
|
|
@@ -40,9 +40,9 @@ const getLoader = (path) => {
|
|
|
40
40
|
const esbuildPlugin = () => ({
|
|
41
41
|
name: 'react-native-web',
|
|
42
42
|
setup: (build) => {
|
|
43
|
-
// We need to manually resolve .web files since the resolveExtensions option does not seem to work properly.
|
|
44
43
|
build.onLoad({ filter: scriptPathPattern }, async (args) => {
|
|
45
44
|
let path = args.path;
|
|
45
|
+
// We need to manually resolve .web files since the resolveExtensions option does not seem to work properly.
|
|
46
46
|
const webPath = args.path.replace(/(\.[^/.]+)$/, '.web$1');
|
|
47
47
|
try {
|
|
48
48
|
await fs.access(webPath);
|
|
@@ -52,7 +52,8 @@ const esbuildPlugin = () => ({
|
|
|
52
52
|
let contents = await fs.readFile(path, 'utf-8');
|
|
53
53
|
const loader = getLoader(path);
|
|
54
54
|
if (nativeLegacyScriptPathPattern.test(path) && flowPragmaPattern.test(contents)) {
|
|
55
|
-
|
|
55
|
+
const transformed = flowRemoveTypes(contents);
|
|
56
|
+
contents = transformed.toString();
|
|
56
57
|
}
|
|
57
58
|
return {
|
|
58
59
|
contents,
|
|
@@ -86,10 +87,12 @@ const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
|
|
|
86
87
|
if (!nativeLegacyScriptPathPattern.test(id)) {
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
90
|
+
let map = null;
|
|
89
91
|
if (flowPragmaPattern.test(code)) {
|
|
90
|
-
|
|
92
|
+
const transformed = flowRemoveTypes(code);
|
|
93
|
+
code = transformed.toString();
|
|
94
|
+
map = transformed.generateMap();
|
|
91
95
|
}
|
|
92
|
-
let map = null;
|
|
93
96
|
if (jsxElementPattern.test(code) || jsxSelfClosingPattern.test(code) || jsxFragmentPattern.test(code)) {
|
|
94
97
|
const loader = getLoader(id);
|
|
95
98
|
const result = await transformWithEsbuild(code, id, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-native-web",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "rollup -c",
|
|
27
|
+
"lint": "biome check --write ./src ./types ./biome.json ./tsconfig.json ./rollup.config.mjs",
|
|
27
28
|
"prerelease": "npm run build",
|
|
28
29
|
"release": "npm publish"
|
|
29
30
|
},
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"flow-remove-types": "^2.233.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
48
|
+
"@biomejs/biome": "^1.9.4",
|
|
47
49
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
48
50
|
"@types/node": "^20.12.4",
|
|
49
51
|
"rollup": "^4.14.0",
|
|
@@ -52,4 +54,4 @@
|
|
|
52
54
|
"vite": "^5.2.8"
|
|
53
55
|
},
|
|
54
56
|
"types": "./types/index.d.ts"
|
|
55
|
-
}
|
|
57
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { Plugin as VitePlugin } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default function reactNativeWeb(options?: ViteReactNativeWebOptions): VitePlugin
|
|
1
|
+
import type { Plugin as VitePlugin } from 'vite'
|
|
2
|
+
|
|
3
|
+
// biome-ignore lint/complexity/noBannedTypes: Empty type for now
|
|
4
|
+
export type ViteReactNativeWebOptions = {}
|
|
5
|
+
|
|
6
|
+
export default function reactNativeWeb(options?: ViteReactNativeWebOptions): VitePlugin
|