Amend #1880 - Bootstrap pyscript module ASAP (#1888)

* bootstrap *pyscript* module ASAP as stdlib
  * improve the test to be sure `js.document` exists **before** our module is imported
This commit is contained in:
Andrea Giammarchi
2023-12-06 11:16:05 +01:00
committed by GitHub
parent 40e99abbdf
commit 96e671b55f
4 changed files with 114 additions and 45 deletions

View File

@@ -33,9 +33,13 @@ const write = (base, literal) => {
write(".", pyscript);
python.push("del _Path");
python.push("del _path");
python.push("del _os");
// in order to fix js.document in the Worker case
// we need to bootstrap pyscript module ASAP
python.push("import pyscript as _pyscript");
python.push(
...["_Path", "_path", "_os", "_pyscript"].map((ref) => `del ${ref}`),
);
python.push("\n");
export default python.join("\n");