Skip to content

Commit a6955b1

Browse files
committed
Merge branch 'main' into pys-19/allow_out_err_redirect
2 parents 392b948 + 6525faf commit a6955b1

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ To try PyScript, import the pyscript to your html page with:
1919
```
2020
At that point, you can then use PyScript components in your html page. PyScript currently implements the following elements:
2121

22-
* `<py-script>`: that can be used to define python code that is execute withing the web page. The element itself is not rendered to the page and only used to add logic
23-
* `<py-repl>`: creates a REPL component that is rendered to the page as a code editor and allows users to right code that can be executed
22+
* `<py-script>`: that can be used to define python code that is executable within the web page. The element itself is not rendered to the page and only used to add logic
23+
* `<py-repl>`: creates a REPL component that is rendered to the page as a code editor and allows users to write code that can be executed
2424

2525
Check out the `/examples` folder for more examples on how to use it, all you need to do is open them in Chrome.
2626

pyscriptjs/examples/d3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
<py-script>
111111
from pyodide import create_proxy, to_js
112-
from esm import d3
112+
import d3
113113

114114
fruits = [
115115
dict(name="🍊", count=21),

pyscriptjs/src/components/pyscript.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ export class PyScript extends BaseEvalElement {
215215
}
216216

217217
protected async _register_esm(pyodide: PyodideInterface): Promise<void> {
218-
const imports: {[key: string]: unknown} = {}
219-
220218
for (const node of document.querySelectorAll("script[type='importmap']")) {
221219
const importmap = (() => {
222220
try {
@@ -233,17 +231,19 @@ export class PyScript extends BaseEvalElement {
233231
if (typeof name != "string" || typeof url != "string")
234232
continue
235233

234+
let exports: object
236235
try {
237236
// XXX: pyodide doesn't like Module(), failing with
238237
// "can't read 'name' of undefined" at import time
239-
imports[name] = {...await import(url)}
238+
exports = {...await import(url)}
240239
} catch {
241-
console.error(`failed to fetch '${url}' for '${name}'`)
240+
console.warn(`failed to fetch '${url}' for '${name}'`)
241+
continue
242242
}
243+
244+
pyodide.registerJsModule(name, exports)
243245
}
244246
}
245-
246-
pyodide.registerJsModule("esm", imports)
247247
}
248248

249249
getSourceFromElement(): string {

0 commit comments

Comments
 (0)