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

Disable external Babel configuration #85

Merged
merged 1 commit into from
Jan 25, 2016
Merged

Conversation

sviridov
Copy link
Contributor

Hi!

This PR prevents jscodeshift's Babel from picking up external Babel configuration.
See this issue for more information.

@fkling
Copy link
Contributor

fkling commented Jan 25, 2016

YOLO: https://phabricator.babeljs.io/T1633 . It seems that babelrc: false should have the same effect. Would you mind trying that instead?

@sviridov
Copy link
Contributor Author

Yeah, I tried to use it, but it's not working. The purpose of babelrc has been changed in Babel 6.

Babel 5:

babelrc (default value = null) Specify a custom file path to load a .babelrc config from.

Babel 6:

babelrc (default value = true) Specify whether or not to use .babelrc and .babelignore files.

@fkling
Copy link
Contributor

fkling commented Jan 25, 2016

Uh :-/ It looked like it should work because of this check:

    // resolve all .babelrc files
    if (opts.babelrc !== false) {
      this.findConfigs(opts.filename);
    }

But OK, breakConfig is basically doing the same thing a few lines above.

@sviridov
Copy link
Contributor Author

Well, opts.babelrc is undefined... I did very simple thing:

function setup(tr, babel) {
  if (babel === 'babel') {
    require('babel-core/register')({ babelrc: false });
  }
  transform = require(tr);
}
console.log('opts:', opts);
// resolve all .babelrc files
if (opts.babelrc !== false) {
  this.findConfigs(opts.filename);
}

Output: opts: { filename: '<my-transformation>.js' }.
And they taking breakConfig not from opts but from this.options...

@fkling
Copy link
Contributor

fkling commented Jan 25, 2016

Ah I see. The options object passed to the function (transformOpts) is not passed passed to init, but added separately:

  var optsManager = new OptionManager;
  optsManager.mergeOptions(transformOpts);
  opts = optsManager.init(opts);

that's why opts.babelrc doesn't work but this.options.breakConfig does.

fkling added a commit that referenced this pull request Jan 25, 2016
Disable external Babel configuration
@fkling fkling merged commit fbfb19a into facebook:master Jan 25, 2016
@fkling
Copy link
Contributor

fkling commented Jan 25, 2016

Released with v0.3.13.

@sviridov
Copy link
Contributor Author

Awesome, thanks!

@zvictor zvictor mentioned this pull request Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants