Merge pull request #10424 from lcy930323/bugfix/missing_module_template

fix(template): Syntax error caused by runtime template
This commit is contained in:
Tobias Koppers 2020-02-26 08:35:53 +01:00 committed by GitHub
commit d0a33e41c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 1 deletions

View File

@ -137,7 +137,7 @@ class RuntimeTemplate {
* @returns {string} generated error IIFE
*/
missingModule({ request }) {
return `!(${this.throwMissingModuleErrorFunction({ request })}())`;
return `Object(${this.throwMissingModuleErrorFunction({ request })}())`;
}
/**

View File

@ -0,0 +1,3 @@
module.exports = [
[/Module not found/, /Can't resolve '\.\/someModule' /],
];

View File

@ -0,0 +1,11 @@
it("should have correct error code", function() {
try {
require("./module");
} catch(e) {
expect(e.code).toBe("MODULE_NOT_FOUND");
}
});

View File

@ -0,0 +1,3 @@
import { SomeClass } from "./someModule";
new SomeClass();