Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve dynamic import spec compliance
- Loading branch information
1 parent
87e48e7
commit 814bf88
Showing
17 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/babel-plugin-proposal-dynamic-import/test/fixtures/amd/module/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,5 +1,5 @@ | ||
define(["require"], function (_require) { | ||
"use strict"; | ||
|
||
var modP = new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(babelHelpers.interopRequireWildcard(imported)), _reject)); | ||
var modP = Promise.resolve().then(() => new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(babelHelpers.interopRequireWildcard(imported)), _reject))); | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/babel-plugin-proposal-dynamic-import/test/fixtures/amd/no-interop/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,3 +1,3 @@ | ||
define(["require"], function (_require) { | ||
var modP = new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(imported), _reject)); | ||
var modP = Promise.resolve().then(() => new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(imported), _reject))); | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/babel-plugin-proposal-dynamic-import/test/fixtures/amd/script/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,3 +1,3 @@ | ||
define(["require"], function (_require) { | ||
var modP = new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(babelHelpers.interopRequireWildcard(imported)), _reject)); | ||
var modP = Promise.resolve().then(() => new Promise((_resolve, _reject) => _require(["mod"], imported => _resolve(babelHelpers.interopRequireWildcard(imported)), _reject))); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-proposal-dynamic-import/test/fixtures/amd/to-string/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 @@ | ||
import(2); |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-proposal-dynamic-import/test/fixtures/amd/to-string/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,3 @@ | ||
define(["require"], function (_require) { | ||
new Promise(r => r(`${2}`)).then(s => new Promise((_resolve, _reject) => _require([s], imported => _resolve(babelHelpers.interopRequireWildcard(imported)), _reject))); | ||
}); |
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
...ges/babel-plugin-proposal-dynamic-import/test/fixtures/commonjs/exec-to-string-order/1.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 @@ | ||
module.exports = 1; |
7 changes: 7 additions & 0 deletions
7
.../babel-plugin-proposal-dynamic-import/test/fixtures/commonjs/exec-to-string-order/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,7 @@ | ||
let i = 0; | ||
const promise = expect(import({ toString: () => `./${++i}.js` })) | ||
.resolves.toHaveProperty("default", 1); | ||
expect(i).toBe(1); | ||
++i; | ||
expect(i).toBe(2); | ||
return promise; |
5 changes: 5 additions & 0 deletions
5
...l-plugin-proposal-dynamic-import/test/fixtures/commonjs/exec-to-string-order/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
.../babel-plugin-proposal-dynamic-import/test/fixtures/commonjs/exec-to-string-throw/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,2 @@ | ||
return expect(import({ toString: () => { throw "toString failed"; } })) | ||
.rejects.toBe("toString failed"); |
5 changes: 5 additions & 0 deletions
5
...l-plugin-proposal-dynamic-import/test/fixtures/commonjs/exec-to-string-throw/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,5 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/babel-plugin-proposal-dynamic-import/test/fixtures/commonjs/to-string/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 +1 @@ | ||
Promise.resolve(`${2}`).then(s => babelHelpers.interopRequireWildcard(require(s))); | ||
new Promise(r => r(`${2}`)).then(s => babelHelpers.interopRequireWildcard(require(s))); |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-proposal-dynamic-import/test/fixtures/systemjs/to-string/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 @@ | ||
import(2); |
10 changes: 10 additions & 0 deletions
10
packages/babel-plugin-proposal-dynamic-import/test/fixtures/systemjs/to-string/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,10 @@ | ||
System.register([], function (_export, _context) { | ||
"use strict"; | ||
|
||
return { | ||
setters: [], | ||
execute: function () { | ||
new Promise(r => r(`${2}`)).then(s => _context.import(s)); | ||
} | ||
}; | ||
}); |
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