Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

fix: regression in browser objects pointing to nested node_mpodules #143

Merged

Conversation

keithamus
Copy link
Contributor

This fixes an issue mentioned by @paulsouche in this comment: #136 (comment)

@paulsouche would you be so kind as to test this with your build to ensure it still passes?

@keithamus
Copy link
Contributor Author

Very confused that these pass on my machine but not on CI.

@paulsouche
Copy link

Hi,

This fixes the issue with my build, but I have same issue locally with test as on CI. require is not defined

Can't wait for this !

Thank you

@bterlson
Copy link
Contributor

bterlson commented Feb 18, 2019

@guybedford @TrySound @lukastaegert @keithamus can I help land this soon?

With rollup-plugin-node-builtins throwing audit warnings, I'm trying to roll my own package replacements, and it's difficult to do without being able to alias to node-modules. This would also enable many more packages json with browser fields to "just work" with rollup. Let me know if I can be of help!

@lukastaegert
Copy link
Member

I can have a look tomorrow

@lukastaegert
Copy link
Member

Ok, so as I understand it: The issue was that even though the browser field correctly resolved to another node module, this module did not exist. Consequently the bundle contained a dangling require statement that could not be resolved by the test harness.

I fixed this by adding an appropriate module (my guess is that this existed locally but was not committed due to some global .gitignore or similar). I also updated the branch to latest master and update the dependencies. I also changed the tests to explicitly list all warnings that are expected to occur.

There is one thing that does not appear ideal to me but probably would require a change in rollup itself and this is how the case is handled where the node module that the browser field points to is missing. In this case, not the replaced import but the original import remains in the bundle. To improve this, however, Rollup would need a mechanism for plugins to identify an import as missing while changing the importee (Currently, you can just return false which does not change the id. If you return something that does not resolve to an existing file, Rollup will throw).

From my side, this is good to be released.

@lukastaegert lukastaegert force-pushed the fix-regression-in-browser-pointing-to-nested-modules branch from 704e3a2 to 0975836 Compare February 20, 2019 07:21
@lukastaegert lukastaegert force-pushed the fix-regression-in-browser-pointing-to-nested-modules branch from 0975836 to 3349a3a Compare February 22, 2019 06:49
@lukastaegert lukastaegert merged commit 1eff8d7 into master Feb 22, 2019
@lukastaegert lukastaegert deleted the fix-regression-in-browser-pointing-to-nested-modules branch February 22, 2019 06:56
@lukastaegert
Copy link
Member

Released

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

Successfully merging this pull request may close these issues.

None yet

4 participants