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

fix: support browser filed false value #395

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

underfin
Copy link
Contributor

@underfin underfin commented Dec 13, 2023

Description

You can simply prevent a module or file from being loaded into a bundle by specifying a value of false for any of the keys. This is useful if you know certain codepaths will not be executed client side but find it awkward to split up or change the code structure.

"browser": {
    "module-a": false,
    "./server/only.js": "./shims/server-only.js"
}

The above will cause the following to return an empty object into a.

var a = require('module-a');

ref https://github.com/defunctzombie/package-browser-field-spec?tab=readme-ov-file#ignore-a-module

Test Plan

Added.


@underfin
Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@hyf0 hyf0 added the on hold label Jan 5, 2024
@underfin underfin force-pushed the main branch 12 times, most recently from 2462fe6 to a00c94c Compare January 17, 2024 06:33
@hyf0
Copy link
Member

hyf0 commented Jan 22, 2024

Allow me to get more time to figure out what xxx: false is and how other bundlers handle it.

@Boshen
Copy link
Member

Boshen commented Jan 23, 2024

Allow me to get more time to figure out what xxx: false is and how other bundlers handle it.

https://github.com/microsoft/TypeScript/blob/2e3b8af85e1f782634349139819151881369e3ea/package.json#L100-L110

It tells the bundler to ignore resolving these node modules.

@hyf0 hyf0 force-pushed the 12-13-fix_support_browser_filed_false_value branch from 6d09b60 to 1288279 Compare January 24, 2024 09:56
@hyf0 hyf0 merged commit c3a82a4 into main Jan 24, 2024
7 checks passed
@hyf0 hyf0 deleted the 12-13-fix_support_browser_filed_false_value branch January 24, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants