1 | export default class ExternalModule {
|
2 | constructor ( id ) {
|
3 | this.id = id;
|
4 | this.name = null;
|
5 |
|
6 | this.isExternal = true;
|
7 | this.importedByBundle = [];
|
8 |
|
9 | this.canonicalNames = {};
|
10 | this.suggestedNames = {};
|
11 |
|
12 | this.needsDefault = false;
|
13 | this.needsNamed = false;
|
14 | }
|
15 |
|
16 | getCanonicalName ( name ) {
|
17 | if ( name === 'default' ) {
|
18 | return this.needsNamed ? `${this.name}__default` : this.name;
|
19 | }
|
20 |
|
21 | if ( name === '*' ) {
|
22 | return this.name;
|
23 | }
|
24 |
|
25 |
|
26 | return `${this.name}.${name}`;
|
27 | }
|
28 |
|
29 | rename ( name, replacement ) {
|
30 | this.canonicalNames[ name ] = replacement;
|
31 | }
|
32 |
|
33 | suggestName ( exportName, suggestion ) {
|
34 | if ( !this.suggestedNames[ exportName ] ) {
|
35 | this.suggestedNames[ exportName ] = suggestion;
|
36 | }
|
37 | }
|
38 | }
|