Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit 1bd38e7

Browse files
committed
example with anonymous exports
1 parent 0bfb57d commit 1bd38e7

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

example/example.html

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
});
1313
</script>
1414

15+
<script type="module" id="testmodule">
16+
export default class Foo {
17+
bar(){
18+
console.log("baz");
19+
}
20+
21+
}
22+
</script>
23+
<script type="module">
24+
import Foo from './testmodule';
25+
let foo = new Foo();
26+
foo.bar();
27+
</script>
1528
<script type="module">
1629
import fn from './es-module.js';
1730
console.log(fn);

src/browser-es-module-loader.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ if (typeof document != 'undefined' && document.getElementsByTagName) {
2727
}
2828
// anonymous modules supported via a custom naming scheme and registry
2929
else {
30-
var anonName = resolveIfNotPlain('./<anon' + ++anonCnt + '>', baseURI);
30+
var uri = './<anon' + ++anonCnt + '>';
31+
if (script.id !== ""){
32+
uri = "./" + script.id;
33+
}
34+
35+
var anonName = resolveIfNotPlain(uri, baseURI);
3136
anonSources[anonName] = script.innerHTML;
3237
loader.import(anonName);
3338
}

0 commit comments

Comments
 (0)