1
- import { registerTable } from "npm:@observablehq/duckdb" ;
2
1
import { FileAttachment , registerFile } from "npm:@observablehq/stdlib" ;
3
2
import { main , runtime , undefine } from "./main.js" ;
4
3
import { enableCopyButtons } from "./pre.js" ;
@@ -17,7 +16,7 @@ export function open({hash, eval: compile} = {}) {
17
16
send ( { type : "hello" , path : location . pathname , hash} ) ;
18
17
} ;
19
18
20
- socket . onmessage = ( event ) => {
19
+ socket . onmessage = async ( event ) => {
21
20
const message = JSON . parse ( event . data ) ;
22
21
console . info ( "↓" , message ) ;
23
22
switch ( message . type ) {
@@ -84,11 +83,14 @@ export function open({hash, eval: compile} = {}) {
84
83
for ( const file of message . files . added ) {
85
84
registerFile ( file . name , file ) ;
86
85
}
87
- for ( const name of message . tables . removed ) {
88
- registerTable ( name , null ) ;
89
- }
90
- for ( const table of message . tables . added ) {
91
- registerTable ( table . name , FileAttachment ( table . path ) ) ;
86
+ if ( message . tables . removed . length || message . tables . added . length ) {
87
+ const { registerTable} = await import ( "npm:@observablehq/duckdb" ) ;
88
+ for ( const name of message . tables . removed ) {
89
+ registerTable ( name , null ) ;
90
+ }
91
+ for ( const table of message . tables . added ) {
92
+ registerTable ( table . name , FileAttachment ( table . path ) ) ;
93
+ }
92
94
}
93
95
if ( message . tables . removed . length || message . tables . added . length ) {
94
96
const sql = main . _resolve ( "sql" ) ;
0 commit comments