purs-loader icon indicating copy to clipboard operation
purs-loader copied to clipboard

Replace require statements in associated foreign modules

Open ethul opened this issue 6 years ago • 4 comments

See #111

Currently, the loader does not update require statements in associated foreign modules. However, some PureScript modules use relative imports in their associated foreign modules.

It's unclear the best approach to handling these scenarios. It may not be safe to update requires in the foreign modules. Also, those files do not pass through the purs-loader.

ethul avatar Dec 11 '18 02:12 ethul

According to the PureScript documentation, it recommended not to call PS code from foreign modules. In light of this, I don't know if this is a case that should be handled by the loader. I am leaning towards making this a limitation and something the load doesn't support. However, I am open to ideas on how to make this support possible.

ethul avatar Dec 11 '18 19:12 ethul

Hmm, that's an interesting quandary. Not knowing how any of this stuff works under the hood, my (obviously self-serving) inclination is that if something builds with pulp build then it should build with purs-loader. Assuming it's not incredibly difficult to do so, that is. I'm a neophyte to both purescript and webpack so I'm not really sure what's involved.

adnelson avatar Dec 11 '18 20:12 adnelson

All that being said, reading thru that I wonder if I might just be able to make a PR to purescript-unordered-containers which implements the approach that they recommend there. At the very least, don't put any urgency on this ticket 😆

adnelson avatar Dec 11 '18 20:12 adnelson

At the moment, I am not sure how this can be solved in the purs-loader. I am still open to ideas. Another way to solve this might be to create a very specific loader inline in your webpack config that is a loader for JavaScript. I believe the Data/HashMap.js would run through a JavaScript loader, which means you might be able to manipulate the path in the require statement that is failing. Just an idea, I am not sure if it would work out. Perhaps a PR would be an option to pursue too. Thanks for following up on this.

ethul avatar Dec 11 '18 20:12 ethul