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