nativewind: v3: A never finished building
Describe the bug
building stuck on Done copying assets when i use withNativewind(config)
To Reproduce Steps to reproduce the behavior:
run on xcode
Screenshots
Additional context
const {getDefaultConfig} = require('metro-config')
const withNativewind = require('nativewind/metro')
module.exports = (async () => {
const {
resolver: {sourceExts, assetExts},
} = await getDefaultConfig()
const config = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
babelTransformerPath: require.resolve('react-native-svg-transformer'),
},
resolver: {
assetExts: assetExts.filter(ext => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg'],
},
}
// return withNativewind(config) // stuck ❌
return config // build success ✅
})()
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 26 (4 by maintainers)
This worked great, thank you! I hope this gets added to the library.
I got it to work in eas build. As pointed by @chenhb23 this issue is with node env variable. I have used patch-package to fix this line. Below are the steps
yarn add patch-package postinstall-postinstall"postinstall": "patch-package"Now eas build works
nativewind+3.0.0-next.34.patch
I have investigated this problem in more detail.
It seems like expo/metro somehow explicitely wait till a spawned process is finished. And if nativewind starts tailwind in watchmode this never happens. I also tried to start it delayed by wrapping it with a setTimeout. But metro seems to also wait for all timeouts being finished till continueing.
Furthermore I discovered that the “getTransformOptions” method is sometimes called multiple times, so even if metro would not block, this method seems not to be ideal to hook into.
In General neither metro nor expo seem to have any kind of hook or middleware concept that would work for nativewinds purpose.
I guess it would be the easiest to keep the non watch mode inside the “getTransformOptions” and extract the watch mode into a cli, that one can put into a script inside the package.json to run alongside the expo cli.
I’m just coming back from break so I’ll look into it soon. It could very well be the same issue, just getting stuck on a different output. It does seem like EAS/Metro has changed how they spawn children processes (as seen above with the different env).
This fixed my issues.
EAS Build was working fine with Nativewind v3 until I added
expo-updatesthen the builds started timing out. Now things work again with this patch.Thanks for the help with this!
Awesome, @anurag-alla, thanks for tracking this bug down.
Here is the code in question.
The problem is EAS uses the
NODE_ENVvariable to determine the build environment (staging, beta, production, etc). But nativewind@next is usingNODE_ENV!== ‘production’ to enable fast-refresh. SettingisDevelopmentto false, enables non-production EAS building, but disables fast-refresh in development.It cannot be assumed that EAS will only be used for production, but fast-refresh in development would be helpful.
A better solution, I think, is to check the
process.env.CIvariable and disable fast-refresh if run in CI. (EXPO EAS also sets the CI env variable for builds).I am seeing the same issue with Nativewind v3 and Expo EAS. Unfortunately, @allpwrfulroot’s suggestion did not work for me with
3.0.0-854ccd0.0. I am using a monorepo very similar to expo-monorepo-example with the following metro config:I can replicate this issue locally using with the
--localflag:Removing withNativewind from the metro.config.js builds successfully.