-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying options with sucrase/register and related tools (#813)
Fixes #792 This PR adds a new environment variable SUCRASE_OPTIONS that works with the require hook and other tools that are based on the require hook (`sucrase-node` and programmatically registering a hook). Its format is simply a JSON string that is parsed and merged with the usual options. Hopefully this will be rare, especially after a semver-major change to better defaults, but it's important for some cases.
- Loading branch information
1 parent
d617368
commit 4bd800b
Showing
6 changed files
with
33 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
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
...ation-test/test-cases/register-cases/respects-preserve-dynamic-import-option/esm-file.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 const foo = 3; |
7 changes: 7 additions & 0 deletions
7
integration-test/test-cases/register-cases/respects-preserve-dynamic-import-option/main.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 @@ | ||
async function main() { | ||
const plainESMFile = await import("./esm-file.mjs"); | ||
if (plainESMFile.foo !== 3) { | ||
throw new Error(); | ||
} | ||
} | ||
main(); |
5 changes: 5 additions & 0 deletions
5
integration-test/test-cases/register-cases/respects-preserve-dynamic-import-option/test.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 @@ | ||
{ | ||
"sucraseOptions": { | ||
"preserveDynamicImport": true | ||
} | ||
} |
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