Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

enhanced-resolve doesn't always have /lib/ModuleAliasPlugin.js #25

Open
robin-surge opened this issue Sep 8, 2017 · 9 comments
Open

Comments

@robin-surge
Copy link

robin-surge commented Sep 8, 2017

I currently have a project with enhanced-resolve v3.4.1 and it doesn't have /lib/ModuleAliasPlugin.js; this causes RewirePlugin.js to fail in line 48.

See also: https://github.com/webpack/enhanced-resolve/tree/master/lib

Additionally, in webpack the resolvers are initialised with null in the Compiler constructor and you cannot use apply on null: https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L184

@gempain
Copy link

gempain commented Sep 11, 2017

Same problem here. Getting TypeError: Cannot read property 'apply' of null as a consequence of the mentioned problem.

@robin-surge
Copy link
Author

For everyone having the same problem: You can use babel and babel-rewire-plugin. It sidesteps the issue (rewire is then handled by babel) and is a nice workaround to get unblocked.

@gempain
Copy link

gempain commented Sep 13, 2017

Can you provide an example :)?

@robin-surge
Copy link
Author

For what, exactly? Using babel-rewire or for the issue described?

@gempain
Copy link

gempain commented Sep 13, 2017 via email

@robin-surge
Copy link
Author

Its nothing special about what I did. I just used a different set of frameworks. Instead of going karma -> webpack -> webpack-rewire -> mocha/chai I now use karma -> webpack -> babel -> babel-plugin-rewire -> mocha/chai

You can check out the babel plugin here: https://github.com/speedskater/babel-plugin-rewire

@gempain
Copy link

gempain commented Sep 13, 2017

Sweet, thanks for the help ! I'll be looking into it. The only thing I am worried about when using babel is that I've always used webpack, and I am testing a lib that is packed with it. But I guess for unit testing it doesn't really matter how you pack scripts. I am somehow worried that packing something differently in a testing environment and in a production environment could cause issues :/

@robin-surge
Copy link
Author

My setup still uses webpack :)

@rensbaardman
Copy link

For a solution without babel, you can use my fork rensbaardman/rewire-webpack-plugin, which has webpack 4 support.

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

No branches or pull requests

3 participants