Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
importInterop: "node"
option for module transforms
- Loading branch information
1 parent
6b39baf
commit 82415e4
Showing
114 changed files
with
922 additions
and
45 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
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
7 changes: 6 additions & 1 deletion
7
packages/babel-plugin-transform-modules-amd/test/fixtures/amd/imports-glob/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,6 +1,11 @@ | ||
define(["foo"], function (foo) { | ||
"use strict"; | ||
|
||
foo = babelHelpers.interopRequireWildcard(foo); | ||
foo = _interopRequireWildcard(foo); | ||
|
||
function _getRequireWildcardCache(i) { if (typeof WeakMap !== "function") return null; var cache = [new WeakMap(), new WeakMap()]; _getRequireWildcardCache = function (i) { return cache[i]; }; return cache[i]; } | ||
|
||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(+!!nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && key !== "default") { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
|
||
foo; | ||
}); |
7 changes: 6 additions & 1 deletion
7
packages/babel-plugin-transform-modules-amd/test/fixtures/amd/imports-mixing/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,7 +1,12 @@ | ||
define(["foo"], function (_foo) { | ||
"use strict"; | ||
|
||
_foo = babelHelpers.interopRequireWildcard(_foo); | ||
_foo = _interopRequireWildcard(_foo); | ||
|
||
function _getRequireWildcardCache(i) { if (typeof WeakMap !== "function") return null; var cache = [new WeakMap(), new WeakMap()]; _getRequireWildcardCache = function (i) { return cache[i]; }; return cache[i]; } | ||
|
||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(+!!nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && key !== "default") { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
|
||
_foo.default; | ||
_foo.baz; | ||
}); |
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
1 change: 1 addition & 0 deletions
1
...ugin-transform-modules-amd/test/fixtures/importInterop-node/export-default-from/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 @@ | ||
export { default } from 'dep'; |
8 changes: 8 additions & 0 deletions
8
...ugin-transform-modules-amd/test/fixtures/importInterop-node/export-default-from/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,8 @@ | ||
define(["exports", "dep"], function (_exports, _dep) { | ||
"use strict"; | ||
|
||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
_exports.default = _dep; | ||
}); |
1 change: 1 addition & 0 deletions
1
...form-modules-amd/test/fixtures/importInterop-node/export-named-and-default-from/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 @@ | ||
export { default, name } from 'dep'; |
20 changes: 20 additions & 0 deletions
20
...form-modules-amd/test/fixtures/importInterop-node/export-named-and-default-from/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,20 @@ | ||
define(["exports", "dep"], function (_exports, _dep) { | ||
"use strict"; | ||
|
||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(_exports, "default", { | ||
enumerable: true, | ||
get: function () { | ||
return _dep.default; | ||
} | ||
}); | ||
Object.defineProperty(_exports, "name", { | ||
enumerable: true, | ||
get: function () { | ||
return _dep.name; | ||
} | ||
}); | ||
_dep = babelHelpers.interopRequireWildcard(_dep, true); | ||
}); |
1 change: 1 addition & 0 deletions
1
...plugin-transform-modules-amd/test/fixtures/importInterop-node/export-named-from/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 @@ | ||
export { name } from 'dep'; |
13 changes: 13 additions & 0 deletions
13
...plugin-transform-modules-amd/test/fixtures/importInterop-node/export-named-from/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,13 @@ | ||
define(["exports", "dep"], function (_exports, _dep) { | ||
"use strict"; | ||
|
||
Object.defineProperty(_exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(_exports, "name", { | ||
enumerable: true, | ||
get: function () { | ||
return _dep.name; | ||
} | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...el-plugin-transform-modules-amd/test/fixtures/importInterop-node/import-default/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,3 @@ | ||
import foo from "foo"; | ||
|
||
foo(); |
5 changes: 5 additions & 0 deletions
5
...el-plugin-transform-modules-amd/test/fixtures/importInterop-node/import-default/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,5 @@ | ||
define(["foo"], function (_foo) { | ||
"use strict"; | ||
|
||
_foo(); | ||
}); |
4 changes: 4 additions & 0 deletions
4
...transform-modules-amd/test/fixtures/importInterop-node/import-named-and-default/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,4 @@ | ||
import foo, { named } from "foo"; | ||
|
||
foo(); | ||
named(); |
7 changes: 7 additions & 0 deletions
7
...transform-modules-amd/test/fixtures/importInterop-node/import-named-and-default/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,7 @@ | ||
define(["foo"], function (_foo) { | ||
"use strict"; | ||
|
||
_foo = babelHelpers.interopRequireWildcard(_foo, true); | ||
(0, _foo.default)(); | ||
(0, _foo.named)(); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...abel-plugin-transform-modules-amd/test/fixtures/importInterop-node/import-named/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,3 @@ | ||
import { named } from "foo"; | ||
|
||
named(); |
Oops, something went wrong.