Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dynamic import when the module source is a template literal (#16267)
- Loading branch information
Showing
6 changed files
with
138 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#### Fix dynamic import when the module source is a template string (#16267 by @fisker) | ||
|
||
<!-- prettier-ignore --> | ||
```jsx | ||
// Input | ||
const module = await import(`data:text/javascript, | ||
console.log("RUN"); | ||
`); | ||
|
||
// Prettier stable | ||
const module = await (`data:text/javascript, | ||
console.log("RUN"); | ||
`); | ||
|
||
// Prettier main | ||
const module = await import(`data:text/javascript, | ||
console.log("RUN"); | ||
`); | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
runFormatTest(import.meta, ["babel", "flow", "typescript"], { | ||
errors: { | ||
flow: ["assertions.js"], | ||
acorn: ["assertions.js"], | ||
espree: ["assertions.js"], | ||
meriyah: ["assertions.js"], | ||
flow: ["assertions.js", "template-literal.js", "import-phase.js"], | ||
acorn: ["assertions.js", "import-phase.js"], | ||
espree: ["assertions.js", "import-phase.js"], | ||
meriyah: ["assertions.js", "import-phase.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 @@ | ||
import.source(`data:text/javascript, | ||
console.log("RUN"); | ||
`) | ||
|
||
import.source(String.raw`data:text/javascript, | ||
console.log("RUN"); | ||
`) |
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 @@ | ||
module = await import(`data:text/javascript, | ||
console.log("RUN"); | ||
`); | ||
|
||
module = await import(String.raw`data:text/javascript, | ||
console.log("RUN"); | ||
`); |