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

Names missing from source map #9173

Open
Nuru opened this issue Dec 13, 2018 · 2 comments
Open

Names missing from source map #9173

Nuru opened this issue Dec 13, 2018 · 2 comments

Comments

@Nuru
Copy link

Nuru commented Dec 13, 2018

Bug Report

This happens with versions 7.2.0 (@babel/core 7.1.0) and 6.26.0 (babel-core 6.26.3). Version 7.2.0 example documented below.

Current Behavior
When minifying code, the generated source map has an empty names property, so dev tools are unable to unmangle variable names.

Input Code

var click = (base) => {
    let xtreme = 1;
    if (base)
      xtreme = xtreme + base;
    console.log(xtreme);
  }

Output Source

var click=a=>{let b=1;a&&(b+=a),console.log(b)};

Output Source Map

{"version":3,"sources":["foo.js"],"names":[],"mappings":"AAAA,GAAI,CAAA,KAAK,CAAI,CAAD,EAAU,CAClB,GAAI,CAAA,CAAM,CAAG,CAAb,CACI,CAFc,GAGhB,CAHgB,EAGE,CAHF,EAIlB,OAAO,CAAC,GAAR,CAAY,CAAZ,CACD,CALH","file":"foo.min.js","sourcesContent":["var click = (base) => {\n    let xtreme = 1;\n    if (base)\n      xtreme = xtreme + base;\n    console.log(xtreme);\n  }\n"]}

Expected behavior/code
Names base and extreme should be in the source map names array and properly mapped from a and b in the mapping.

Babel Configuration (.babelrc, package.json, cli command)

% npx babel --presets=minify --source-type=script dev/foo.js --out-file=dev/foo.min.js --source-maps --no-babelrc 

Environment

  • Babel version(s): 7.2.0 (@babel/core 7.1.0), 6.26.0 (babel-core 6.26.3
  • Node/npm version: Node 8/npm 6
  • OS: OSX 10.11.6
  • Monorepo: no
  • How you are using Babel: cli

Comments
Hard to call this a reversion of #27, but this should have been fixed with #3658.

@babel-bot
Copy link
Collaborator

Hey @Nuru! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@JennieJi
Copy link

Wow this still happens in latest version. Got test case here. And only fails in babel-cli, babel-core's transform works well. Not sure why babel-cli is not using same implementation from babel-core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants