davideicardi / live-plugin-manager

Plugin manager and installer for Node.JS
MIT License
242 stars 44 forks source link

Error: Code generation from strings disallowed for this context #83

Open qeelei opened 1 year ago

qeelei commented 1 year ago

I am trying to install and use the lodash package:

    const manager = new PluginManager()
    await manager.install('lodash')

    const _ = manager.require('lodash')
    console.log('defaults: ', _.defaults({ a: 1 }, { a: 3, b: 2 }))

But the following error is thrown:

Uncaught (in promise) Error: Code generation from strings disallowed for this context

This moment example works fine

https://github.com/davideicardi/live-plugin-manager#usage

davideicardi commented 1 year ago

You are running both examples using the same runtime? What If you try to run the unit tests?

qeelei commented 1 year ago

@davideicardi Yes it is in the same runtime. I am using the Electron framework, and these examples are running within a script called preload.

The following is the result after I execute npm run test

Screen Shot 2023-10-27 at 4 32 28 PM

And when I only install the packages without require, the error mentioned in my question is not thrown.

    const manager = new PluginManager()
    await manager.install('lodash')

    // const _ = manager.require('lodash')
    // console.log('defaults: ', _.defaults({ a: 1 }, { a: 3, b: 2 }))