forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve import binding locations during module rewriting (babel#7378)
* Only wrap import references that need it. * Preserve the import binding location for sourcemaps. * Add tests.
- Loading branch information
1 parent
14f3710
commit 625e5b4
Showing
6 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
.../babel-plugin-transform-modules-commonjs/test/fixtures/misc/reference-source-map/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import aDefault from "one"; | ||
import { aNamed } from "two"; | ||
import { orig as anAliased } from "three"; | ||
import * as aNamespace from "four"; | ||
|
||
console.log(aDefault); | ||
console.log(aNamed); | ||
console.log(anAliased); | ||
console.log(aNamespace); | ||
|
||
console.log(aDefault()); | ||
console.log(aNamed()); | ||
console.log(anAliased()); | ||
console.log(aNamespace()); |
3 changes: 3 additions & 0 deletions
3
...el-plugin-transform-modules-commonjs/test/fixtures/misc/reference-source-map/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["external-helpers", "transform-modules-commonjs"] | ||
} |
17 changes: 17 additions & 0 deletions
17
...babel-plugin-transform-modules-commonjs/test/fixtures/misc/reference-source-map/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
|
||
var _one = babelHelpers.interopRequireDefault(require("one")); | ||
|
||
var _two = require("two"); | ||
|
||
var _three = require("three"); | ||
|
||
var aNamespace = babelHelpers.interopRequireWildcard(require("four")); | ||
console.log(_one.default); | ||
console.log(_two.aNamed); | ||
console.log(_three.orig); | ||
console.log(aNamespace); | ||
console.log((0, _one.default)()); | ||
console.log((0, _two.aNamed)()); | ||
console.log((0, _three.orig)()); | ||
console.log(aNamespace()); |
162 changes: 162 additions & 0 deletions
162
...n-transform-modules-commonjs/test/fixtures/misc/reference-source-map/source-mappings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
[ | ||
{ | ||
"generated": { | ||
"line": 10, | ||
"column": 12 | ||
}, | ||
"original": { | ||
"line": 6, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 10, | ||
"column": 23 | ||
}, | ||
"original": { | ||
"line": 6, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 11, | ||
"column": 12 | ||
}, | ||
"original": { | ||
"line": 7, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 11, | ||
"column": 22 | ||
}, | ||
"original": { | ||
"line": 7, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 12, | ||
"column": 12 | ||
}, | ||
"original": { | ||
"line": 8, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 12, | ||
"column": 22 | ||
}, | ||
"original": { | ||
"line": 8, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 13, | ||
"column": 12 | ||
}, | ||
"original": { | ||
"line": 9, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 13, | ||
"column": 21 | ||
}, | ||
"original": { | ||
"line": 9, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 14, | ||
"column": 16 | ||
}, | ||
"original": { | ||
"line": 11, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 14, | ||
"column": 27 | ||
}, | ||
"original": { | ||
"line": 11, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 15, | ||
"column": 16 | ||
}, | ||
"original": { | ||
"line": 12, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 15, | ||
"column": 26 | ||
}, | ||
"original": { | ||
"line": 12, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 16, | ||
"column": 16 | ||
}, | ||
"original": { | ||
"line": 13, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 16, | ||
"column": 26 | ||
}, | ||
"original": { | ||
"line": 13, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 17, | ||
"column": 12 | ||
}, | ||
"original": { | ||
"line": 14, | ||
"column": 12 | ||
} | ||
}, | ||
{ | ||
"generated": { | ||
"line": 17, | ||
"column": 21 | ||
}, | ||
"original": { | ||
"line": 14, | ||
"column": 12 | ||
} | ||
} | ||
] |