-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[file_packager.py] Add --modularize to file_packager.py #24737
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
Open
lkwinta
wants to merge
8
commits into
emscripten-core:main
Choose a base branch
from
lkwinta:file_packager_modularize
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c6c74d0
Add modularize to file_packager.py
lkwinta d18dd68
fix python format
lkwinta 3f3d8bf
apply more ruff fixes
lkwinta 9914e14
fix pipeline
lkwinta 738a4c2
revert file to the most actual version and apply changes
lkwinta a4eb650
add modularize to options class
lkwinta ee72cab
add utilization of EXPORT_NAME with modularize option
lkwinta 05f9693
simplify declaration of the modularize function
lkwinta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this extra inner function here or can we just do:
Also, I think the function doesn't need to be async because it hooks into the Module object using
addRunDependency
/removeRunDependency
. Although if the Module is already loaded and running that might not work, so we might need to change that too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function is async because I didn't touch inner code, i. e. web requests which return promises but I agree that it might need changing.
The inner function prevents from using
new
keywoard, just like inemcc
ES 6 export codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need the generated code here to look like the emscripten-generate program. For example, the file loading code just take a single
Module
argument, I think, it doesn't need the whole moduleArg dictionary thing.Also, the emcc output no longer contains the
new
keyword check. See #23960.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, my bad, I was basing on emsdk release which doesn't have those changs.
What do you suggest to pass inside that function? Only Module's FS and used stuff like locate file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the generated code expected something called
Module
which is the whole module object? But I could be wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also call it with your module args object and it looks like it will inject a
Module.preRun
in that case. i.e. it works if its passed either module args or that actual module.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, generated module want's to use modules function like
locateFile
andFS_CreatePath
. Probably it messes with modules internal state while creating files in VFS.You mean that I could just use it like this:
Isn't it the same as calling it with
mod
arg sinceMainModule(preMod)
takespreMod
by reference and extends it with fields? Od that's not the case I think we can't use it like this because we need to fill in Module's (mod
) virtual FS paths.Original use case was:
since it oprrates on the same global context IT passes whole Module dictionary.
In @kripken's demo linked in emscripten docs, DOM manipulation is used to insert <script> tags at runtime to load datafile, but we can't use it because of react and WebWorkers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to use EXPORT_NAME here.. can't you just always call the function
loadDataFile
? Since it exported by default I don't even think it really matter what it is called.Why not just?
Also, as I think I said already I don't think need the inner function here do you? And I don't think anything need to be async because we never return a promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, now I see your point, I think that I have simplified it now.
I will take a look into those tests that are failing for some reason.