Use a different name than "top" in top-level code #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When style-mod is bundled without being minified, the
topvariable withinsrc/style-mod.jsconflicts with many browsers'toptop-level variable.Since this is a computed attribute, this throws an error in strict mode:
This is a regular, module-local variable. In a standard-conforming module loader or bundler, it should not interfere with a global of the same name at all. How are you doing the bundling?
I tried esbuild and tsup. Both have the same issue.
I realize this is a pretty weird error. I was baffled by it for a while
This works and emits a bundle that looks perfectly okay.
It seems like this error only shows up when using the
nodeplatform:test.js:test_bundle.jsThis is still only a problem when there are browser apis to conflict with:
test.htmlDon't use
--platform=node, which emits a CommonJS module, if you're going to run the bundle in the browser. As you found, that'll load all the module-local variables into the global scope, which is bad.Unfortunately
--platform=nodeis required for VS Code extensions, which is what I'm working on.Actually, no... maybe it's not required. But that's the default....
Actually, I think I see the issue. I'm using the same bundler settings for the extension javascript file and the javascript that's loaded in the webview. I'll have to update that on my project's side.
Thanks!
Pull request closed