Skip to content

Commit 51aef03

Browse files
authored
Export build time not found packages on runtime (#518)
* Export build time not found packages on runtime Exporting eval results * test: add integration test for runtime-notfound
1 parent 818848c commit 51aef03

File tree

9 files changed

+42
-15
lines changed

9 files changed

+42
-15
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/node-path
12+
!test/integration/node-path/*.js
1113
!test/unit
1214
!test/unit/**
1315
!dist/

src/@@notfound.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__non_webpack_require__('UNKNOWN');
1+
module.exports = __non_webpack_require__('UNKNOWN');

test/integration/node-path/foo.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'foo'

test/integration/notfound-eval.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const assert = require('assert');
2+
const childProcess = require('child_process');
3+
const path = require('path');
4+
5+
(function main() {
6+
if (process.env.CHILD !== 'notfound-eval') {
7+
const cp = childProcess.fork(__filename, [], {
8+
stdio: 'inherit',
9+
env: Object.assign({}, process.env, {
10+
CHILD: 'notfound-eval',
11+
NODE_PATH: path.join(process.cwd(), 'test/integration/node-path')
12+
})
13+
});
14+
cp.on('exit', (code) => {
15+
if (code == null) {
16+
code = 1;
17+
}
18+
process.exit(code);
19+
})
20+
return;
21+
}
22+
const foo = require('foo');
23+
assert.strictEqual(foo, 'foo');
24+
})();

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ __webpack_require__(497);
5252
/***/ }),
5353

5454
/***/ 464:
55-
/***/ (function() {
55+
/***/ (function(module) {
5656

57-
eval("require")("./not-found.js");
57+
module.exports = eval("require")("./not-found.js");
5858

5959

6060
/***/ }),
6161

6262
/***/ 497:
63-
/***/ (function() {
63+
/***/ (function(module) {
6464

65-
eval("require")("./not-foud2.js");
65+
module.exports = eval("require")("./not-foud2.js");
6666

6767

6868
/***/ })

test/unit/runtime-notfound/output.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ __webpack_require__(695);
5252
/***/ }),
5353

5454
/***/ 367:
55-
/***/ (function() {
55+
/***/ (function(module) {
5656

57-
eval("require")("./not-found.js");
57+
module.exports = eval("require")("./not-found.js");
5858

5959

6060
/***/ }),
6161

6262
/***/ 695:
63-
/***/ (function() {
63+
/***/ (function(module) {
6464

65-
eval("require")("./not-foud2.js");
65+
module.exports = eval("require")("./not-foud2.js");
6666

6767

6868
/***/ })

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module.exports =
4444
/******/ ({
4545

4646
/***/ 17:
47-
/***/ (function() {
47+
/***/ (function(module) {
4848

49-
eval("require")("@module");
49+
module.exports = eval("require")("@module");
5050

5151

5252
/***/ }),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module.exports =
4444
/******/ ({
4545

4646
/***/ 17:
47-
/***/ (function() {
47+
/***/ (function(module) {
4848

49-
eval("require")("@module");
49+
module.exports = eval("require")("@module");
5050

5151

5252
/***/ }),

test/unit/tsconfig-paths/output.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module.exports =
4444
/******/ ({
4545

4646
/***/ 17:
47-
/***/ (function() {
47+
/***/ (function(module) {
4848

49-
eval("require")("@module");
49+
module.exports = eval("require")("@module");
5050

5151

5252
/***/ }),

0 commit comments

Comments
 (0)