-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow pyscript package to contain multiple files #1262
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
Conversation
Followup to pyscript#1232. Closes pyscript#1226. Use node to make a manifest of the src/python dir and then use terser to inject it into the bundle as a variable called pyscript_package. This means we need to always use the terser plugin even when not minifying. In the non-minify case, we disable terser minification and mangling and enable terser beautification. Note that we bundle mangled versions of many upstream npm dependencies, so even in debug/nonminified builds, these do not include symbol names.
7195b0e
to
1e34b4b
Compare
Oh we seem to vendor mangled npm dependencies. This is not very good. |
For mysterious reasons, these errors appear on my branch pyscript#1262 even though they are not related to changes there. The eslint config seems a bit unstable. Anyways this fixes them.
For mysterious reasons, these errors appear on my branch pyscript#1262 even though they are not related to changes there. The eslint config seems a bit unstable. Anyways this fixes them.
b8ab0cd
to
7957814
Compare
* Unvendor toml package * Fix many ESlint errors For mysterious reasons, these errors appear on my branch #1262 even though they are not related to changes there. The eslint config seems a bit unstable. Anyways this fixes them. * Put back Record * Fix typescript compilation * Fix lints * Try @iarna/toml instead * Fix import * Use @ltd/j-toml * Update test * Use toml-j0.4 * Some changes * Fix toml import * Try adding eslint gha job * Add forgotten checkout action * Force CI to run * Blah * Fix * Revert changes to github workflow * Fix lints * wget toml-j0.4 type definitions * Add toml-j types workaround to eslint workflow * Apply formatter * Use @hoodmane/toml-j0.4 * Import from @hoodmane/toml-j0.4
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.
Thanks for the PR @hoodmane.
I've learned a bit of TS reviewing it, cool!
Most of my comments are questions of things that are not clear to me.
Once you rebase it it's good to me to merge.
@@ -163,15 +166,15 @@ const pyAttributeToEvent: Map<string, string> = new Map<string, string>([ | |||
]); | |||
|
|||
/** Initialize all elements with py-* handlers attributes */ | |||
export function initHandlers(interpreter: InterpreterClient) { | |||
export async function initHandlers(interpreter: InterpreterClient) { |
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.
Why are these now async?
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.
Sorry these changes are unrelated...
plugins: [terser()], | ||
}, | ||
], | ||
output: [{ minify: true }, { minify: false }].map(({ minify }) => ({ |
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.
Where do I pass the minify
argument to this? (in general, just because I don't really know what's calling this code)
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.
This needs to change because of #1298.
interpreter._remote.interface.FS.mkdirTree('/home/pyodide/pyscript'); | ||
interpreter._remote.interface.FS.writeFile('pyscript/__init__.py', pyscript); | ||
// Write pyscript package into file system | ||
for (let dir of pyscript_package.dirs) { | 67ED
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 you think it makes sense to test this code?
Thanks for the review @marimeireles! |
Closed in favor of #1309. |
Followup to #1232. Closes #1226.
Use node to make a manifest of the src/python dir and then use terser to inject it into the bundle as a variable called pyscript_package. This means we need to always use the terser plugin even when not minifying. In the non-minify case, we disable terser minification and mangling and enable terser beautification. Note that we bundle mangled versions of many upstream npm dependencies, so even in debug/nonminified builds, these do not include symbol names.