Issue 1:
Hello

It seems that having a local plugin in the .babelrc breaks babel-node.

This is my .babelrc file:

{
"stage": 0,
"env": {
"development": {
"plugins": ["./build/babelRelayPlugin", "react-transform"],
"sourceMaps": "inline",
"optional": [
"runtime",
"es7.decorators",
"es7.classProperties"
],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}
}
}
}
}

And this is my local ./build/babelRelayPlugin:

var getbabelRelayPlugin = require('babel-relay-plugin');
var schema = require('../data/schema.json');

module.exports = getbabelRelayPlugin(schema.data);

This results in the following error:

> babel-node ./devServer.js

C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\file\plugin-manager.js:164
throw new TypeError(messages.get("pluginNotTransformer", name));
^

TypeError: The plugin "./build/babelRelayPlugin.js" didn't export a Plugin instance
at PluginManager.validate (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\file\plugin-manager.js:164:13)
at PluginManager.add (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\file\plugin-manager.js:213:10)
at File.buildTransformers (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\file\index.js:237:21)
at new File (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\file\index.js:139:10)
at Pipeline.transform (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\transformation\pipeline.js:164:16)
at Object.transformFileSync (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\api\node.js:137:37)
at compile (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\api\register\node.js:132:20)
at normalLoader (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\api\register\node.js:199:14)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\bwessels.SPENDV\Documents\WebstormProjects\react-transform-boilerplate\node_modules\babel-core\lib\api\register\node.js:216:7)
at Module.load (module.js:355:32)

The only way I found to fix this is moving my local babel-relay-plugin into the node_modules folder and make it like being a complete package. That works but I would rather be able to use local plugins in my .babelrc file.

Any ideas how to fix this?

Thank you

Bernd

Issue 2:
Minimal 100% repro case: https://gist.github.com/impinball/cfe04caff66f7547611a

Expected:

Success

Found:

$PWD/node_modules/babel/node_modules/babel-core/lib/transformation/file/plugin-manager.js:164
throw new TypeError(messages.get("pluginNotTransformer", name));
^

TypeError: The plugin "./plugin.js" didn't export a Plugin instance
at PluginManager.validate ($PWD/node_modules/babel/node_modules/babel-core/lib/transformation/file/plugin-manager.js:164:13)
at PluginManager.add ($PWD/node_modules/babel/node_modules/babel-core/lib/transformation/file/plugin-manager.js:213:10)
at File.buildTransformers ($PWD/node_modules/babel/node_modules/babel-core/lib/transformation/file/index.js:237:21)
at new File ($PWD/node_modules/babel/node_modules/babel-core/lib/transformation/file/index.js:139:10)
at Pipeline.transform ($PWD/node_modules/babel/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at Object.transformFileSync ($PWD/node_modules/babel/node_modules/babel-core/lib/api/node.js:137:37)
at compile ($PWD/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:132:20)
at normalLoader ($PWD/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:14)
at Object.require.extensions.(anonymous function) [as .js] ($PWD/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:355:32)

@sebmck?

Edit: See the first comment for a better explanation.

The problem appears, from inserting console.logs in the generated output, to be caused by this require returning an empty object, as if by a circular require. The catch is that the file is never actually evaluated. And this only happens with relative requires.

It seems to me like the problem is that Babel's require hook is getting in the way of parsing plugins given with relative paths, causing them to be required twice. The best fix IMHO is to explicitly ignore (without the ability to override) plugin files when transpiling.