File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 109
109
110
110
< py-script >
111
111
from pyodide import create_proxy, to_js
112
- from esm import d3
112
+ import d3
113
113
114
114
fruits = [
115
115
dict(name="🍊", count=21),
Original file line number Diff line number Diff line change @@ -247,8 +247,6 @@ export class PyScript extends HTMLElement {
247
247
}
248
248
249
249
protected async _register_esm ( pyodide : PyodideInterface ) : Promise < void > {
250
- const imports : { [ key : string ] : unknown } = { }
251
-
252
250
for ( const node of document . querySelectorAll ( "script[type='importmap']" ) ) {
253
251
const importmap = ( ( ) => {
254
252
try {
@@ -265,17 +263,19 @@ export class PyScript extends HTMLElement {
265
263
if ( typeof name != "string" || typeof url != "string" )
266
264
continue
267
265
266
+ let exports : object
268
267
try {
269
268
// XXX: pyodide doesn't like Module(), failing with
270
269
// "can't read 'name' of undefined" at import time
271
- imports [ name ] = { ...await import ( url ) }
270
+ exports = { ...await import ( url ) }
272
271
} catch {
273
- console . error ( `failed to fetch '${ url } ' for '${ name } '` )
272
+ console . warn ( `failed to fetch '${ url } ' for '${ name } '` )
273
+ continue
274
274
}
275
+
276
+ pyodide . registerJsModule ( name , exports )
275
277
}
276
278
}
277
-
278
- pyodide . registerJsModule ( "esm" , imports )
279
279
}
280
280
281
281
async evaluate ( ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments