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 @@ -23,7 +23,7 @@
"dependencies": {
"@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",
"@data-fair/processings-shared": "*",
"ajv": "^8.17.1",
Expand Down
2 changes: 1 addition & 1 deletion api/src/processings/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const prepareProcessing = async (processing: Processing) => {
// state is what the UI banner already shows for deleted plugins.
if (!processing.config) return
const { ensured } = await ensurePluginAndReadSchema(processing)
const plugin = await importPluginModule<{ prepare?: PrepareFunction }>(ensured.path, { cacheBust: true })
const plugin = await importPluginModule<{ prepare?: PrepareFunction }>(ensured.path)
if (!(plugin.prepare && typeof plugin.prepare === 'function')) return

// Decipher the actuals secrets if they are present
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.

12 changes: 5 additions & 7 deletions shared/plugin-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ import fs from 'fs-extra'
* type-stripping (main: "index.ts"). Either way, callers should not hard-code
* an extension — read main and trust it.
*
* `cacheBust` appends a query string so the same module path can be re-imported
* fresh in the same process (used by the API's `prepare` flow, which may run
* twice in one save).
* No cache-busting is needed: lib-node-registry (>=0.7.0) extracts each plugin
* version into its own directory, so an updated plugin resolves to a fresh URL
* and Node's module registry reloads the whole graph naturally.
*/
export const importPluginModule = async <T = unknown>(
pluginDir: string,
opts: { cacheBust?: boolean } = {}
pluginDir: string
): Promise<T> => {
const pkg = await fs.readJson(path.join(pluginDir, 'package.json'))
const mainRel = typeof pkg.main === 'string' && pkg.main.length > 0 ? pkg.main : 'index.js'
const mainAbs = path.resolve(pluginDir, mainRel)
if (!(await fs.pathExists(mainAbs))) {
throw new Error(`fichier source manquant : ${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/lib-node": "^2.12.1",
"@data-fair/lib-node-registry": "^0.6.0",
"@data-fair/lib-node-registry": "^0.7.0",
"@data-fair/processings-shared": "*",
"@mdi/js": "^7.4.47",
"axios": "^1.8.3",
Expand Down
Loading