Skip to content

Zod is no longer able to be correctly shared via module federation #4656

@brentswisher

Description

@brentswisher

Our organization uses Zod in several micro-frontends that share resources via module federation. After recently updating Zod to the latest version in one of the micro-frontends I'm seeing this warning being emitted in the browser:

WARNING in shared module zod -> <path to my project>/.yarn/cache/zod-npm-3.25.56-a6f60427c3-f2faf9f9bf.zip/node_modules/zod/dist/esm/index.js No version specified and unable to automatically determine one. No version in description file (usually package.json). Add version to description file <path to my project>/.yarn/cache/zod-npm-3.25.56-a6f60427c3-f2faf9f9bf.zip/node_modules/zod/dist/esm/package.json, or manually specify version in shared config.

It appears that Module Federation is looking for a version field in the package.json located at zod/dist/esm/package.json, but that file only contains { "type": "module" }. As a result, the version can't be determined for sharing. It seems like this is maybe a side effect of the build changes for #4371.

I looked around at how the Zod packages are structured, and manually added a version field to that package.json locally, and the warning went away. I'm not sure if appending a version field during the build is the best long-term solution, but if that seems reasonable, I’d be happy to submit a PR to try and implement that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions