Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy getters and setters correctly in interopWildcard (#6850)
- Loading branch information
1 parent
18b91a8
commit 9d9710c
Showing
10 changed files
with
70 additions
and
2 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
3 changes: 3 additions & 0 deletions
3
...-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/actual.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,3 @@ | ||
import * as foo from "./moduleWithGetter"; | ||
|
||
export { foo }; |
5 changes: 5 additions & 0 deletions
5
...el-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/exec.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,5 @@ | ||
import * as foo from "./moduleWithGetter"; | ||
|
||
assert.throws(() => foo.boo); | ||
|
||
// No exception should be thrown |
12 changes: 12 additions & 0 deletions
12
...lugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/expected.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,12 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.foo = void 0; | ||
|
||
var foo = _interopRequireWildcard(require("./moduleWithGetter")); | ||
|
||
exports.foo = foo; | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } |
6 changes: 6 additions & 0 deletions
6
...ansform-modules-commonjs/test/fixtures/misc/copy-getters-setters-star/moduleWithGetter.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,6 @@ | ||
var Obj = { | ||
baz: 123, | ||
get boo() { throw new Error('Should never be triggered'); } | ||
} | ||
|
||
module.exports = Obj; |
3 changes: 3 additions & 0 deletions
3
...babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters/actual.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,3 @@ | ||
import Foo, { baz } from "./moduleWithGetter"; | ||
|
||
export { Foo, baz }; |
3 changes: 3 additions & 0 deletions
3
...s/babel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters/exec.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,3 @@ | ||
import Foo, { baz } from "./moduleWithGetter"; | ||
|
||
// No exception should be thrown |
21 changes: 21 additions & 0 deletions
21
...bel-plugin-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters/expected.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,21 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "Foo", { | ||
enumerable: true, | ||
get: function () { | ||
return _moduleWithGetter.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "baz", { | ||
enumerable: true, | ||
get: function () { | ||
return _moduleWithGetter.baz; | ||
} | ||
}); | ||
|
||
var _moduleWithGetter = _interopRequireWildcard(require("./moduleWithGetter")); | ||
|
||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } |
6 changes: 6 additions & 0 deletions
6
...in-transform-modules-commonjs/test/fixtures/misc/copy-getters-setters/moduleWithGetter.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,6 @@ | ||
var Obj = { | ||
baz: 123, | ||
get boo() { throw new Error('Should never be triggered'); } | ||
} | ||
|
||
module.exports = Obj; |
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