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

failure to match srcModuleRegex leads to null instead of __require__ in bundle #113

Open
afcondon opened this issue Jul 12, 2018 · 1 comment

Comments

@afcondon
Copy link

I'm not at all sure that this is really a bug, i'm just posting an issue so that you can consider whether it's desired behaviour.

Situation: if you have a PureScript file in which the module statement isn't the very first thing in the file then the regex defined in purs-module-map.js will fail and you'll get a null instead of the desired __require__ for the compiled JavaScript that you need in the Webpack bundle. In my case, i discovered that i'd acquired a space in front of the module name at some point.

i'm sure there are many things that could break the regex (tho probably almost all others would be caught by the compiler failing to compile the file) so it seems to me that possibly the fix, if a fix is needed, would be to raise an error whenever there isn't a match.

@ethul
Copy link
Owner

ethul commented Jul 22, 2018

Good point. Thanks for bringing this up. It is possible to write a purescript file without importing anything, so I am not sure we should raise an error if no import statements are found. Maybe a warning, but I am not sure.

I wonder if there is a better way to handle the import-to-require mappings altogether, instead of using a regex. Perhaps something that handles cases like the one where there is an extra space in front of the module name.

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

No branches or pull requests

2 participants