vite-plugin-react-native-web 2.4.1 → 2.5.0
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 +15 -3
- package/dist/cjs/index.js +18 -2
- package/dist/es/index.js +18 -2
- package/package.json +2 -2
- package/types/index.d.ts +3 -2
package/README.md
CHANGED
|
@@ -18,21 +18,33 @@ npm i vite-plugin-react-native-web -D
|
|
|
18
18
|
import reactNativeWeb from "vite-plugin-react-native-web";
|
|
19
19
|
|
|
20
20
|
export default defineConfig({
|
|
21
|
-
plugins: [
|
|
22
|
-
reactNativeWeb()
|
|
23
|
-
]
|
|
21
|
+
plugins: [reactNativeWeb({ ... })],
|
|
24
22
|
});
|
|
25
23
|
```
|
|
26
24
|
|
|
25
|
+
## Options
|
|
26
|
+
|
|
27
|
+
The plugin accepts an options object with the following optional properties:
|
|
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.
|
|
30
|
+
|
|
27
31
|
If you are getting errors please report them in the issues section.
|
|
28
32
|
|
|
29
33
|
The following variables are defined in the transformed files: (inferred during Vite's build process)
|
|
34
|
+
|
|
30
35
|
- `global` as `self`
|
|
31
36
|
- `__DEV__` as `process.env.NODE_ENV === 'development'`
|
|
32
37
|
- `process.env.NODE_ENV` as `process.env.NODE_ENV`
|
|
38
|
+
- `process.env.EXPO_OS` as `"web"`
|
|
33
39
|
|
|
34
40
|
## Contributing
|
|
41
|
+
|
|
35
42
|
Please feel free to contribute to this project. Just fork it and submit a PR.
|
|
36
43
|
|
|
37
44
|
## License
|
|
45
|
+
|
|
38
46
|
MIT
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var fs = require('node:fs/promises');
|
|
|
6
6
|
var flowRemoveTypes = require('flow-remove-types');
|
|
7
7
|
var vite = require('vite');
|
|
8
8
|
|
|
9
|
-
// import type { ViteReactNativeWebOptions } from '../types'
|
|
10
9
|
const development = process.env.NODE_ENV === 'development';
|
|
11
10
|
const extensions = [
|
|
12
11
|
// ⚠️ This currently does not work as expected (https://github.com/evanw/esbuild/issues/4053)
|
|
@@ -61,7 +60,7 @@ const esbuildPlugin = () => ({
|
|
|
61
60
|
});
|
|
62
61
|
},
|
|
63
62
|
});
|
|
64
|
-
const reactNativeWeb = (
|
|
63
|
+
const reactNativeWeb = (options) => ({
|
|
65
64
|
enforce: 'pre',
|
|
66
65
|
name: 'react-native-web',
|
|
67
66
|
config: () => ({
|
|
@@ -76,6 +75,23 @@ const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
|
|
|
76
75
|
extensions,
|
|
77
76
|
transformMixedEsModules: true,
|
|
78
77
|
},
|
|
78
|
+
rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk) !== false
|
|
79
|
+
? {
|
|
80
|
+
output: {
|
|
81
|
+
manualChunks(id) {
|
|
82
|
+
if (id.includes('expo-modules-core')) {
|
|
83
|
+
return 'expo-modules-core';
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
entryFileNames: (chunk) => {
|
|
87
|
+
if (chunk.name === 'expo-modules-core') {
|
|
88
|
+
return '0-expo-modules-core.js';
|
|
89
|
+
}
|
|
90
|
+
return '[name].js';
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
: undefined,
|
|
79
95
|
},
|
|
80
96
|
resolve: {
|
|
81
97
|
extensions,
|
package/dist/es/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import flowRemoveTypes from 'flow-remove-types';
|
|
3
3
|
import { transformWithEsbuild } from 'vite';
|
|
4
4
|
|
|
5
|
-
// import type { ViteReactNativeWebOptions } from '../types'
|
|
6
5
|
const development = process.env.NODE_ENV === 'development';
|
|
7
6
|
const extensions = [
|
|
8
7
|
// ⚠️ This currently does not work as expected (https://github.com/evanw/esbuild/issues/4053)
|
|
@@ -57,7 +56,7 @@ const esbuildPlugin = () => ({
|
|
|
57
56
|
});
|
|
58
57
|
},
|
|
59
58
|
});
|
|
60
|
-
const reactNativeWeb = (
|
|
59
|
+
const reactNativeWeb = (options) => ({
|
|
61
60
|
enforce: 'pre',
|
|
62
61
|
name: 'react-native-web',
|
|
63
62
|
config: () => ({
|
|
@@ -72,6 +71,23 @@ const reactNativeWeb = ( /*options: ViteReactNativeWebOptions = {}*/) => ({
|
|
|
72
71
|
extensions,
|
|
73
72
|
transformMixedEsModules: true,
|
|
74
73
|
},
|
|
74
|
+
rollupOptions: (options === null || options === void 0 ? void 0 : options.enableExpoManualChunk) !== false
|
|
75
|
+
? {
|
|
76
|
+
output: {
|
|
77
|
+
manualChunks(id) {
|
|
78
|
+
if (id.includes('expo-modules-core')) {
|
|
79
|
+
return 'expo-modules-core';
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
entryFileNames: (chunk) => {
|
|
83
|
+
if (chunk.name === 'expo-modules-core') {
|
|
84
|
+
return '0-expo-modules-core.js';
|
|
85
|
+
}
|
|
86
|
+
return '[name].js';
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
: undefined,
|
|
75
91
|
},
|
|
76
92
|
resolve: {
|
|
77
93
|
extensions,
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Plugin as VitePlugin } from 'vite'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export type ViteReactNativeWebOptions = {
|
|
4
|
+
enableExpoManualChunk?: boolean
|
|
5
|
+
}
|
|
5
6
|
|
|
6
7
|
export default function reactNativeWeb(options?: ViteReactNativeWebOptions): VitePlugin
|