Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #744 Fixes #566 In ESM mode, we parse import assertions and usually just pass them through to the output code, though TS import elision needs to know how to remove them as well. In CJS mode, we always remove import assertions since `require` can handle JSON files.
- Loading branch information
1 parent
0ae8d9b
commit 8e3f254
Showing
12 changed files
with
179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ const CONTEXTUAL_KEYWORDS = [ | |
"abstract", | ||
"accessor", | ||
"as", | ||
"assert", | ||
"asserts", | ||
"async", | ||
"await", | ||
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ export enum ContextualKeyword { | |
_abstract, | ||
_accessor, | ||
_as, | ||
_assert, | ||
_asserts, | ||
_async, | ||
_await, | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {ContextualKeyword} from "../parser/tokenizer/keywords"; | ||
import {TokenType as tt} from "../parser/tokenizer/types"; | ||
import type TokenProcessor from "../TokenProcessor"; | ||
|
||
/** | ||
* Starting at a potential `assert` token remove the import assertion if there | ||
* is one. | ||
*/ | ||
export function removeMaybeImportAssertion(tokens: TokenProcessor): void { | ||
if (tokens.matches2(tt.name, tt.braceL) && tokens.matchesContextual(ContextualKeyword._assert)) { | ||
// assert | ||
tokens.removeToken(); | ||
// { | ||
tokens.removeToken(); | ||
tokens.removeBalancedCode(); | ||
// } | ||
tokens.removeToken(); | ||
} | ||
} |
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