-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Remove --post-js? #6814
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
Comments
Yes, you are right, actually I usually put all those javascript codes into an anonymous function which will be pushed into the " ATPOSTRUN" structure. The "--post-js" option just used for appending those custom codes to the output javascript file which was generated by "emcc". |
+1 |
+1 It would be great if you could implement two new options instead "--prepend-js" and "--append-js" which could be used e.g. for initializing modularized code on which one could apply simple minification... |
It is used this way in one of the examples: |
I love the Filament uses For example, our View class takes an options structure that has default values, so in our post-js we have something like this:
This allows us to use |
Meanwhile we have added options similar to what @CodeFetch asked for, |
The The only issue is that we access some Module internals; specifically, we call |
I don't think there is an exported API for GC contexts. So you would need a pre-js or a post-js for it. I guess that is overall a reasonable reason to keep post-js around, so maybe we should just not remove it. It would also be a little oddly asymmetrical I suppose. I'll close this for now. |
I think we should remove that option for several reasons:
--post-js
made a lot of sense for JS and asm.js as startup was synchronous there. So adding some code after the main JS would result in it being run as you expect. Even this became a little complicated with async startup due to things like file preloading, but overall worked well. But with wasm, we assume async startup in the common case. And, if async startup is the norm, then all you need is--pre-js
- you add the code you want to run later in a callback, likeModule.onRuntimeInitialized
. Having--post-js
is just an opportunity for confusion.--pre-js
and--post-js
has been seen as a way to wrap the entire output in a function scope. This was never intended: we have MODULARIZE for that, and also, wrapping the output in a new scope the optimizer doesn't see confuses it.--post-js
will make some future refactorings of our JS easier, in particular Feedback wanted: Allow custom "core JS" replacements, to *really* shrink minimal JS sizes #6803.This change may require a bunch of work on tests, so I'm opening this issue for discussion first, as opposed to having the discussion on a PR with code.
The text was updated successfully, but these errors were encountered: