vite-plugin-react-native-web 3.0.0-rc.2 → 3.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/dist/cjs/index.js +22 -29
- package/dist/es/index.js +20 -30
- package/package.json +2 -4
- package/README.md +0 -53
- package/dist/cjs/build2-DTMMS--0.js +0 -5267
- package/dist/cjs/chunk-D0RAK71K.js +0 -75
- package/dist/cjs/chunk-DyKKrNZQ.js +0 -35
- package/dist/cjs/lib-Csqa2WBC.js +0 -370
- package/dist/cjs/node-BU5sMlzK.js +0 -799
- package/dist/cjs/postcss-DAB3_PkB.js +0 -5428
- package/dist/cjs/postcss-import-Ogs8NQqH.js +0 -450
- package/dist/cjs/prompt-BYQIwEjg-CGdBgYkO.js +0 -850
- package/dist/es/build2-D4SLif06.js +0 -5267
- package/dist/es/chunk-CRPLlQ3x.js +0 -28
- package/dist/es/chunk-CU5vi22U.js +0 -39
- package/dist/es/lib-CK8QVVm9.js +0 -365
- package/dist/es/node-mn1xxwR1.js +0 -790
- package/dist/es/postcss-gI9snXny.js +0 -3217
- package/dist/es/postcss-import-BvPWe_Qj.js +0 -450
- package/dist/es/prompt-BYQIwEjg-C9BFbUKm.js +0 -847
package/dist/cjs/index.js
CHANGED
|
@@ -27,11 +27,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
let flow_remove_types = require("flow-remove-types");
|
|
28
28
|
flow_remove_types = __toESM(flow_remove_types);
|
|
29
29
|
//#region src/plugins/flow-remove-types-plugin.ts
|
|
30
|
-
const reactNativeFlowJsxPathPattern = /\.(js|flow)$/;
|
|
31
30
|
const flowRemoveTypesPlugin = () => ({
|
|
32
31
|
name: "flow-remove-types",
|
|
33
32
|
transform: {
|
|
34
|
-
filter: {
|
|
33
|
+
filter: { code: /@flow/ },
|
|
35
34
|
handler: async (code) => {
|
|
36
35
|
code = (0, flow_remove_types.default)(code).toString();
|
|
37
36
|
return code;
|
|
@@ -50,18 +49,6 @@ const treeshakeFixPlugin = () => ({
|
|
|
50
49
|
}
|
|
51
50
|
});
|
|
52
51
|
//#endregion
|
|
53
|
-
//#region src/plugins/type-exports-fix.ts
|
|
54
|
-
const typeExportsFixPlugin = () => ({
|
|
55
|
-
name: "type-exports-fix",
|
|
56
|
-
load: {
|
|
57
|
-
filter: { id: /expo-modules-core.*ts-declarations.*\.ts$/ },
|
|
58
|
-
handler: () => ({
|
|
59
|
-
code: "export {}",
|
|
60
|
-
moduleType: "js"
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
//#endregion
|
|
65
52
|
//#region src/index.ts
|
|
66
53
|
const development = process.env.NODE_ENV === "development";
|
|
67
54
|
const extensions = [
|
|
@@ -81,13 +68,20 @@ const extensions = [
|
|
|
81
68
|
];
|
|
82
69
|
const moduleTypes = {
|
|
83
70
|
".js": "jsx",
|
|
71
|
+
".mjs": "jsx",
|
|
72
|
+
".cjs": "jsx",
|
|
84
73
|
".flow": "jsx"
|
|
85
74
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
const treeshakePreset = {
|
|
76
|
+
annotations: true,
|
|
77
|
+
invalidImportSideEffects: true,
|
|
78
|
+
manualPureFunctions: [],
|
|
79
|
+
moduleSideEffects: true,
|
|
80
|
+
propertyReadSideEffects: "always",
|
|
81
|
+
unknownGlobalSideEffects: true,
|
|
82
|
+
propertyWriteSideEffects: "always"
|
|
83
|
+
};
|
|
84
|
+
const optimizeDepsInclude = ["react-native-web"];
|
|
91
85
|
const reactNativeWeb = (_options) => ({
|
|
92
86
|
enforce: "pre",
|
|
93
87
|
name: "react-native-web",
|
|
@@ -107,28 +101,27 @@ const reactNativeWeb = (_options) => ({
|
|
|
107
101
|
},
|
|
108
102
|
build: { rolldownOptions: {
|
|
109
103
|
resolve: { extensions },
|
|
104
|
+
shimMissingExports: true,
|
|
105
|
+
treeshake: treeshakePreset,
|
|
110
106
|
moduleTypes,
|
|
111
|
-
plugins: [
|
|
112
|
-
flowRemoveTypesPlugin(),
|
|
113
|
-
treeshakeFixPlugin(),
|
|
114
|
-
typeExportsFixPlugin()
|
|
115
|
-
]
|
|
107
|
+
plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
|
|
116
108
|
} },
|
|
117
109
|
optimizeDeps: {
|
|
118
110
|
include: optimizeDepsInclude,
|
|
119
111
|
rolldownOptions: {
|
|
120
112
|
resolve: { extensions },
|
|
113
|
+
shimMissingExports: true,
|
|
114
|
+
treeshake: treeshakePreset,
|
|
121
115
|
moduleTypes,
|
|
122
|
-
plugins: [
|
|
123
|
-
flowRemoveTypesPlugin(),
|
|
124
|
-
treeshakeFixPlugin(),
|
|
125
|
-
typeExportsFixPlugin()
|
|
126
|
-
]
|
|
116
|
+
plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
|
|
127
117
|
}
|
|
128
118
|
}
|
|
129
119
|
})
|
|
130
120
|
});
|
|
131
121
|
//#endregion
|
|
132
122
|
exports.default = reactNativeWeb;
|
|
123
|
+
exports.reactNativeWeb = reactNativeWeb;
|
|
124
|
+
exports.flowRemoveTypesPlugin = flowRemoveTypesPlugin;
|
|
125
|
+
exports.treeshakeFixPlugin = treeshakeFixPlugin;
|
|
133
126
|
|
|
134
127
|
//# sourceMappingURL=index.js.map
|
package/dist/es/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import flowRemoveTypes from "flow-remove-types";
|
|
2
2
|
//#region src/plugins/flow-remove-types-plugin.ts
|
|
3
|
-
const reactNativeFlowJsxPathPattern = /\.(js|flow)$/;
|
|
4
3
|
const flowRemoveTypesPlugin = () => ({
|
|
5
4
|
name: "flow-remove-types",
|
|
6
5
|
transform: {
|
|
7
|
-
filter: {
|
|
6
|
+
filter: { code: /@flow/ },
|
|
8
7
|
handler: async (code) => {
|
|
9
8
|
code = flowRemoveTypes(code).toString();
|
|
10
9
|
return code;
|
|
@@ -23,18 +22,6 @@ const treeshakeFixPlugin = () => ({
|
|
|
23
22
|
}
|
|
24
23
|
});
|
|
25
24
|
//#endregion
|
|
26
|
-
//#region src/plugins/type-exports-fix.ts
|
|
27
|
-
const typeExportsFixPlugin = () => ({
|
|
28
|
-
name: "type-exports-fix",
|
|
29
|
-
load: {
|
|
30
|
-
filter: { id: /expo-modules-core.*ts-declarations.*\.ts$/ },
|
|
31
|
-
handler: () => ({
|
|
32
|
-
code: "export {}",
|
|
33
|
-
moduleType: "js"
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
//#endregion
|
|
38
25
|
//#region src/index.ts
|
|
39
26
|
const development = false;
|
|
40
27
|
const extensions = [
|
|
@@ -54,13 +41,20 @@ const extensions = [
|
|
|
54
41
|
];
|
|
55
42
|
const moduleTypes = {
|
|
56
43
|
".js": "jsx",
|
|
44
|
+
".mjs": "jsx",
|
|
45
|
+
".cjs": "jsx",
|
|
57
46
|
".flow": "jsx"
|
|
58
47
|
};
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
const treeshakePreset = {
|
|
49
|
+
annotations: true,
|
|
50
|
+
invalidImportSideEffects: true,
|
|
51
|
+
manualPureFunctions: [],
|
|
52
|
+
moduleSideEffects: true,
|
|
53
|
+
propertyReadSideEffects: "always",
|
|
54
|
+
unknownGlobalSideEffects: true,
|
|
55
|
+
propertyWriteSideEffects: "always"
|
|
56
|
+
};
|
|
57
|
+
const optimizeDepsInclude = ["react-native-web"];
|
|
64
58
|
const reactNativeWeb = (_options) => ({
|
|
65
59
|
enforce: "pre",
|
|
66
60
|
name: "react-native-web",
|
|
@@ -80,28 +74,24 @@ const reactNativeWeb = (_options) => ({
|
|
|
80
74
|
},
|
|
81
75
|
build: { rolldownOptions: {
|
|
82
76
|
resolve: { extensions },
|
|
77
|
+
shimMissingExports: true,
|
|
78
|
+
treeshake: treeshakePreset,
|
|
83
79
|
moduleTypes,
|
|
84
|
-
plugins: [
|
|
85
|
-
flowRemoveTypesPlugin(),
|
|
86
|
-
treeshakeFixPlugin(),
|
|
87
|
-
typeExportsFixPlugin()
|
|
88
|
-
]
|
|
80
|
+
plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
|
|
89
81
|
} },
|
|
90
82
|
optimizeDeps: {
|
|
91
83
|
include: optimizeDepsInclude,
|
|
92
84
|
rolldownOptions: {
|
|
93
85
|
resolve: { extensions },
|
|
86
|
+
shimMissingExports: true,
|
|
87
|
+
treeshake: treeshakePreset,
|
|
94
88
|
moduleTypes,
|
|
95
|
-
plugins: [
|
|
96
|
-
flowRemoveTypesPlugin(),
|
|
97
|
-
treeshakeFixPlugin(),
|
|
98
|
-
typeExportsFixPlugin()
|
|
99
|
-
]
|
|
89
|
+
plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
|
|
100
90
|
}
|
|
101
91
|
}
|
|
102
92
|
})
|
|
103
93
|
});
|
|
104
94
|
//#endregion
|
|
105
|
-
export { reactNativeWeb as default };
|
|
95
|
+
export { reactNativeWeb as default, reactNativeWeb, flowRemoveTypesPlugin, treeshakeFixPlugin };
|
|
106
96
|
|
|
107
97
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-react-native-web",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rolldown -c rolldown.config.ts",
|
|
28
|
-
"lint": "biome check --write",
|
|
29
28
|
"prerelease": "npm run build",
|
|
30
29
|
"release": "npm publish"
|
|
31
30
|
},
|
|
@@ -43,10 +42,9 @@
|
|
|
43
42
|
"react-native-web"
|
|
44
43
|
],
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"flow-remove-types": "^2.
|
|
45
|
+
"flow-remove-types": "^2.305.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@biomejs/biome": "^2.4.6",
|
|
50
48
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
51
49
|
"@types/node": "^25.5.0",
|
|
52
50
|
"rolldown": "^1.0.0-rc.9",
|
package/README.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# vite-plugin-react-native-web
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/vite-plugin-react-native-web)
|
|
4
|
-
|
|
5
|
-
Add React Native Web support to Vite by removing Flow types, aliasing `react-native` to `react-native-web` and transforming .js files as .jsx files using ESBuild.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Just install it:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm i vite-plugin-react-native-web -D
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import reactNativeWeb from "vite-plugin-react-native-web";
|
|
19
|
-
|
|
20
|
-
export default defineConfig({
|
|
21
|
-
plugins: [reactNativeWeb({ ... })],
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
If you are getting errors please report them in the issues section.
|
|
26
|
-
|
|
27
|
-
The following variables are defined in the transformed files: (inferred during Vite's build process)
|
|
28
|
-
|
|
29
|
-
- `global` as `globalThis`
|
|
30
|
-
- `__DEV__` as `process.env.NODE_ENV === 'development'`
|
|
31
|
-
- `process.env.NODE_ENV` as `process.env.NODE_ENV`
|
|
32
|
-
- `process.env.EXPO_OS` as `"web"`
|
|
33
|
-
|
|
34
|
-
## Examples
|
|
35
|
-
|
|
36
|
-
- [React + TypeScript + Vite + React Native Web Example](./apps/example)
|
|
37
|
-
- [React + TypeScript + Expo + Vite + React Native Web Example](./apps/expo-example)
|
|
38
|
-
|
|
39
|
-
## Contributing
|
|
40
|
-
|
|
41
|
-
Please feel free to contribute to this project. Just fork it and submit a PR.
|
|
42
|
-
|
|
43
|
-
## License
|
|
44
|
-
|
|
45
|
-
MIT
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
```
|