vite-plugin-react-native-web 2.6.0 → 2.7.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 CHANGED
@@ -26,7 +26,7 @@ export default defineConfig({
26
26
 
27
27
  The plugin accepts an options object with the following optional properties:
28
28
 
29
- - `enableExpoManualChunk` (boolean): When set to true, this option enables manual chunking for expo-modules-core modules to optimize bundle size and loading performance. Default is true.
29
+ - `enableExpoManualChunk` (boolean): When set to true, this option enables manual chunking for expo-modules-core modules to optimize bundle size and loading performance. Default is false. Be cautious when enabling this option, since it overrides user-defined manual chunks in the Vite configuration.
30
30
 
31
31
  If you are getting errors please report them in the issues section.
32
32
 
package/dist/cjs/index.js CHANGED
@@ -8,42 +8,23 @@ var vite = require('vite');
8
8
 
9
9
  const development = process.env.NODE_ENV === 'development';
10
10
  const extensions = [
11
- // ⚠️ This currently does not work as expected (https://github.com/evanw/esbuild/issues/4053)
12
- // '.web.mjs',
13
- // '.mjs',
14
- // '.web.js',
15
- // '.js',
16
- // '.web.mts',
17
- // '.mts',
18
- // '.web.ts',
19
- // '.ts',
20
- // '.web.jsx',
21
- // '.jsx',
22
- // '.web.tsx',
23
- // '.tsx',
24
- // '.json',
25
- // ⚠️ Temporary fix
26
11
  '.web.mjs',
27
- '.web.js',
28
- '.web.mts',
29
- '.web.ts',
30
- '.web.jsx',
31
- '.web.tsx',
32
12
  '.mjs',
13
+ '.web.js',
33
14
  '.js',
15
+ '.web.mts',
34
16
  '.mts',
17
+ '.web.ts',
35
18
  '.ts',
19
+ '.web.jsx',
36
20
  '.jsx',
21
+ '.web.tsx',
37
22
  '.tsx',
38
23
  '.json',
39
24
  ];
40
25
  const reactNativeFlowJsxPathPattern = /\.(js|flow)$/;
41
26
  const reactNativeFlowJsxLoader = 'jsx';
42
27
  const flowPragmaPattern = /@flow\b/;
43
- const useClientPragmaPattern = /['"]use client['"]/;
44
- const jsxElementPattern = /<([A-Za-z][A-Za-z0-9]*)\b[^>]*>([\s\S]*?)<\/\1>/;
45
- const jsxSelfClosingPattern = /<([A-Za-z][A-Za-z0-9]*)\b[^>]*\/?>/;
46
- const jsxFragmentPattern = /<>([\s\S]*?)<\/>/;
47
28
  const esbuildPlugin = () => ({
48
29
  name: 'react-native-web',
49
30
  setup: (build) => {
@@ -75,7 +56,7 @@ const reactNativeWeb = (options) => ({
75
56
  extensions,
76
57
  transformMixedEsModules: true,
77
58
  },
78
- rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk) !== false
59
+ rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk)
79
60
  ? {
80
61
  output: {
81
62
  manualChunks(id) {
@@ -110,31 +91,19 @@ const reactNativeWeb = (options) => ({
110
91
  return;
111
92
  }
112
93
  let map = null;
113
- if (flowPragmaPattern.test(code)) {
114
- const transformed = flowRemoveTypes(code);
115
- code = transformed.toString();
116
- map = {
117
- file: id,
118
- toUrl: () => id,
119
- ...transformed.generateMap(),
120
- };
121
- }
122
- if (jsxElementPattern.test(code) || jsxSelfClosingPattern.test(code) || jsxFragmentPattern.test(code)) {
123
- const result = await vite.transformWithEsbuild(code, id, {
124
- loader: reactNativeFlowJsxLoader,
125
- tsconfigRaw: {
126
- compilerOptions: {
127
- jsx: 'react-jsx',
128
- },
129
- },
130
- });
131
- code = result.code;
132
- map = result.map;
133
- // Do not include source maps for files that are using 'use client' pragma since these break the esbuild mappings (https://github.com/vitejs/vite/issues/15012)
134
- if (useClientPragmaPattern.test(code)) {
135
- map = null;
136
- }
137
- }
94
+ const transformed = flowRemoveTypes(code);
95
+ code = transformed.toString();
96
+ map = {
97
+ file: id,
98
+ toUrl: () => id,
99
+ ...transformed.generateMap(),
100
+ };
101
+ const result = await vite.transformWithEsbuild(code, id, {
102
+ loader: reactNativeFlowJsxLoader,
103
+ jsx: 'automatic',
104
+ });
105
+ code = result.code;
106
+ map = result.map;
138
107
  return { code, map };
139
108
  },
140
109
  });
package/dist/es/index.js CHANGED
@@ -4,42 +4,23 @@ import { transformWithEsbuild } from 'vite';
4
4
 
5
5
  const development = process.env.NODE_ENV === 'development';
6
6
  const extensions = [
7
- // ⚠️ This currently does not work as expected (https://github.com/evanw/esbuild/issues/4053)
8
- // '.web.mjs',
9
- // '.mjs',
10
- // '.web.js',
11
- // '.js',
12
- // '.web.mts',
13
- // '.mts',
14
- // '.web.ts',
15
- // '.ts',
16
- // '.web.jsx',
17
- // '.jsx',
18
- // '.web.tsx',
19
- // '.tsx',
20
- // '.json',
21
- // ⚠️ Temporary fix
22
7
  '.web.mjs',
23
- '.web.js',
24
- '.web.mts',
25
- '.web.ts',
26
- '.web.jsx',
27
- '.web.tsx',
28
8
  '.mjs',
9
+ '.web.js',
29
10
  '.js',
11
+ '.web.mts',
30
12
  '.mts',
13
+ '.web.ts',
31
14
  '.ts',
15
+ '.web.jsx',
32
16
  '.jsx',
17
+ '.web.tsx',
33
18
  '.tsx',
34
19
  '.json',
35
20
  ];
36
21
  const reactNativeFlowJsxPathPattern = /\.(js|flow)$/;
37
22
  const reactNativeFlowJsxLoader = 'jsx';
38
23
  const flowPragmaPattern = /@flow\b/;
39
- const useClientPragmaPattern = /['"]use client['"]/;
40
- const jsxElementPattern = /<([A-Za-z][A-Za-z0-9]*)\b[^>]*>([\s\S]*?)<\/\1>/;
41
- const jsxSelfClosingPattern = /<([A-Za-z][A-Za-z0-9]*)\b[^>]*\/?>/;
42
- const jsxFragmentPattern = /<>([\s\S]*?)<\/>/;
43
24
  const esbuildPlugin = () => ({
44
25
  name: 'react-native-web',
45
26
  setup: (build) => {
@@ -71,7 +52,7 @@ const reactNativeWeb = (options) => ({
71
52
  extensions,
72
53
  transformMixedEsModules: true,
73
54
  },
74
- rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk) !== false
55
+ rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk)
75
56
  ? {
76
57
  output: {
77
58
  manualChunks(id) {
@@ -106,31 +87,19 @@ const reactNativeWeb = (options) => ({
106
87
  return;
107
88
  }
108
89
  let map = null;
109
- if (flowPragmaPattern.test(code)) {
110
- const transformed = flowRemoveTypes(code);
111
- code = transformed.toString();
112
- map = {
113
- file: id,
114
- toUrl: () => id,
115
- ...transformed.generateMap(),
116
- };
117
- }
118
- if (jsxElementPattern.test(code) || jsxSelfClosingPattern.test(code) || jsxFragmentPattern.test(code)) {
119
- const result = await transformWithEsbuild(code, id, {
120
- loader: reactNativeFlowJsxLoader,
121
- tsconfigRaw: {
122
- compilerOptions: {
123
- jsx: 'react-jsx',
124
- },
125
- },
126
- });
127
- code = result.code;
128
- map = result.map;
129
- // Do not include source maps for files that are using 'use client' pragma since these break the esbuild mappings (https://github.com/vitejs/vite/issues/15012)
130
- if (useClientPragmaPattern.test(code)) {
131
- map = null;
132
- }
133
- }
90
+ const transformed = flowRemoveTypes(code);
91
+ code = transformed.toString();
92
+ map = {
93
+ file: id,
94
+ toUrl: () => id,
95
+ ...transformed.generateMap(),
96
+ };
97
+ const result = await transformWithEsbuild(code, id, {
98
+ loader: reactNativeFlowJsxLoader,
99
+ jsx: 'automatic',
100
+ });
101
+ code = result.code;
102
+ map = result.map;
134
103
  return { code, map };
135
104
  },
136
105
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-react-native-web",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +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
+ "lint": "biome check --write ./src ./types ./biome.json ./tsconfig.json ./rollup.config.mjs ./example/tsconfig.app.json ./example/tsconfig.node.json ./example/tsconfig.json ./example/vite.config.ts ./example/src",
28
28
  "prerelease": "npm run build",
29
29
  "release": "npm publish"
30
30
  },