Skip to content

Commit

Permalink
Merge pull request #1492 from stealjs/duplicate-import-error
Browse files Browse the repository at this point in the history
Include filename in duplicate import error message
  • Loading branch information
m-mujica authored Aug 1, 2019
2 parents 6e1659a + c09a6b7 commit 226625c
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 11 deletions.
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,8 @@ addStealExtension(function addTreeShaking(loader) {
}
var code = babel.transform(load.source, {
plugins: babelPlugins,
compact: false
compact: false,
filename: load && load.address
}).code;

// If everything is tree shaken still mark as ES6
Expand Down
3 changes: 2 additions & 1 deletion src/extension-tree-shaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ addStealExtension(function addTreeShaking(loader) {
}
var code = babel.transform(load.source, {
plugins: babelPlugins,
compact: false
compact: false,
filename: load && load.address
}).code;

// If everything is tree shaken still mark as ES6
Expand Down
3 changes: 2 additions & 1 deletion steal-with-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -7441,7 +7441,8 @@ addStealExtension(function addTreeShaking(loader) {
}
var code = babel.transform(load.source, {
plugins: babelPlugins,
compact: false
compact: false,
filename: load && load.address
}).code;

// If everything is tree shaken still mark as ES6
Expand Down
4 changes: 2 additions & 2 deletions steal-with-promises.production.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion steal.js
Original file line number Diff line number Diff line change
Expand Up @@ -6171,7 +6171,8 @@ addStealExtension(function addTreeShaking(loader) {
}
var code = babel.transform(load.source, {
plugins: babelPlugins,
compact: false
compact: false,
filename: load && load.address
}).code;

// If everything is tree shaken still mark as ES6
Expand Down
4 changes: 2 additions & 2 deletions steal.production.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions test/duplicate_import_warning/dev.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Duplicate Import Warning</title>
</head>
<body>
<script src="../../steal.js" config="./package.json!npm">
var done = window.parent.done;
var assert = window.parent.assert;

if (assert) {
steal
.import("~/dups")
.then(function resolved() {
assert.ok(false, "it should not resolve");
done();
})
.catch(function rejected(err) {
assert.notOk(
/unknown:/.test(err.message),
"error should include the filename"
);
assert.ok(
/dups.js/.test(err.message),
"error should include the filename"
);
done();
});
}
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions test/duplicate_import_warning/dups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import foo from "~/foo";
import foo from "~/foo";
1 change: 1 addition & 0 deletions test/duplicate_import_warning/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function foo() {}
5 changes: 5 additions & 0 deletions test/duplicate_import_warning/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "duplicate_imports",
"main": "dups.js",
"version": "0.0.1"
}
3 changes: 2 additions & 1 deletion test/steal-with-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -7441,7 +7441,8 @@ addStealExtension(function addTreeShaking(loader) {
}
var code = babel.transform(load.source, {
plugins: babelPlugins,
compact: false
compact: false,
filename: load && load.address
}).code;

// If everything is tree shaken still mark as ES6
Expand Down
4 changes: 2 additions & 2 deletions test/steal-with-promises.production.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ if (hasConsole) {
QUnit.test("No 'loaded twice' warnings when there is a loading error", function(assert){
makeIframe("load_module_twice_false_positive/on-error.html", assert);
});

QUnit.test("Duplicate import error should include filename", function(assert) {
makeIframe("duplicate_import_warning/dev.html", assert);
});
}

QUnit.test("can add implicit deps to ES and CJS modules", function(assert) {
Expand Down

0 comments on commit 226625c

Please sign in to comment.