mirror of https://github.com/lukechilds/rollup.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
671 B
33 lines
671 B
10 years ago
|
import { has } from './utils/object';
|
||
|
|
||
|
export default class ExternalModule {
|
||
|
constructor ( id ) {
|
||
|
this.id = id;
|
||
|
this.name = null;
|
||
|
|
||
|
this.isExternal = true;
|
||
|
this.importedByBundle = [];
|
||
|
|
||
|
this.canonicalNames = {};
|
||
|
this.defaultExportName = null;
|
||
|
}
|
||
|
|
||
|
getCanonicalName ( name ) {
|
||
|
if ( name === 'default' ) {
|
||
|
return `${this.name}__default`; // TODO...
|
||
|
}
|
||
|
|
||
|
// TODO this depends on the output format... works for CJS etc but not ES6
|
||
|
return `${this.name}.${name}`;
|
||
|
}
|
||
|
|
||
|
rename ( name, replacement ) {
|
||
|
this.canonicalNames[ name ] = replacement;
|
||
|
}
|
||
|
|
||
|
suggestDefaultName ( name ) {
|
||
|
if ( !this.defaultExportName ) {
|
||
|
this.defaultExportName = name;
|
||
|
}
|
||
|
}
|
||
|
}
|