Closed sz3lbi closed 2 years ago
exports require(...)
Unfortunately, userscripts do not support modules.
Okay, thanks.
Fortunately, I already use the Webpack, so after removing the module from externals
in the Webpack config it just gets bundled with the script itself and I don't need to require any externals. Then the script code gets a lot longer, but everything works fine.
Expected Behavior
Working code of the required script.
Actual Behavior
TypeError
in the browser console. It occurs exactly in the line of the required script code. I don't even have to execute anything from the script. Actually, the error is not dependent of the requested script. It occurs in the attached case (typescript-json-serializer
) as well as in the case of importingreflect-metadata
and thenclass-transformer
. Then it shows the line of theclass-transformer
script code as the faulty one.In the Node.js with TypeScript there are no errors at all. Webpack compilation also goes smoothly and that's the step when the UserScript header is generated. Issues appear in the Tampermonkey and they are not dependent of the script code as the UserScript header is enough for them to occur.
Maybe I am doing something wrong? Thanks in advance for your tips.
Firefox:
Uncaught (in promise) TypeError: undefined is not a non-null object
Chromium:
Uncaught (in promise) TypeError: Object.defineProperty called on non-object
Specifications
Script