Skip to content

Commit

Permalink
Merge pull request #1493 from stealjs/1463-npm-import-warn-with-importer
Browse files Browse the repository at this point in the history
warn with the importer in case of missing module
  • Loading branch information
cherifGsoul authored Jan 15, 2019
2 parents 8c81c5a + 344bf2c commit 13b376b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions ext/npm-extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ exports.addExtension = function addNpmExtension(System){
"Is this an npm module not saved in your package.json?"
].join("\n"));
newError.statusCode = error.statusCode;
newError.stack = newError.stack + error.stack;
throw newError;
} else {
throw error;
Expand Down
2 changes: 1 addition & 1 deletion steal.production.js

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

2 changes: 2 additions & 0 deletions test/npm_nested_import_errors/dep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {};
require("~/foo");
22 changes: 22 additions & 0 deletions test/npm_nested_import_errors/dev.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
window.done = window.parent.done;
window.assert = window.parent.assert;
</script>
<script src="../../steal-with-promises.js"
config="package.json!npm"
main="@empty">
steal.import('~/main').then(null, function(err){
var stack = err.stack;
window.assert.ok(/dep.js/.test(stack), "dep.js is in the stack");
window.done();
})
</script>
</body>
</html>
3 changes: 3 additions & 0 deletions test/npm_nested_import_errors/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {};
require('~/dep');

5 changes: 5 additions & 0 deletions test/npm_nested_import_errors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "npm_nested_import_errors",
"main": "main.js",
"version": "1.0.0"
}
4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,7 @@ QUnit.test("dev bundle loads BEFORE configMain", function(assert) {
QUnit.test("When the dev-bundle is missing we get a nice message", function(assert){
makeIframe("dev_bundle_err/dev.html", assert);
});

QUnit.test("If a package is missing, warn which file imported it #1463", function(assert) {
makeIframe("npm_nested_import_errors/dev.html", assert);
})

0 comments on commit 13b376b

Please sign in to comment.