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

Research workarounds for webpack parses varDeclaration #12

Open
rensbaardman opened this issue Jun 3, 2019 · 1 comment
Open

Research workarounds for webpack parses varDeclaration #12

rensbaardman opened this issue Jun 3, 2019 · 1 comment

Comments

@rensbaardman
Copy link
Owner

Currently, we have

parser.hooks.varDeclaration.for('rewire').tap('RewireWebpackPlugin', ...

But then we miss things like

const my_rewire_name = require('rewire')

How to work around this?

Possibly contribute to webpack itself with an extra parser option for require statements. Or for function calls, and then specifically require-statements.

@rensbaardman rensbaardman added this to the future milestone Jun 3, 2019
@rensbaardman
Copy link
Owner Author

It seems related to the fact that you first have to 'register' variables to the parses, because else it will only consider 'free variables'.

See
Sokra: The Parser only handles "free-vars". Identifiers declared in scope do not trigger hooks. This is expected.
webpack/webpack#6740 (comment)

This behaviour seems undocumented. Also note that you need to 'return true' instead of 'return false', as the comment by Sokra suggested.

Related:
webpack/webpack#2585
webpack/webpack#6740

@rensbaardman rensbaardman removed this from the future milestone Jun 11, 2019
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

1 participant