fedwiki / wiki-server

Federated Wiki client and server in Node.js
Other
153 stars 35 forks source link

Use dynamic import expression to load plugin code #189

Open nrn opened 3 weeks ago

nrn commented 3 weeks ago

This lets plugins choose whether to be es modules or not at the package level.

Shockingly easy server change to allow es modules in server side plugin code. Import expressions have been available and stable in node since at least v12, but this won't work in very old versions. By default this will still load server side plugins as common js modules because it hard codes the .js file extension, to switch a plugin to esmodules add "type": "module" to the top level of its package.json

Related to, but not dependent on https://github.com/fedwiki/wiki-client/pull/320