forked from alangpierce/sucrase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flag to preserve dynamic import (alangpierce#727)
Progress toward alangpierce#726 This PR adds a new `preserveDynamicImport` flag that, when enabled, changes the `imports` transform so that only static `import`s are transformed, while dynamic `import()` expressions are passed through as-is. This behavior matches what TypeScript does when handling a `.cjs` file when `module: nodenext` is specified, and ts-node expects transpilers to handle this mode, so this PR is a necessary step toward Sucrase as a ts-node plugin. This mode also seems like the best interpretation of `import()` in new code these days; if `import()` is transpiled, then it's impossible to access ESM code from CJS in Node, so leaving it alone allows a mechanism to import ESM-only libraries. My tentative plan is to change this mode to be the default behavior in an upcoming semver-major release.
- Loading branch information
1 parent
f4a16ac
commit 38db7dc
Showing
6 changed files
with
39 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
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