Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do babel transformations for script, not module MONGOSH-986 #1103

Merged
merged 1 commit into from
Sep 13, 2021

Conversation

addaleax
Copy link
Contributor

Tell babel that we are targeting script mode, not ES module mode.
(Note that the babel docs indicate that script should be the
default – it seems that that is not entirely accurate.)

This fixes the linked bug because unlike ES modules, script mode
does not automatically also enable strict mode.

This also fixes a minor bug in the wrap-as-iife babel plugin,
where if the input was a single string literal, escaped characters
would have remained escaped (e.g., entering '\x41' in mongosh
would have returned \x41, not 'A'), by keeping the existing
information about the raw source instead of generating an
entirely new string literal in that case.

Tell babel that we are targeting script mode, not ES module mode.
(Note that the babel docs indicate that `script` should be the
default – it seems that that is not entirely accurate.)

This fixes the linked bug because unlike ES modules, script mode
does not automatically also enable strict mode.

This also fixes a minor bug in the wrap-as-iife babel plugin,
where if the input was a single string literal, escaped characters
would have remained escaped (e.g., entering `'\x41'` in mongosh
would have returned `\x41`, not 'A'), by keeping the existing
information about the raw source instead of generating an
entirely new string literal in that case.
@addaleax addaleax merged commit a118848 into main Sep 13, 2021
@addaleax addaleax deleted the 986-dev branch September 13, 2021 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants