Skip to content

Instantly share code, notes, and snippets.

@defunctzombie
Last active July 15, 2024 04:13
Show Gist options
  • Save defunctzombie/4339901 to your computer and use it in GitHub Desktop.
Save defunctzombie/4339901 to your computer and use it in GitHub Desktop.
browser field spec for package.json
@basedwon
Copy link

basedwon commented May 7, 2022

My files are isomorphic, meaning they work on both browser and in Node, I'd call that "universal". The issue is that Webpack (4) doesn't care, and so I have to compensate by listing every file in the browser field. I have one file that is used on Node only and the exports field handles that just fine.

The efficient thing would be to allow for the browser field to behave like the exports field. But less efficient for me to use my time trying to get that changed than just to deal with it. But as my libs grow, so too must the exports field. Tracking each import in the config is redundant and therefore inefficient. Hopefully Browserify/Webpack will address this. But I won't be holding my breath.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment