The plugin babel-plugin-transform-merge-sibling-variables does not maintain source mapping when merging sibling variable declarators into a single declaration after babel-plugin-transform-modules-commonjs has been applied.
To Reproduce
Minify a file that has been processed with babel-plugin-transform-modules-commonjs. If the original file has more than one import statement, the mapping will be lost.
Minimal code to reproduce the bug
index.js.map
import { abc } from 'abc';
import { xyz } from 'xyz';
Describe the bug
The plugin
babel-plugin-transform-merge-sibling-variables
does not maintain source mapping when merging sibling variable declarators into a single declaration afterbabel-plugin-transform-modules-commonjs
has been applied.To Reproduce
Minify a file that has been processed with
babel-plugin-transform-modules-commonjs
. If the original file has more than one import statement, the mapping will be lost.Minimal code to reproduce the bug
index.js.map
Actual Output
index.out.js
index.out.js.map
Expected Output
index.out.js
index.out.js.map
Configuration
How are you using babel-minify?
babel-minify version:
0.5.2
babel version :
7.21.0
babel-plugin-transform-modules-commonjs:
8.0.11
babel-plugin-transform-merge-sibling-variables:
6.9.5
babelrc
package.json
Possible solution
This pull request: https://github.com/babel/minify/pull/1047
You can use the link below to inspect the mappings for a given output file and sourcemap.
https://evanw.github.io/source-map-visualization/#MTEwACJ1c2Ugc3RyaWN0IjsKCnZhciBfYWJjID0gcmVxdWlyZSgiYWJjIiksCiAgX3h5eiA9IHJlcXVpcmUoInh5eiIpOwoKLy8jIHNvdXJjZU1hcHBpbmdVUkw9aW5kZXguZXhwZWN0ZWQuanMubWFwMjQ1AHsidmVyc2lvbiI6MywiZmlsZSI6ImluZGV4LmV4cGVjdGVkLmpzIiwibmFtZXMiOlsiX2FiYyIsInJlcXVpcmUiLCJfeHl6Il0sInNvdXJjZXMiOlsiaW5kZXguanMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgYWJjIH0gZnJvbSAnYWJjJztcbmltcG9ydCB7IHh5eiB9IGZyb20gJ3h5eic7Il0sIm1hcHBpbmdzIjoiOztJQUFBQSxJQUFBLEdBQUFDLE9BQUEsT0FBMEI7RUFDMUJDLElBQUEsR0FBQUQsT0FBQSxPQUEwQiJ9
https://evanw.github.io/source-map-visualization/
alternative tool:https://sokra.github.io/source-map-visualization/