-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
--format=bare or --global={var1, var2} #964
Comments
Why not just do something like |
There isn't a |
Wait -- maybe I'm mistaken. I'll go tinker with the sandbox model Zotero has. Maybe it can be exposed there. |
Zotero is based on FF60ESR, and according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis, only FF65+ has |
(but there may be no need to rush on this -- I need code splitting, but I can't use esm modules. I'm tinkering with jscodeshift to see if I can transform |
globalThis refers to window and/or self depending on the context. If you're targeting FF60 then |
Zotero runs parts of the code (the translators) in a xpcom sandbox, which doesn't have a |
Where would I start if I wanted to create a new output format? Firefox extensions have facilities that can mimic esm modules. I'm really keen on starting with esbuild - the speed is unbelievable, and recent versions of webpack have been a pain to use for xpcom Firefox extensions. |
I think it should be pretty straightforward to do this with a footer: https://esbuild.github.io/api/#footer. Just use the IIFE format with a footer that looks like |
Absolutely! That solves my problem for the context where I just need simple bundling. For the other context, I need code splitting, so I'm looking to have esbuild convert my typescript to esm, and then use jscodeshift to transform the |
Probably not a surprise for you but the speed of esbuild is insane. I must get this to work for my project. I should be thanking webpack for breaking my builds with the releases of the past few weeks -- that's what drove me to seek out alternatives. |
Where would I start adding a new output format? Seems like a shame to hand in a good chunk of the speed gained by having to put it through jscodeshift. Is this something that could be done in a plugin (either go or JS)? |
Code splitting is still a work in progress. It is currently undergoing a rewrite and the second half of the linker (the part that deals with output formats) is being completely rewritten. Because of this, I'm not open to adding new output formats at the moment. Still it could be useful to know a little bit about the output format you are looking for. How do imports and exports work? |
import: Components.utils.import but I have to warn that these are methods that Mozilla deems deprecated. Zotero builds on ESR because they're still active there, and all Zotero plugins use this, but it doesn't have a long lifespan left. I know I'm not supposed to ask for an ETA on the rewrite, but does your current hunch think of it in weeks, months, or years? Pretty keen to get rid of webpack. |
Does that mean code splitting is fine now but is expected to get better in some way, or that the current code splitting should not be used? |
The current form of code splitting is still experimental and should only be used in certain circumstances. It currently only works with the I don't have a hard ETA for this but I'm hoping to get pretty much everything figured out and shipped sometime in the next month. That said there are significant complexities to doing all of this and it's already taking longer than I had planned earlier. In particular, the ordering requirements of top-level await and external imports are especially tricky to get right. Other bundlers such as Rollup don't even get them right yet. |
I know how those projects go. No worries. I'll just await (ha!) the drop of the rewrite then. One more month of webpack won't kill me, and I do have ordering requirements, albeit only for synchronous code. Maybe I should do something about that anyway. |
I'm closing this issue since I'm not planning on implementing this. |
I have a workaround, so no issue. |
I am building Zotero plugins, and for that I must sometimes expose multiple variables in the global context. Would it be possible to either expose the entrypoint "bare" (so all declarations happen in the global scope) or allow multi-var assignment so the bundled code ends up looking like
var {var1, var2} = ...
The text was updated successfully, but these errors were encountered: