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

browser = false resolves to @empty, fails import #325

Closed
AutoSponge opened this issue Jan 21, 2015 · 7 comments
Closed

browser = false resolves to @empty, fails import #325

AutoSponge opened this issue Jan 21, 2015 · 7 comments

Comments

@AutoSponge
Copy link

Documented example: readable-stream

When package.json sets browser: false the dependency maps to @empty module. This fails on load with an unknown module error. Can this instead fail silently? Or should we add @empty to our map?

@guybedford
Copy link
Member

@AutoSponge thanks for reporting.

Can you clarify - are you loading in Node or the browser here?

Is this jspm install stream that you are referring to or something else?

Is the browser field false or { util: false }? The @empty replacement is designed to optimize for the browser use case handling following Browserify rules.

@AutoSponge
Copy link
Author

@guybedford, I'm loading in the browser. The uncompiled version works fine but when building to a self-executing package, the reference to util is lost. According to the stream team, the choice to exclude util from the package.json was intentional ({util: false}).

@guybedford
Copy link
Member

@AutoSponge perhaps the issue here is that SFX bundles don't support @empty?

Try adding System.register('@empty', [], false, function() {}) at the appropriate place in the sfx bundle and see if that helps?

@guybedford
Copy link
Member

@AutoSponge see systemjs/builder#49 and the associated commit and let me know if that helps.

@AutoSponge
Copy link
Author

@guybedford, manually adding the @empty registration also works. I also fixed the issue by adding an empty.js file to my project and adding "@empty": "app/empty", to my config.js map. IMO, if that statement could be injected automatically in SFX bundles, it could better support production builds.

@guybedford
Copy link
Member

Thanks for confirming! I've added systemjs/builder@79efa57.

@guybedford
Copy link
Member

Resolved in builder.

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

No branches or pull requests

2 participants