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

"sourceMaps" option in babelrc has no effect #2484

andy-hanson opened this issue Oct 4, 2015 · 6 comments

"sourceMaps" option in babelrc has no effect #2484

andy-hanson opened this issue Oct 4, 2015 · 6 comments


Copy link

@andy-hanson andy-hanson commented Oct 4, 2015

Create an empty directory and do this:

echo '{"sourceMaps": true}' > .babelrc
mkdir src
echo 'export default 1' > src/index.js
babel src --out-dir lib

lib/index.js will be created but not lib/

Adding --source-maps to the command fixes the problem, but I want to do that through babelrc.

Copy link

@sebmck sebmck commented Oct 11, 2015

I've thought about this and it doesn't make any sense. The behaviour of the CLI flags and API options are fundamentally different. Making an API option produce source maps on disk is very different to just populating a property. I'm going to close this as a wontfix.

@sebmck sebmck closed this as completed Oct 11, 2015
@sebmck sebmck added the wontfix label Oct 11, 2015
Copy link

@andy-hanson andy-hanson commented Oct 11, 2015

Maybe remove the option then? If I use {"badOptionName": true} it will tell me that's an unknown option.

Copy link

@sebmck sebmck commented Oct 11, 2015

Except it's a perfectly valid API option.

On Sun, Oct 11, 2015 at 3:08 AM, Andy Hanson

Maybe remove the option then? If I use {"badOptionName": true} it will tell me that's an unknown option.

Reply to this email directly or view it on GitHub:
#2484 (comment)

Copy link

@babel-bot babel-bot commented Sep 7, 2016

Comment originally made by @garthk on 2016-01-30T01:05:13.000Z

@sebmck, I just wasted half an hour reproducing this. I might not be the only one. Reading this thread, I'm now worried there might be //other// options babel silently ignores because you disagree with your users that they make sense affecting the command line.

Maybe, you can wallpaper over this one with a documentation fix. I doubt it. The presence of --no-babelrc strongly suggests .babelrc will be consulted. It's natural to expect all its options will be applied. I don't think a disclaimer in the documentation will help much.

Also, consider the case of babel src -d lib in use in a run script, with a user trying to generate source maps if BABEL_ENV=development. Pushing the option to the command line means they now have to come up with some way of conditionally adding it to the command line. Many build systems, npm run scripts for example, won't make that easy. Your users might blame you, not their build system.

I can write my own command line for babel that does what I want. I don't want to spend the time, though, and many don't have the capability. Please reconsider.

Comment originally made by @jmlane on 2016-03-22T18:31:14.000Z


I am also surprised by this implementation decision.

I just had to double-check to make sure that the documentation does not explicitly state .babelrc will be used at the command-line. Despite this, as @garthk mentioned, the --no-babelrc option as well as most examples/tutorials I've seen imply this is the case.

I would be a very good idea to clarify in the Babel Options documentation which .babelrc options will be used by the CLI and which will be ignored/are for API use only. If .babelrc should not be relied upon for CLI usage then //that fact// should be documented instead.

Comment originally made by Hrusikesh Panda (mrchief) on 2016-05-11T16:55:38.000Z

The behaviour of the CLI flags and API options are fundamentally different.

Then why have an rc file when you're not going to follow *nix philosophy?

Comment originally made by @afinnell on 2016-09-03T20:54:52.000Z

I'm quite confused by this as well..

The babel cli will use the .babelrc to configure itself, but ignores specific "API Only" configuration parameters? Wouldn't it then make sense to have two different configuration files? One for the API and one for the CLI if they both aren't following the same schema?

I just ran into this same problem and was surprised to see the responses. Is there documentation on which API options MUST be specified via command line (if they are going to be used with babel cli)?

The crux of the issue is that the Babel CLI and the Babel API 'use' the same .babelrc file, but accept different schemas.

And the better question is why would the Babel CLI allow certain parameters to be specific in the .babelrc but not source maps? Is it because source maps is a different API in itself when used in a build system like gulp?

Copy link

@laggingreflex laggingreflex commented Dec 13, 2016

It works if you set it to "inline"

evgenykochetkov added a commit to xodio/xod that referenced this issue May 29, 2017
…make babel generate sourcemaps on build

Why not in .babelrc?
See here: babel/babel#2484
Copy link

@olalonde olalonde commented Jun 17, 2017

Yeah, that's confusing, it works for "inline" but not for true :/

@lock lock bot added the outdated label May 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

5 participants