vite-plugin-react-native-web 3.1.0 → 3.1.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 CHANGED
@@ -1,6 +1,35 @@
1
1
  # vite-plugin-react-native-web
2
2
 
3
- React Native Web support for Vite.
3
+ [![npm](https://img.shields.io/npm/v/vite-plugin-react-native-web?style=flat-square)](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"`
4
33
 
5
34
  ## Peer Dependencies
6
35
 
@@ -12,31 +41,14 @@ This plugin requires `react-native-web` and `inline-style-prefixer` as peer depe
12
41
  pnpm add react-native-web inline-style-prefixer
13
42
  ```
14
43
 
15
- ## Why?
16
-
17
- - `react-native-web` provides the core React Native compatibility for web.
18
- - `inline-style-prefixer` is required for style prefixing and is used internally by `react-native-web`.
19
-
20
- ## Example Vite config
21
-
22
- To ensure correct dependency optimization, add the following to your Vite config:
23
-
24
- ```js
25
- optimizeDeps: {
26
- include: [
27
- 'inline-style-prefixer/lib/createPrefixer',
28
- 'inline-style-prefixer/lib/plugins/backgroundClip',
29
- 'inline-style-prefixer/lib/plugins/crossFade',
30
- 'inline-style-prefixer/lib/plugins/cursor',
31
- 'inline-style-prefixer/lib/plugins/filter',
32
- 'inline-style-prefixer/lib/plugins/imageSet',
33
- 'inline-style-prefixer/lib/plugins/logical',
34
- 'inline-style-prefixer/lib/plugins/position',
35
- 'inline-style-prefixer/lib/plugins/sizing',
36
- 'inline-style-prefixer/lib/plugins/transition'
37
- ]
38
- }
39
- ```
44
+ ## Examples
45
+
46
+ - [React + TypeScript + Vite + React Native Web Example](./apps/example)
47
+ - [React + TypeScript + Expo + Vite + React Native Web Example](./apps/expo-example)
48
+
49
+ ## Contributing
50
+
51
+ Please feel free to contribute to this project. Just fork it and submit a PR.
40
52
 
41
53
  ## License
42
54
 
package/dist/cjs/index.js CHANGED
@@ -91,6 +91,13 @@ const optimizeDepsInclude = [
91
91
  "inline-style-prefixer/lib/plugins/sizing",
92
92
  "inline-style-prefixer/lib/plugins/transition"
93
93
  ];
94
+ const silencedLogs = [{
95
+ code: "EVAL",
96
+ file: "expo/src/async-require/fetchThenEvalJs.ts"
97
+ }, {
98
+ code: "EVAL",
99
+ file: "expo-modules-core/src/uuid/index.web.ts"
100
+ }];
94
101
  const reactNativeWeb = (_options) => ({
95
102
  enforce: "pre",
96
103
  name: "react-native-web",
@@ -113,7 +120,14 @@ const reactNativeWeb = (_options) => ({
113
120
  shimMissingExports: true,
114
121
  treeshake: treeshakePreset,
115
122
  moduleTypes,
116
- plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
123
+ plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()],
124
+ onLog(level, log, defaultHandler) {
125
+ var _a;
126
+ const code = log.code;
127
+ const file = (_a = log.loc) === null || _a === void 0 ? void 0 : _a.file;
128
+ if (code && file && silencedLogs.some((silencedLog) => code === silencedLog.code && file.includes(silencedLog.file))) return;
129
+ defaultHandler(level, log);
130
+ }
117
131
  } },
118
132
  optimizeDeps: {
119
133
  include: optimizeDepsInclude,
package/dist/es/index.js CHANGED
@@ -64,6 +64,13 @@ const optimizeDepsInclude = [
64
64
  "inline-style-prefixer/lib/plugins/sizing",
65
65
  "inline-style-prefixer/lib/plugins/transition"
66
66
  ];
67
+ const silencedLogs = [{
68
+ code: "EVAL",
69
+ file: "expo/src/async-require/fetchThenEvalJs.ts"
70
+ }, {
71
+ code: "EVAL",
72
+ file: "expo-modules-core/src/uuid/index.web.ts"
73
+ }];
67
74
  const reactNativeWeb = (_options) => ({
68
75
  enforce: "pre",
69
76
  name: "react-native-web",
@@ -86,7 +93,14 @@ const reactNativeWeb = (_options) => ({
86
93
  shimMissingExports: true,
87
94
  treeshake: treeshakePreset,
88
95
  moduleTypes,
89
- plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()]
96
+ plugins: [flowRemoveTypesPlugin(), treeshakeFixPlugin()],
97
+ onLog(level, log, defaultHandler) {
98
+ var _a;
99
+ const code = log.code;
100
+ const file = (_a = log.loc) === null || _a === void 0 ? void 0 : _a.file;
101
+ if (code && file && silencedLogs.some((silencedLog) => code === silencedLog.code && file.includes(silencedLog.file))) return;
102
+ defaultHandler(level, log);
103
+ }
90
104
  } },
91
105
  optimizeDeps: {
92
106
  include: optimizeDepsInclude,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-native-web",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"