Skip to content

Commit

Permalink
Export build time not found packages on runtime (#518)
Browse files Browse the repository at this point in the history
* Export build time not found packages on runtime

Exporting eval results

* test: add integration test for runtime-notfound
  • Loading branch information
legendecas authored Mar 23, 2020
1 parent 818848c commit 51aef03
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 15 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/node-path
!test/integration/node-path/*.js
!test/unit
!test/unit/**
!dist/
Expand Down
2 changes: 1 addition & 1 deletion src/@@notfound.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__non_webpack_require__('UNKNOWN');
module.exports = __non_webpack_require__('UNKNOWN');
1 change: 1 addition & 0 deletions test/integration/node-path/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'foo'
24 changes: 24 additions & 0 deletions test/integration/notfound-eval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const assert = require('assert');
const childProcess = require('child_process');
const path = require('path');

(function main() {
if (process.env.CHILD !== 'notfound-eval') {
const cp = childProcess.fork(__filename, [], {
stdio: 'inherit',
env: Object.assign({}, process.env, {
CHILD: 'notfound-eval',
NODE_PATH: path.join(process.cwd(), 'test/integration/node-path')
})
});
cp.on('exit', (code) => {
if (code == null) {
code = 1;
}
process.exit(code);
})
return;
}
const foo = require('foo');
assert.strictEqual(foo, 'foo');
})();
8 changes: 4 additions & 4 deletions test/unit/runtime-notfound/output-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ __webpack_require__(497);
/***/ }),

/***/ 464:
/***/ (function() {
/***/ (function(module) {

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


/***/ }),

/***/ 497:
/***/ (function() {
/***/ (function(module) {

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


/***/ })
Expand Down
8 changes: 4 additions & 4 deletions test/unit/runtime-notfound/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ __webpack_require__(695);
/***/ }),

/***/ 367:
/***/ (function() {
/***/ (function(module) {

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


/***/ }),

/***/ 695:
/***/ (function() {
/***/ (function(module) {

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


/***/ })
Expand Down
4 changes: 2 additions & 2 deletions test/unit/tsconfig-paths-allowjs/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ module.exports =
/******/ ({

/***/ 17:
/***/ (function() {
/***/ (function(module) {

eval("require")("@module");
module.exports = eval("require")("@module");


/***/ }),
Expand Down
4 changes: 2 additions & 2 deletions test/unit/tsconfig-paths-conflicting-external/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ module.exports =
/******/ ({

/***/ 17:
/***/ (function() {
/***/ (function(module) {

eval("require")("@module");
module.exports = eval("require")("@module");


/***/ }),
Expand Down
4 changes: 2 additions & 2 deletions test/unit/tsconfig-paths/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ module.exports =
/******/ ({

/***/ 17:
/***/ (function() {
/***/ (function(module) {

eval("require")("@module");
module.exports = eval("require")("@module");


/***/ }),
Expand Down

0 comments on commit 51aef03

Please sign in to comment.