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

Unknown Plugin "transform-es2015-block-scoping" #121

Closed
wdullaer opened this issue Nov 13, 2017 · 5 comments · Fixed by #122
Closed

Unknown Plugin "transform-es2015-block-scoping" #121

wdullaer opened this issue Nov 13, 2017 · 5 comments · Fixed by #122

Comments

@wdullaer
Copy link

Since upgrading to rewire 3.0.0 some of my builds are failing because babel can't load the "transform-es2015-block-scoping" plugin.
The stacktrace indicates that rewire is trying to load this (my own code does not rely on babel).
You can see at the top of the stactrace that babel is looking for node_modules in the directory where the rewired file lives, rather than the current working directory.

Some research (babel/babel#5618) seems to indicate that this is a known issue with babel 6.
As of babel 7, babel will try to resolve plugins relative to the cwd, or, you could explicitly specify the location of the plugin using babel.resolvePlugin('foo', '/my-dir')

If you know of any other workaround, I'm all ears :-)

Stacktrace:

/node_modules/rewire/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180
          throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));                                                                                                   
          ^                                                                                                                                                                                   

ReferenceError: Unknown plugin "transform-es2015-block-scoping" specified in "base" at 0, attempted to resolve relative to "/lib"                                                             
    at /node_modules/rewire/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17                                                                                  
    at Array.map (native)                                                                                                                                                                     
    at Function.normalisePlugins (/node_modules/rewire/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)                                                      
    at OptionManager.mergeOptions (/node_modules/rewire/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)                                                     
    at OptionManager.init (/node_modules/rewire/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)                                                             
    at File.initOptions (/node_modules/rewire/node_modules/babel-core/lib/transformation/file/index.js:212:65)                                                                                
    at new File (/node_modules/rewire/node_modules/babel-core/lib/transformation/file/index.js:135:24)                                                                                        
    at Pipeline.transform (/node_modules/rewire/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at Module.module._compile (/node_modules/rewire/lib/moduleEnv.js:78:29)
    at Object.Module._extensions..js (module.js:416:10)
    at Object.jsExtension (/node_modules/rewire/lib/moduleEnv.js:87:24)
    at Module.load (module.js:343:32)
    at Object.load (/node_modules/rewire/lib/moduleEnv.js:23:18)
    at internalRewire (/node_modules/rewire/lib/rewire.js:50:15)
    at rewire (/node_modules/rewire/lib/index.js:11:12)
    at Object.<anonymous> (/test/index.js:12:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (native)
    at Mocha.loadFiles (/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/node_modules/mocha/bin/_mocha:484:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3
@JvJefke
Copy link
Contributor

JvJefke commented Nov 13, 2017

Babel was introduced into 3.0.0 to enable mocking of const variables. Could you give example code so I can reproduce this error?

@wdullaer
Copy link
Author

Checkout https://github.com/wdullaer/oplog-emitter and run npm run mocha on node 4
The issue does not occur on later node versions (presumably because babel realises that the features it's trying to compile are natively supported by the runtime and therefore does not hit the problematic code path)

@JvJefke
Copy link
Contributor

JvJefke commented Nov 13, 2017

Thx! I opened a PR that should fix this. see #122.

@wdullaer
Copy link
Author

Cool!
I'm not an expert on the internals of require, so I opened an issue rather than a PR.
Also thanks for this library that I've been happily using for a long time 👍

jhnns added a commit that referenced this issue Nov 15, 2017
@jhnns
Copy link
Owner

jhnns commented Nov 15, 2017

Awesome, thanks. Sorry for the broken version. I think I've used require.resolve locally but haven't committed it somehow...

Shipped with 3.0.1

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

Successfully merging a pull request may close this issue.

3 participants