-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
ssrLoadModule executes code in non-strict mode #9197
Labels
Comments
Changing this line...
const AsyncFunction = async function () {}.constructor as typeof Function
const initModule = new AsyncFunction(
`global`,
ssrModuleExportsKey,
ssrImportMetaKey,
ssrImportKey,
ssrDynamicImportKey,
ssrExportAllKey,
- result.code + `\n//# sourceURL=${mod.url}`
+ '"use strict";\n' + result.code + `\n//# sourceURL=${mod.url}`
) |
LGTM. @Rich-Harris if you don't mind I'll do the PR to change that line as we can run vite-ecosystem-ci if the PR branch is in the repo. If no ecosystem CI complaints I think it is safe to get this one in a patch |
patak-dev
added a commit
that referenced
this issue
Jul 18, 2022
4 tasks
4 tasks
patak-dev
added a commit
that referenced
this issue
Jul 19, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Describe the bug
A module like this...
...should fail, because
foo
is not declared anywhere, and modules always run in strict mode. This works correctly in an app built by Vite. During development, however, the module is interpreted as a non-strict function, and the code above runs.Reproduction
https://github.com/Rich-Harris/vite-ssrloadmodule-strict-repro
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: