@@ -19,6 +19,8 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
19
19
const jsxRuntime = require . resolve ( 'react/jsx-runtime.js' )
20
20
const jsxDevRuntime = require . resolve ( 'react/jsx-dev-runtime.js' )
21
21
const rnw = require . resolve ( 'react-native-web' )
22
+ const reanimated = require . resolve ( 'react-native-reanimated' )
23
+ console . log ( 'reanimated' , reanimated )
22
24
23
25
webpackConfig . resolve . alias = {
24
26
...( webpackConfig . resolve . alias || { } ) ,
@@ -27,6 +29,10 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
27
29
'react/jsx-dev-runtime.js' : jsxDevRuntime ,
28
30
'react/jsx-dev-runtime' : jsxDevRuntime ,
29
31
'react-native$' : rnw ,
32
+ 'react-native-reanimated' : reanimated ,
33
+ '@gorhom/bottom-sheet$' : require
34
+ . resolve ( '@gorhom/bottom-sheet' )
35
+ . replace ( 'commonjs' , 'module' ) ,
30
36
'react-native-web/src/modules/normalizeColor' : require . resolve (
31
37
'react-native-web/dist/cjs/modules/normalizeColor'
32
38
) ,
@@ -37,6 +43,7 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
37
43
webpackConfig . plugins . push (
38
44
new webpack . DefinePlugin ( {
39
45
'process.env.TAMAGUI_TARGET' : '"web"' ,
46
+ __DEV__ : JSON . stringify ( dev ) ,
40
47
} )
41
48
)
42
49
@@ -73,6 +80,9 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
73
80
if ( / ^ \@ ? r e a c t - n a t i v e - / . test ( request ) ) {
74
81
return false
75
82
}
83
+ if ( fullPath === '@gorhom/bottom-sheet' ) {
84
+ return 'inline'
85
+ }
76
86
if (
77
87
fullPath . startsWith ( 'react-native-web' ) ||
78
88
fullPath . includes ( 'node_modules/react-native-web' )
@@ -96,6 +106,9 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
96
106
if ( isWebpack5 ) {
97
107
return ( ctx , cb ) => {
98
108
const res = includeModule ( ctx . context , ctx . request )
109
+ if ( res === 'inline' ) {
110
+ return cb ( )
111
+ }
99
112
if ( typeof res === 'string' ) {
100
113
return cb ( null , res )
101
114
}
@@ -164,7 +177,10 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
164
177
}
165
178
166
179
// add loader
167
- const shouldExclude = ( x ) => {
180
+ const shouldExclude = ( x : string ) => {
181
+ if ( x . includes ( 'react-native-reanimated' ) ) {
182
+ return false
183
+ }
168
184
// analyze everything in our jsx dir
169
185
// analyze everything in the components dirs
170
186
const shouldInclude =
@@ -179,21 +195,48 @@ export const withTamagui = (tamaguiOptions: TamaguiOptions) => {
179
195
}
180
196
181
197
if ( isNext12 ) {
182
- const oneOfJSRules = webpackConfig . module . rules [ 2 ] . oneOf
198
+ const oneOfJSRules : any [ ] = webpackConfig . module . rules [ 2 ] . oneOf
183
199
const swcLoaderIndex = 3
184
200
const swcLoader = oneOfJSRules [ swcLoaderIndex ]
185
201
// put an earlier loader where we just do tamagui stuff before regular swc
186
- oneOfJSRules . splice ( swcLoaderIndex , 0 , {
187
- test : / \. ( j s x ? | t s x ? ) $ / ,
188
- exclude : shouldExclude ,
189
- use : [
190
- ...[ ] . concat ( swcLoader . use ) ,
191
- {
192
- loader : 'tamagui-loader' ,
193
- options : tamaguiOptions ,
194
- } ,
195
- ] ,
196
- } )
202
+ oneOfJSRules . splice (
203
+ swcLoaderIndex ,
204
+ 0 ,
205
+ {
206
+ // test: /\.(jsx?|tsx?)$/,
207
+ test : / ( b o t t o m - s h e e t ) .* \. [ t j ] s x ? $ / ,
208
+ use : [
209
+ // ...[].concat(swcLoader.use),
210
+ {
211
+ loader : 'babel-loader' ,
212
+ options : {
213
+ plugins : [
214
+ 'react-native-reanimated/plugin' ,
215
+ // '@babel/plugin-transform-react-jsx',
216
+ ] ,
217
+ } ,
218
+ } ,
219
+ {
220
+ loader : 'esbuild-loader' ,
221
+ options : {
222
+ target : 'esnext' ,
223
+ loader : 'jsx' ,
224
+ } ,
225
+ } ,
226
+ ] ,
227
+ } ,
228
+ {
229
+ test : / \. ( j s x ? | t s x ? ) $ / ,
230
+ exclude : shouldExclude ,
231
+ use : [
232
+ ...[ ] . concat ( swcLoader . use ) ,
233
+ {
234
+ loader : 'tamagui-loader' ,
235
+ options : tamaguiOptions ,
236
+ } ,
237
+ ] ,
238
+ }
239
+ )
197
240
} else {
198
241
// next 11 modify loader
199
242
const [ first , second , ...rest ] = webpackConfig . module . rules
0 commit comments