vite-plugin-react-native-web 3.0.1 → 3.1.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 ADDED
@@ -0,0 +1,43 @@
1
+ # vite-plugin-react-native-web
2
+
3
+ React Native Web support for Vite.
4
+
5
+ ## Peer Dependencies
6
+
7
+ This plugin requires `react-native-web` and `inline-style-prefixer` as peer dependencies. **You must install them in the `node_modules` directory of the app where you use this plugin.**
8
+
9
+ > **Note:** If you are using pnpm or a workspace setup, peer dependencies may be installed in nested `node_modules` folders by default. To avoid issues, ensure both `react-native-web` and `inline-style-prefixer` are installed in the app's own `node_modules` directory:
10
+
11
+ ```sh
12
+ pnpm add react-native-web inline-style-prefixer
13
+ ```
14
+
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
+ ```
40
+
41
+ ## License
42
+
43
+ MIT
package/dist/cjs/index.js CHANGED
@@ -81,7 +81,23 @@ const treeshakePreset = {
81
81
  unknownGlobalSideEffects: true,
82
82
  propertyWriteSideEffects: "always"
83
83
  };
84
- const optimizeDepsInclude = ["react-native-web"];
84
+ const optimizeDepsInclude = [
85
+ "react-native-web",
86
+ "inline-style-prefixer/lib/createPrefixer",
87
+ "inline-style-prefixer/lib/plugins/crossFade",
88
+ "inline-style-prefixer/lib/plugins/imageSet",
89
+ "inline-style-prefixer/lib/plugins/logical",
90
+ "inline-style-prefixer/lib/plugins/position",
91
+ "inline-style-prefixer/lib/plugins/sizing",
92
+ "inline-style-prefixer/lib/plugins/transition"
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
+ }];
85
101
  const reactNativeWeb = (_options) => ({
86
102
  enforce: "pre",
87
103
  name: "react-native-web",
@@ -104,7 +120,14 @@ const reactNativeWeb = (_options) => ({
104
120
  shimMissingExports: true,
105
121
  treeshake: treeshakePreset,
106
122
  moduleTypes,
107
- 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
+ }
108
131
  } },
109
132
  optimizeDeps: {
110
133
  include: optimizeDepsInclude,
package/dist/es/index.js CHANGED
@@ -54,7 +54,23 @@ const treeshakePreset = {
54
54
  unknownGlobalSideEffects: true,
55
55
  propertyWriteSideEffects: "always"
56
56
  };
57
- const optimizeDepsInclude = ["react-native-web"];
57
+ const optimizeDepsInclude = [
58
+ "react-native-web",
59
+ "inline-style-prefixer/lib/createPrefixer",
60
+ "inline-style-prefixer/lib/plugins/crossFade",
61
+ "inline-style-prefixer/lib/plugins/imageSet",
62
+ "inline-style-prefixer/lib/plugins/logical",
63
+ "inline-style-prefixer/lib/plugins/position",
64
+ "inline-style-prefixer/lib/plugins/sizing",
65
+ "inline-style-prefixer/lib/plugins/transition"
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
+ }];
58
74
  const reactNativeWeb = (_options) => ({
59
75
  enforce: "pre",
60
76
  name: "react-native-web",
@@ -77,7 +93,14 @@ const reactNativeWeb = (_options) => ({
77
93
  shimMissingExports: true,
78
94
  treeshake: treeshakePreset,
79
95
  moduleTypes,
80
- 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
+ }
81
104
  } },
82
105
  optimizeDeps: {
83
106
  include: optimizeDepsInclude,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-native-web",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,6 +20,7 @@
20
20
  "import": "./dist/es/index.js",
21
21
  "default": "./dist/cjs/index.js"
22
22
  },
23
+ "types": "./types/index.d.ts",
23
24
  "engines": {
24
25
  "node": ">=14.0.0"
25
26
  },
@@ -44,6 +45,10 @@
44
45
  "dependencies": {
45
46
  "flow-remove-types": "^2.305.0"
46
47
  },
48
+ "peerDependencies": {
49
+ "inline-style-prefixer": "*",
50
+ "react-native-web": "*"
51
+ },
47
52
  "devDependencies": {
48
53
  "@rollup/plugin-typescript": "^12.3.0",
49
54
  "@types/node": "^25.5.0",
@@ -51,6 +56,5 @@
51
56
  "tslib": "^2.8.1",
52
57
  "typescript": "^5.9.3",
53
58
  "vite": "^8.0.0"
54
- },
55
- "types": "./types/index.d.ts"
59
+ }
56
60
  }