From 296c1c03bc36fa824f264427313291f78fb3bc15 Mon Sep 17 00:00:00 2001 From: Dmitry Sharabin Date: Wed, 10 Jun 2026 19:02:21 +0200 Subject: [PATCH] Let plugins supply their own static import() loader Plugins are loaded by URL, so import-map/bundler tooling can't trace their dependencies. load() now honors an optional `load` thunk on the registry entry (a static import()), falling back to URL loading for plugins known only by `base`. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/plugins.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins.js b/src/plugins.js index 517db76..7284ebe 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -29,7 +29,9 @@ export function load (id, def = registry[id]) { let plugin = (loaded[id] = {}); plugin.loading = pluginURL; - plugin.loadedJS = import(pluginURL).then(module => (plugin.module = module)); + // Use the entry's own static `import()` loader when present, so import-map/bundler + // tooling can trace the plugin's dependencies; otherwise resolve the file by URL. + plugin.loadedJS = (def.load?.() ?? import(pluginURL)).then(module => (plugin.module = module)); plugin.loaded = plugin.loadedJS.then(module => { if (!noCSS && module.hasCSS) { let pluginCSS = new URL(`${id}/plugin.css`, base);