Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support exports.*.browser #976

Open
ai opened this issue Feb 22, 2025 · 3 comments
Open

Support exports.*.browser #976

ai opened this issue Feb 22, 2025 · 3 comments

Comments

@ai
Copy link

ai commented Feb 22, 2025

We still have a difference between Node.js and browser environment.

For instance, in Nano ID we need to use special Node.js API. Also Node.js and browser versions have different optimization strategies—one is for size, other is for performance.

So we need support for exports like:

{
  "name": "@sitnik/nanoid",
  "version": "5.1.0",
  "license": "MIT",
  "exports": {
    ".": {
      "browser": "./index.browser.js",
      "default": "./index.js"
    }
  }
}
@github-project-automation github-project-automation bot moved this to Needs Triage in JSR Feb 22, 2025
@BlackAsLight
Copy link

On a side question: why would you write code for size at the penalty of performance? Is the small difference in size worth the hit to performance?

@ai
Copy link
Author

ai commented Feb 24, 2025

why would you write code for size at the penalty of performance?

Because loading performance affect overall performance more in browser (when people load website multiple times per day just for few minutes) than Node.js (when we have a server running whole day, so we need to load it once).

Is the small difference in size worth the hit to performance?

Loading time difference is similar to performance losses. So it is like one to one exchange.

@realhydroper
Copy link

Related: #964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Triage
Development

No branches or pull requests

3 participants