-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix transform of named import with shadowed namespace import (#15898)
- Loading branch information
Showing
13 changed files
with
109 additions
and
65 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
11 changes: 6 additions & 5 deletions
11
packages/babel-plugin-transform-modules-amd/test/fixtures/amd/overview/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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (_exports, foo2, _fooBar, _fooBar2) { | ||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (_exports, _foo, _fooBar, _fooBar2) { | ||
"use strict"; | ||
|
||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
_exports.test2 = _exports.test = _exports.default = void 0; | ||
foo2 = babelHelpers.interopRequireWildcard(foo2); | ||
_foo = babelHelpers.interopRequireWildcard(_foo); | ||
var foo2 = _foo; | ||
var test; | ||
_exports.test = test; | ||
var test2 = 5; | ||
_exports.test2 = test2; | ||
var _default = test; | ||
_exports.default = _default; | ||
foo2.default; | ||
_foo.default; | ||
foo2; | ||
foo2.bar; | ||
foo2.foo; | ||
_foo.bar; | ||
_foo.foo; | ||
}); |
11 changes: 6 additions & 5 deletions
11
packages/babel-plugin-transform-modules-amd/test/fixtures/loose/overview/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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (_exports, foo2, _fooBar, _fooBar2) { | ||
define(["exports", "foo", "foo-bar", "./directory/foo-bar"], function (_exports, _foo, _fooBar, _fooBar2) { | ||
"use strict"; | ||
|
||
_exports.__esModule = true; | ||
_exports.test2 = _exports.test = _exports.default = void 0; | ||
foo2 = babelHelpers.interopRequireWildcard(foo2); | ||
_foo = babelHelpers.interopRequireWildcard(_foo); | ||
var foo2 = _foo; | ||
var test; | ||
_exports.test = test; | ||
var test2 = 5; | ||
_exports.test2 = test2; | ||
var _default = test; | ||
_exports.default = _default; | ||
foo2.default; | ||
_foo.default; | ||
foo2; | ||
foo2.bar; | ||
foo2.foo; | ||
_foo.bar; | ||
_foo.foo; | ||
}); |
7 changes: 4 additions & 3 deletions
7
...in-transform-modules-commonjs/test/fixtures/lazy-dep/import-namespace-and-named/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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
"use strict"; | ||
|
||
function foo() { | ||
function _foo() { | ||
const data = babelHelpers.interopRequireWildcard(require("foo")); | ||
foo = function () { | ||
_foo = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
console.log(foo(), foo().bar); | ||
var foo = _foo; | ||
console.log(foo(), _foo().bar); |
7 changes: 4 additions & 3 deletions
7
...ages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/lazy-7176/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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
"use strict"; | ||
|
||
function mod() { | ||
function _mod() { | ||
const data = babelHelpers.interopRequireWildcard(require("mod")); | ||
mod = function () { | ||
_mod = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
mod().named; | ||
var mod = _mod; | ||
_mod().named; | ||
mod(); |
3 changes: 3 additions & 0 deletions
3
...el-plugin-transform-modules-commonjs/test/fixtures/shadowed-namespace-import/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": ["transform-modules-commonjs"] | ||
} |
8 changes: 8 additions & 0 deletions
8
...sform-modules-commonjs/test/fixtures/shadowed-namespace-import/transformed-name/input.mjs
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,8 @@ | ||
import * as e from "mod"; | ||
import t from "mod"; | ||
|
||
const foo = (e) => { | ||
return { | ||
amount: t.format(1), | ||
}; | ||
}; |
9 changes: 9 additions & 0 deletions
9
...sform-modules-commonjs/test/fixtures/shadowed-namespace-import/transformed-name/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,9 @@ | ||
"use strict"; | ||
|
||
var _mod = babelHelpers.interopRequireWildcard(require("mod")); | ||
var e = _mod; | ||
const foo = e => { | ||
return { | ||
amount: _mod.default.format(1) | ||
}; | ||
}; |
15 changes: 8 additions & 7 deletions
15
packages/babel-plugin-transform-modules-commonjs/test/fixtures/strict/import/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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
"use strict"; | ||
|
||
var foo4 = babelHelpers.interopRequireWildcard(require("foo")); | ||
foo4.default; | ||
foo4.default; | ||
foo4.foo3; | ||
(0, foo4.foo3)(); | ||
(0, foo4.foo3)``; | ||
(0, foo4.foo3)?.(); | ||
var _foo = babelHelpers.interopRequireWildcard(require("foo")); | ||
var foo4 = _foo; | ||
_foo.default; | ||
_foo.default; | ||
_foo.foo3; | ||
(0, _foo.foo3)(); | ||
(0, _foo.foo3)``; | ||
(0, _foo.foo3)?.(); |
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
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