standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 147 forks source link

Code is executed in require #921

Open ishaiavrahami opened 1 year ago

ishaiavrahami commented 1 year ago

Hello, i'm using the following code and it seems to execute the function in the import even though i haven't even called the function yet. Any reason for this behavior?

const _require = require("esm")(module);
try {
    let code = _require('test.js');
 } catch (error) {
        error ->   if (!params?.plugin_setup?.[params.propsP.fieldA]) {
                        ^ SyntaxError: Invalid or unexpected token
 }