Skip to content

Commit 497276c

Browse files
committed
stuff
1 parent 4e524c9 commit 497276c

File tree

29 files changed

+5468
-1870
lines changed

29 files changed

+5468
-1870
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@vitejs/vite-plugin-react-monorepo",
2+
"name": "@dhw/vite-plugin-react-native-web-monorepo",
33
"private": true,
44
"type": "module",
55
"engines": {
File renamed without changes.
File renamed without changes.
File renamed without changes.

packages/plugin-react/package.json renamed to packages/plugin-react-native-web/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
2-
"name": "@vitejs/plugin-react",
2+
"name": "@dhw/plugin-react-native-web",
33
"version": "4.3.4",
44
"license": "MIT",
5-
"author": "Evan You",
5+
"author": "Daniel Williams",
66
"contributors": [
7-
"Alec Larson",
8-
"Arnaud Barré"
7+
"Daniel Williams"
98
],
109
"files": [
1110
"dist"
@@ -44,6 +43,7 @@
4443
"babel-plugin-react-native-web": "^0.19.13",
4544
"@babel/plugin-transform-flow-strip-types": "^7.25.9",
4645
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
46+
"@babel/plugin-syntax-export-default-from": "^7.25.9",
4747
"@types/babel__core": "^7.20.5",
4848
"react-refresh": "^0.14.2"
4949
},

packages/plugin-react/src/fast-refresh.ts renamed to packages/plugin-react-native-web/src/fast-refresh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ let prevRefreshSig;
4040
if (import.meta.hot && !inWebWorker) {
4141
if (!window.__vite_plugin_react_preamble_installed__) {
4242
throw new Error(
43-
"@vitejs/plugin-react can't detect preamble. Something is wrong. " +
43+
"@dhw/plugin-react-native-web can't detect preamble. Something is wrong. " +
4444
"See https://github.com/vitejs/vite-plugin-react/pull/11#discussion_r430879201"
4545
);
4646
}

packages/plugin-react/src/index.ts renamed to packages/plugin-react-native-web/src/index.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ type ReactBabelHookContext = { ssr: boolean; id: string }
8282

8383
export type ViteReactPluginApi = {
8484
/**
85-
* Manipulate the Babel options of `@vitejs/plugin-react`
85+
* Manipulate the Babel options of `@dhw/plugin-react-native-web`
8686
*/
8787
reactBabel?: ReactBabelHook
8888
}
@@ -146,6 +146,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
146146
'process.env.NODE_ENV': JSON.stringify(
147147
process.env.NODE_ENV || env.mode,
148148
),
149+
__reanimatedLoggerConfig: `{}`,
149150
},
150151
optimizeDeps: {
151152
esbuildOptions: {
@@ -166,18 +167,18 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
166167

167168
if (opts.jsxRuntime === 'classic') {
168169
return {
170+
...commonOptions,
169171
esbuild: {
170172
jsx: 'transform',
171173
},
172-
...commonOptions,
173174
} satisfies ViteOptions
174175
} else {
175176
return {
177+
...commonOptions,
176178
esbuild: {
177179
jsx: 'automatic',
178180
jsxImportSource: opts.jsxImportSource,
179181
},
180-
...commonOptions,
181182
optimizeDeps: {
182183
...commonOptions.optimizeDeps,
183184
esbuildOptions: {
@@ -199,7 +200,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
199200

200201
if ('jsxPure' in opts) {
201202
config.logger.warnOnce(
202-
'[@vitejs/plugin-react] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.',
203+
'[@dhw/plugin-react-native-web] jsxPure was removed. You can configure esbuild.jsxSideEffects directly.',
203204
)
204205
}
205206

@@ -234,9 +235,20 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
234235
return newBabelOptions
235236
})()
236237
const plugins = [
237-
loadPlugin('babel-plugin-react-native-web'),
238-
loadPlugin('@babel/plugin-transform-flow-strip-types'),
239-
loadPlugin('@babel/plugin-transform-modules-commonjs'),
238+
await loadPlugin('babel-plugin-react-native-web'),
239+
await loadPlugin('@babel/plugin-transform-flow-strip-types'),
240+
await loadPlugin('@babel/plugin-syntax-export-default-from'),
241+
// [
242+
// // this is a fix for reanimated not working in production
243+
// '@babel/plugin-transform-modules-commonjs',
244+
// {
245+
// strict: false,
246+
// strictMode: false, // prevent "use strict" injections
247+
// allowTopLevelThis: true, // dont rewrite global `this` -> `undefined`
248+
// },
249+
// ],
250+
251+
// await loadPlugin('@babel/plugin-transform-modules-commonjs'),
240252
...babelOptions.plugins,
241253
]
242254

@@ -336,7 +348,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
336348
jsxImportRuntime,
337349
]
338350
const staticBabelPlugins =
339-
typeof opts.babel === 'object' ? opts.babel?.plugins ?? [] : []
351+
typeof opts.babel === 'object' ? (opts.babel?.plugins ?? []) : []
340352
const reactCompilerPlugin = getReactCompilerPlugin(staticBabelPlugins)
341353
if (reactCompilerPlugin != null) {
342354
const reactCompilerRuntimeModule =
@@ -353,7 +365,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
353365
include: dependencies,
354366
},
355367
resolve: {
356-
dedupe: ['react', 'react-dom'],
368+
dedupe: ['react', 'react-dom', 'react-native', 'react-native-web'],
357369
},
358370
}),
359371
resolveId(id) {

0 commit comments

Comments
 (0)