Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@data-fair/catalogs-shared": "*",
"@data-fair/lib-express": "^1.22.5",
"@data-fair/lib-node": "^2.12.1",
"@data-fair/lib-node-registry": "^0.6.0",
"@data-fair/lib-node-registry": "^0.7.0",
"@data-fair/lib-utils": "^1.10.1",
"config": "^4.4.1",
"express": "^5.2.0",
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions shared/plugin-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { readFile, access } from 'node:fs/promises'
* type-stripping (main: "index.ts"). Callers must not hard-code an extension —
* read main and trust it. Defaults to "index.js" when main is absent.
*
* `cacheBust` appends a query string so the same module path can be re-imported
* fresh in the same process.
* No in-process cache busting is needed: @data-fair/lib-node-registry extracts a
* changed artefact into a content-versioned directory, so an updated plugin
* always resolves to a brand-new absolute path. That forces Node's ESM registry
* to reload the whole module graph (entry + siblings + bundled deps) — something
* a `?query` suffix on the entry point could never do.
*/
export const importPluginModule = async <T = unknown> (
pluginDir: string,
opts: { cacheBust?: boolean } = {}
pluginDir: string
): Promise<T> => {
const pkg = JSON.parse(await readFile(path.join(pluginDir, 'package.json'), 'utf8'))
const mainRel = typeof pkg.main === 'string' && pkg.main.length > 0 ? pkg.main : 'index.js'
Expand All @@ -23,6 +25,5 @@ export const importPluginModule = async <T = unknown> (
} catch {
throw new Error(`plugin entry point missing: ${mainAbs}`)
}
const url = opts.cacheBust ? `${mainAbs}?imported=${Date.now()}` : mainAbs
return (await import(url)) as T
return (await import(mainAbs)) as T
}
2 changes: 1 addition & 1 deletion worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@data-fair/catalogs-shared": "*",
"@data-fair/lib-node": "^2.12.1",
"@data-fair/lib-node-registry": "^0.6.0",
"@data-fair/lib-node-registry": "^0.7.0",
"config": "^4.4.1",
"debug": "^4.4.1",
"form-data": "^4.0.4",
Expand Down
Loading