vite-plugin-rnw 0.0.3 → 0.0.5

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,8 @@
1
1
  # vite-plugin-rnw
2
2
 
3
- A vite plugin for React Native Web projects. (edited from a version of the react plugin)
3
+ A vite plugin for React Native Web projects.
4
+
5
+ This plugin is based on the [react plugin](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md)
4
6
 
5
7
  - enable [Fast Refresh](https://www.npmjs.com/package/react-refresh) in development (requires react >= 16.9)
6
8
  - use the [automatic JSX runtime](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)
@@ -32,8 +34,15 @@ export default defineConfig({
32
34
  });
33
35
  ```
34
36
 
35
- > `node_modules` can be processed by this plugin when needed
36
- > the excludes default is `/\/node_modules\/(?!react-native|@react-native|expo|@expo)/;`
37
+ `node_modules` can be processed by this plugin when needed
38
+
39
+ By default the excludes pattern is:
40
+
41
+ ```js
42
+ /\/node_modules\/(?!react-native|@react-native|expo|@expo)/;
43
+ ```
44
+
45
+ This means any package that starts with react-native, @react-native, expo, or @expo will be included and other node_modules will be excluded. But you can change this to include or exclude any package you want.
37
46
 
38
47
  ### jsxImportSource
39
48
 
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ const node_path = __toESM(require("node:path"));
25
25
  const node_url = __toESM(require("node:url"));
26
26
  const node_fs = __toESM(require("node:fs"));
27
27
  const vite = __toESM(require("vite"));
28
+ const __bunchtogether_vite_plugin_flow = __toESM(require("@bunchtogether/vite-plugin-flow"));
28
29
  const vite_plugin_commonjs = __toESM(require("vite-plugin-commonjs"));
29
30
  const __rolldown_pluginutils = __toESM(require("@rolldown/pluginutils"));
30
31
 
@@ -186,13 +187,23 @@ function rnw(opts = {}) {
186
187
  },
187
188
  optimizeDeps: {
188
189
  ...initialOptions.optimizeDeps,
189
- include: ["react-native-reanimated"],
190
+ include: ["react-native-reanimated", "react-native-css-interop"],
190
191
  esbuildOptions: {
191
192
  ...(_initialOptions$optim = initialOptions.optimizeDeps) === null || _initialOptions$optim === void 0 ? void 0 : _initialOptions$optim.esbuildOptions,
192
193
  resolveExtensions: extensions,
193
- loader: { ".js": "jsx" }
194
+ loader: { ".js": "jsx" },
195
+ plugins: [(0, __bunchtogether_vite_plugin_flow.esbuildFlowPlugin)(/* @__PURE__ */ new RegExp(/\.(flow|jsx?)$/), (_path) => "jsx")]
194
196
  }
195
197
  },
198
+ build: { rollupOptions: {
199
+ treeshake: "safest",
200
+ plugins: [{
201
+ name: "nativewind-fix",
202
+ async transform(code, id) {
203
+ if (id.includes("react-native-css-interop") && id.includes("runtime/components.js")) return { moduleSideEffects: "no-treeshake" };
204
+ }
205
+ }]
206
+ } },
196
207
  resolve: {
197
208
  extensions,
198
209
  alias: { "react-native": "react-native-web" }
@@ -334,6 +345,7 @@ function rnw(opts = {}) {
334
345
  }
335
346
  };
336
347
  return [
348
+ (0, __bunchtogether_vite_plugin_flow.flowPlugin)({ exclude }),
337
349
  {
338
350
  name: "treat-js-files-as-jsx",
339
351
  async transform(code, id) {
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
3
3
  import { readFileSync } from "node:fs";
4
4
  import * as vite from "vite";
5
5
  import { createFilter } from "vite";
6
+ import { esbuildFlowPlugin, flowPlugin } from "@bunchtogether/vite-plugin-flow";
6
7
  import commonjs from "vite-plugin-commonjs";
7
8
  import { exactRegex, makeIdFiltersToMatchWithQuery } from "@rolldown/pluginutils";
8
9
 
@@ -164,13 +165,23 @@ function rnw(opts = {}) {
164
165
  },
165
166
  optimizeDeps: {
166
167
  ...initialOptions.optimizeDeps,
167
- include: ["react-native-reanimated"],
168
+ include: ["react-native-reanimated", "react-native-css-interop"],
168
169
  esbuildOptions: {
169
170
  ...(_initialOptions$optim = initialOptions.optimizeDeps) === null || _initialOptions$optim === void 0 ? void 0 : _initialOptions$optim.esbuildOptions,
170
171
  resolveExtensions: extensions,
171
- loader: { ".js": "jsx" }
172
+ loader: { ".js": "jsx" },
173
+ plugins: [esbuildFlowPlugin(/* @__PURE__ */ new RegExp(/\.(flow|jsx?)$/), (_path) => "jsx")]
172
174
  }
173
175
  },
176
+ build: { rollupOptions: {
177
+ treeshake: "safest",
178
+ plugins: [{
179
+ name: "nativewind-fix",
180
+ async transform(code, id) {
181
+ if (id.includes("react-native-css-interop") && id.includes("runtime/components.js")) return { moduleSideEffects: "no-treeshake" };
182
+ }
183
+ }]
184
+ } },
174
185
  resolve: {
175
186
  extensions,
176
187
  alias: { "react-native": "react-native-web" }
@@ -312,6 +323,7 @@ function rnw(opts = {}) {
312
323
  }
313
324
  };
314
325
  return [
326
+ flowPlugin({ exclude }),
315
327
  {
316
328
  name: "treat-js-files-as-jsx",
317
329
  async transform(code, id) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.3",
2
+ "version": "0.0.5",
3
3
  "name": "vite-plugin-rnw",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
@@ -39,26 +39,28 @@
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^22",
42
- "tsdown": "^0.12.9",
43
- "vite": "^7.0.4",
44
42
  "babel-plugin-react-compiler": "19.1.0-rc.2",
45
43
  "react": "^19.1.0",
46
44
  "react-dom": "^19.1.0",
47
- "rolldown": "1.0.0-beta.24"
45
+ "rolldown": "1.0.0-beta.24",
46
+ "tsdown": "^0.12.9",
47
+ "vite": "^7.0.4"
48
48
  },
49
49
  "peerDependencies": {
50
+ "react-native-web": "*",
50
51
  "typescript": "^5",
51
- "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
52
- "react-native-web": "*"
52
+ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
53
53
  },
54
54
  "dependencies": {
55
- "vite-plugin-commonjs": "^0.10.4",
56
- "@babel/plugin-transform-modules-commonjs": "^7.27.1",
57
55
  "@babel/core": "^7.28.0",
56
+ "@babel/plugin-transform-flow-strip-types": "^7.27.1",
57
+ "@babel/plugin-transform-modules-commonjs": "^7.27.1",
58
58
  "@babel/plugin-transform-react-jsx-self": "^7.27.1",
59
59
  "@babel/plugin-transform-react-jsx-source": "^7.27.1",
60
+ "@bunchtogether/vite-plugin-flow": "^1.0.2",
60
61
  "@rolldown/pluginutils": "1.0.0-beta.24",
61
62
  "@types/babel__core": "^7.20.5",
62
- "react-refresh": "^0.17.0"
63
+ "react-refresh": "^0.17.0",
64
+ "vite-plugin-commonjs": "^0.10.4"
63
65
  }
64
66
  }