Closed Chinlinlee closed 1 year ago
Support plugin that uses ESModule
"scriptType":"module"
bluelight/data/plugin.json
{ "plugin": [ {"path":"../scripts/plugin/esm-hello-world/index.js", "name": "esm-hello-world", "disableCatch": "true", "scriptType": "module"} ] }
"text/javascript"
esm-hello-world/hello-world-model.js
class HelloWorld { constructor() {} print() { console.log("hello world"); } }
export { HelloWorld };
- `esm-hello-world/index.js` ```js import { HelloWorld } from "./hello-world-model.js"; (() => { let helloWorld = new HelloWorld(); helloWorld.print(); })();
{ "plugin": [ {"path":"../scripts/plugin/oauth.js", "name": "oauth", "disableCatch": "true"}, {"path":"../scripts/plugin/mpr.js", "name": "MPR", "disableCatch": "true"}, {"path":"../scripts/plugin/vr.js", "name": "VR", "disableCatch": "true"}, {"path":"../scripts/plugin/xml_format.js", "name": "xml_format", "disableCatch": "true"}, {"path":"../scripts/plugin/graphic_annotation.js", "name": "graphic_annotation", "disableCatch": "true"}, {"path":"../scripts/plugin/rtss.js", "name": "rtss", "disableCatch": "true"}, {"path":"../scripts/plugin/seg.js", "name": "seg", "disableCatch": "true"}, {"path":"../scripts/plugin/esm-hello-world/index.js", "name": "esm-hello-world", "disableCatch": "true", "scriptType": "module"} ] }
{ "plugin": [ {"path":"../scripts/plugin/oauth.js", "name": "oauth", "disableCatch": "true"}, {"path":"../scripts/plugin/mpr.js", "name": "MPR", "disableCatch": "true"}, {"path":"../scripts/plugin/vr.js", "name": "VR", "disableCatch": "true"}, {"path":"../scripts/plugin/xml_format.js", "name": "xml_format", "disableCatch": "true"}, {"path":"../scripts/plugin/graphic_annotation.js", "name": "graphic_annotation", "disableCatch": "true"}, {"path":"../scripts/plugin/rtss.js", "name": "rtss", "disableCatch": "true"}, {"path":"../scripts/plugin/seg.js", "name": "seg", "disableCatch": "true"}, {"path":"../scripts/plugin/esm-hello-world/index.js", "name": "esm-hello-world", "disableCatch": "true"} ] }
70db479 this work has been merged to PR 24
Describe what this pull request is trying to achieve
Support plugin that uses ESModule
Additional notes and description of your changes
"scriptType":"module"
in config(bluelight/data/plugin.json
) when the plugin using ESMdoule"text/javascript"
when scriptType is not present in the configEnvironment this was tested in
test detail
esm-hello-world/hello-world-model.js
export { HelloWorld };
bluelight/data/plugin.json
"scriptType":"module"
in config