Skip to content

Commit

Permalink
enable strictModuleExceptionHandling (#529)
Browse files Browse the repository at this point in the history
* enable strictModuleExceptionHandling

Fixes #411

* coverage
  • Loading branch information
Janpot authored Apr 14, 2020
1 parent 9082d53 commit a3aef08
Show file tree
Hide file tree
Showing 24 changed files with 137 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dist/**/*.js
!test/integration/*.json
!test/integration/*.js
!test/integration/*.ts
!test/integration/include/
!test/integration/include/*.js
!test/integration/node-path
!test/integration/node-path/*.js
!test/unit
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ module.exports = (
path: "/",
// Webpack only emits sourcemaps for files ending in .js
filename: ext === '.cjs' ? filename + '.js' : filename,
libraryTarget: "commonjs2"
libraryTarget: "commonjs2",
strictModuleExceptionHandling: true
},
resolve: {
extensions: SUPPORTED_EXTENSIONS,
Expand Down
1 change: 1 addition & 0 deletions test/integration/include/throwing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error('kaboom')
14 changes: 14 additions & 0 deletions test/integration/strict-module-exception-handling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
try {
require('./include/throwing')
} catch (err) {}

let threw = false
try {
require('./include/throwing')
} catch (err) {
threw = true
}

if (!threw) {
process.exit(1)
}
8 changes: 7 additions & 1 deletion test/unit/externals/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/externals/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/minify/output-coverage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/unit/minify/output-coverage.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/unit/minify/output.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/unit/minify/output.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion test/unit/runtime-notfound/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/runtime-notfound/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/shebang/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/shebang/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/ts-decl/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/ts-decl/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/ts-exts/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/ts-exts/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/tsconfig-paths-allowjs/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/tsconfig-paths-allowjs/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/tsconfig-paths-conflicting-external/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/tsconfig-paths/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down
8 changes: 7 additions & 1 deletion test/unit/tsconfig-paths/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down

0 comments on commit a3aef08

Please sign in to comment.