Skip to content

Commit

Permalink
Rename to importedBindings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Aug 15, 2020
1 parent 91e5756 commit bd39cd3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/02-javascript-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function build() {
// fileName: string, // the chunk file name
// implicitlyLoadedBefore: string[]; // entries that should only be loaded after this chunk
// imports: string[], // external modules imported statically by the chunk
// importSpecifiers: {[imported: string]: string[]} // list of imported bindings per dependency
// importedBindings: {[imported: string]: string[]} // imported bindings per dependency
// isDynamicEntry: boolean, // is this chunk a dynamic entry point
// isEntry: boolean, // is this chunk a static entry point
// isImplicitEntry: boolean, // should this chunk only be loaded after other chunks
Expand Down
2 changes: 1 addition & 1 deletion docs/05-plugin-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ Called at the end of `bundle.generate()` or immediately before the files are wri
fileName: string,
implicitlyLoadedBefore: string[],
imports: string[],
importSpecifiers: {[imported: string]: string[]},
importedBindings: {[imported: string]: string[]},
isDynamicEntry: boolean,
isEntry: boolean,
isImplicitEntry: boolean,
Expand Down
24 changes: 12 additions & 12 deletions src/Chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ export default class Chunk {
dynamicImports: Array.from(this.dynamicDependencies, getId),
fileName: this.id!,
implicitlyLoadedBefore: Array.from(this.implicitlyLoadedBefore, getId),
importedBindings: this.getImportedBindingsPerDependency(),
imports: Array.from(this.dependencies, getId),
importSpecifiers: this.getDependencyImportSpecifiers(),
map: undefined,
referencedFiles: this.getReferencedFiles()
});
Expand Down Expand Up @@ -1020,7 +1020,17 @@ export default class Chunk {
return { deconflictedDefault, deconflictedNamespace, dependencies };
}

private getDependencyImportSpecifiers(): { [imported: string]: string[] } {
private getFallbackChunkName(): string {
if (this.manualChunkAlias) {
return this.manualChunkAlias;
}
if (this.fileName) {
return getAliasName(this.fileName);
}
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
}

private getImportedBindingsPerDependency(): { [imported: string]: string[] } {
const importSpecifiers: { [imported: string]: string[] } = {};
for (const [dependency, declaration] of this.renderedDependencies!) {
const specifiers = new Set<string>();
Expand All @@ -1039,16 +1049,6 @@ export default class Chunk {
return importSpecifiers;
}

private getFallbackChunkName(): string {
if (this.manualChunkAlias) {
return this.manualChunkAlias;
}
if (this.fileName) {
return getAliasName(this.fileName);
}
return getAliasName(this.orderedModules[this.orderedModules.length - 1].id);
}

private getImportSpecifiers(): Map<Chunk | ExternalModule, ImportSpecifier[]> {
const { interop } = this.outputOptions;
const importsByDependency = new Map<Chunk | ExternalModule, ImportSpecifier[]>();
Expand Down
4 changes: 2 additions & 2 deletions src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,10 +683,10 @@ export interface RenderedChunk extends PreRenderedChunk {
dynamicImports: string[];
fileName: string;
implicitlyLoadedBefore: string[];
imports: string[];
importSpecifiers: {
importedBindings: {
[imported: string]: string[];
};
imports: string[];
map?: SourceMap;
referencedFiles: string[];
}
Expand Down
16 changes: 8 additions & 8 deletions test/misc/bundle-information.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ describe('The bundle object', () => {
'imports'
);
assert.deepEqual(
output.map(chunk => chunk.importSpecifiers),
output.map(chunk => chunk.importedBindings),
[
{ 'generated-shared-c4fdd061.js': ['u', 's'] },
{ 'generated-shared-c4fdd061.js': [] },
{}
],
'importSpecifiers'
'importedBindings'
);
assert.deepEqual(
output.map(chunk => chunk.dynamicImports),
Expand Down Expand Up @@ -175,9 +175,9 @@ describe('The bundle object', () => {
'imports'
);
assert.deepEqual(
output.map(chunk => chunk.importSpecifiers),
output.map(chunk => chunk.importedBindings),
[{ external1: ['bar', 'default'], external2: ['*'], external3: ['*'] }],
'importSpecifiers'
'importedBindings'
);
assert.deepEqual(
output.map(chunk => chunk.dynamicImports),
Expand Down Expand Up @@ -424,9 +424,9 @@ describe('The bundle object', () => {
'imports'
);
assert.deepEqual(
output.map(chunk => chunk.importSpecifiers),
output.map(chunk => chunk.importedBindings),
[{}],
'importSpecifiers'
'importedBindings'
);
assert.deepEqual(
output.map(chunk => chunk.dynamicImports),
Expand Down Expand Up @@ -506,9 +506,9 @@ console.log(other);Promise.all([import('./dynamic1'), import('./dynamic2')]).the
'imports'
);
assert.deepEqual(
output.map(chunk => chunk.importSpecifiers),
output.map(chunk => chunk.importedBindings),
[{ '_virtual/other': ['other'] }, {}, {}, {}],
'importSpecifiers'
'importedBindings'
);
assert.deepEqual(
output.map(chunk => chunk.exports),
Expand Down

0 comments on commit bd39cd3

Please sign in to comment.