Comments (7)
Hi @mackie1311
I suspect that for now it is not possible to import ES6 module.
Probably using https://nodejs.org/api/vm.html#vm_class_vm_module we should be able to implement it, but nerver yet tried.
As usual any help is appreciated, otherwise I will try to work on that in the future.
from live-plugin-manager.
Ciao @davideicardi, I quote all words from @mackie1311 you have done really a good job.
I'm planning to use your package in some way to orchestate an extension manager for b3nab/deckpad. Probably you need to be aware that ESM now is getting traction and can be used without experimental flags at minimum Node.js 12.20, 14.14, or 16.0.
To understand more about the "Pure ESM" you can take a look at this discussion https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c.
If you want I could contribute to this package with a PR if I will find out a way. 😄
To help continue the discussion reagarding an improvement on live-plugin-manager interoperability with cjs and esm I will leave some interesting articles and links:
https://blog.logrocket.com/how-to-use-ecmascript-modules-with-node-js/
https://redfin.engineering/node-modules-at-war-why-commonjs-and-es-modules-cant-get-along-9617135eeca1
https://nodejs.org/api/esm.html
https://nodejs.org/api/esm.html#interoperability-with-commonjs
from live-plugin-manager.
I have done some investigation, and I can confirm that it should be possible to support ECMAScript Modules.
We should essentially use the vm.Module
class. See doc here.
But consider that as of today it is still marked as Experimental
.
I think that this will be a major release with no backward compatibility (or at least it can be difficult to be backward compatible...).
Here the steps that I think we should do to implement it:
- Implement live-plugin-manager as a module (this is required to allow to use live-plugin-manager as a module, but not stricly related to the ability to load modules)
- Review
PluginVm
class to use the newvm.Module
class (this is where we need to change most of the actual code). Essentially instead of using avm.Script
we should use avm.Module
... with all the required changes. - replace the current
PluginManager.require
with aPluginManager.importModule
function that return a Promise (marked as async) and call the newPluginVm
functions.
from live-plugin-manager.
Thanks, @davideicardi I will set aside some time to look into this as well but for now, using CommonJS format and everything works great! I Will keep you posted
from live-plugin-manager.
Thank you for the info @b3nab . I will try to investigate on that. Pull requests are always welcome!
from live-plugin-manager.
Related Issues (20)
- 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead. HOT 3
- 0.14.1 -> 0.15.1 issue on 0.15.1 HOT 2
- no such file or directory, mkdir '/plugin_packages' HOT 4
- getInfo should load the package from disk HOT 2
- Proxy settings for NPM registry HOT 1
- Support loading plugins without FS access HOT 1
- fix: circular dependencies result in endless loop + out of memory crash HOT 3
- Plugin manager require gives module not found but passing the path directly works HOT 4
- Plugin manager gives an error requiring aws-sdk HOT 3
- sharp lib install failed HOT 2
- PluginManager.install is not compatible with NodeJS workers HOT 1
- Literal Object prototype is not working properly inside the plugin's context HOT 9
- Module not found: Can't resolve 'console' in React HOT 2
- Error: Invalid plugin github repository HOT 2
- Improper Error handling HOT 1
- PluginVm.getScopedInfo could not get the correct scope if it contains a dot HOT 1
- Handling modules with index.json entrypoints HOT 2
- FR: Support for `"exports"` in `package.json` HOT 1
- Error: Code generation from strings disallowed for this context HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from live-plugin-manager.