Giter Club home page Giter Club logo

Comments (7)

davideicardi avatar davideicardi commented on May 26, 2024 1

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.

b3nab avatar b3nab commented on May 26, 2024 1

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.

davideicardi avatar davideicardi commented on May 26, 2024 1

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:

  1. 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)
  2. Review PluginVm class to use the new vm.Module class (this is where we need to change most of the actual code). Essentially instead of using a vm.Script we should use a vm.Module ... with all the required changes.
  3. replace the current PluginManager.require with a PluginManager.importModule function that return a Promise (marked as async) and call the new PluginVm functions.

from live-plugin-manager.

mackie1311 avatar mackie1311 commented on May 26, 2024

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.

davideicardi avatar davideicardi commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.