Open shaunco opened 4 years ago
Looks like ncc transpiled:
class XMLSerializer {
constructor() {
return exports.setup(Object.create(new.target.prototype), globalObject, undefined);
}
In to:
class XMLSerializer {
constructor() {
return exports.setup(Object.create(/* unsupported import.meta.prototype */ undefined), globalObject, undefined);
}
Along with about 40 other spots in jsdom that ended up with /* unsupported import.meta.prototype */ undefined
.
Turns out it is the ImportMetaPlugin for WebPack that produced this: https://github.com/webpack/webpack/blob/8295202bc86b45b791c28215703f7ce4e2eac370/lib/dependencies/ImportMetaPlugin.js#L147
Is there any hope of fixing this on the NCC side, or should I report this issue against webpack?
I tried using webpack's new "external" flag that was added to work around similar issues with canvas and jsdom:
const path = require("path");
module.exports = {
target: "node",
externals: {
jsdom: "commonjs jsdom"
}
};
But it looks like ncc ignores the webpack.config.js (I tried purposely making it invalid and ncc still completes without error).
No luck via the node-loader route either.
I have the same problem when using the Vercel CLI (vercel dev
). When a Lambda function throws an exception, the stack trace is not shown because
Object.setPrototypeOf(this, new.target.prototype);
(github.com/vercel/fun/src/errors.ts#L15) is transpiled incorrectly to
Object.setPrototypeOf(this, /* unsupported import.meta.prototype */ undefined);
which prevents the stack trace from being printed in the terminal.
I'm experiencing the same thing with errors from simple-git
I have attached jsdom-ncc-issue.zip which reduces this issue to the smallest amount of code I could reproduce this in.
If you run:
and then visit http://localhost:8080 you will get a simple blue SVG square with a green outline.
If you run:
and then visit http://localhost:8080, you will get
NCC seems to be changing jsdom in some way which breaks XMLSerializer. I haven't been able to dig deep enough to provide any additional insight, but the sample project should at least make the issue reproducible.