Skip to content

Monorepo docs issue #67

@jljorgenson18

Description

@jljorgenson18

So I just went to hell and back due to a pattern in the v5 docs here.

https://www.nativewind.dev/v5/guides/using-with-monorepos#modify-your-metroconfigjs

const { withNativeWind } = require("nativewind/metro");
 
// ... existing Nx configuration
 
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
  // ... existing Nx config
}).then((config) => withNativeWind(config));

Basically I was creating an anonymous async function that would call itself and resolve to a config object before. After upgrading, it was like parts of my metro config were being ignored.

I spent a day digging and finally found that metro-config does not actually support promise returns anymore

https://github.com/facebook/metro/blob/main/packages/metro-config/src/loadConfig.js#L240

This did work fine a few versions ago, but exporting a promise now seems to cause an issue where loadConfig internally will skip over the Promise since you end up passing a promise into mergeConfig

 return mergeConfig(defaultConfig, configModule);

I was able to find the issue for it here facebook/metro#1585

Because of that, I think the safer answer for documentation would be to export a function by itself and not export a promise directly.

Example:

module.exports = async () => {
 let config = await withNxMetro(mergeConfig(defaultConfig, customConfig), {
     // ... existing Nx config
 });
 config = withNativeWind(config);
 return config;
}

Metro-config doesn't throw any obvious errors for this as well so it's extra insidious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions