Skip to content

Commit a3aef08

Browse files
authored
enable strictModuleExceptionHandling (#529)
* enable strictModuleExceptionHandling Fixes #411 * coverage
1 parent 9082d53 commit a3aef08

24 files changed

+137
-23
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ dist/**/*.js
88
!test/integration/*.json
99
!test/integration/*.js
1010
!test/integration/*.ts
11+
!test/integration/include/
12+
!test/integration/include/*.js
1113
!test/integration/node-path
1214
!test/integration/node-path/*.js
1315
!test/unit

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ module.exports = (
141141
path: "/",
142142
// Webpack only emits sourcemaps for files ending in .js
143143
filename: ext === '.cjs' ? filename + '.js' : filename,
144-
libraryTarget: "commonjs2"
144+
libraryTarget: "commonjs2",
145+
strictModuleExceptionHandling: true
145146
},
146147
resolve: {
147148
extensions: SUPPORTED_EXTENSIONS,

test/integration/include/throwing.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
throw new Error('kaboom')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
try {
2+
require('./include/throwing')
3+
} catch (err) {}
4+
5+
let threw = false
6+
try {
7+
require('./include/throwing')
8+
} catch (err) {
9+
threw = true
10+
}
11+
12+
if (!threw) {
13+
process.exit(1)
14+
}

test/unit/externals/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/externals/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/minify/output-coverage.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/minify/output-coverage.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/minify/output.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/minify/output.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/unit/runtime-notfound/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/runtime-notfound/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/shebang/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ module.exports =
2020
/******/ };
2121
/******/
2222
/******/ // Execute the module function
23-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
23+
/******/ var threw = true;
24+
/******/ try {
25+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
26+
/******/ threw = false;
27+
/******/ } finally {
28+
/******/ if(threw) delete installedModules[moduleId];
29+
/******/ }
2430
/******/
2531
/******/ // Flag the module as loaded
2632
/******/ module.l = true;

test/unit/shebang/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ module.exports =
2020
/******/ };
2121
/******/
2222
/******/ // Execute the module function
23-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
23+
/******/ var threw = true;
24+
/******/ try {
25+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
26+
/******/ threw = false;
27+
/******/ } finally {
28+
/******/ if(threw) delete installedModules[moduleId];
29+
/******/ }
2430
/******/
2531
/******/ // Flag the module as loaded
2632
/******/ module.l = true;

test/unit/ts-decl/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/ts-decl/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/ts-exts/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/ts-exts/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths-allowjs/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths-allowjs/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths-conflicting-external/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths-conflicting-external/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths/output-coverage.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

test/unit/tsconfig-paths/output.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;

0 commit comments

Comments
 (0)