Skip to content

Commit

Permalink
Merge branch 'master' into fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jan 26, 2022
2 parents cd505fc + f523f00 commit 5ed64c7
Show file tree
Hide file tree
Showing 34 changed files with 255 additions and 171 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,20 @@
# rollup changelog

## 2.66.1

_2022-01-25_

### Bug Fixes

- Only warn for conflicting names in namespace reexports if it actually causes problems (#4363)
- Only allow explicit exports or reexports as synthetic namespaces and hide them from namespace reexports (#4364)

### Pull Requests

- [#4362](https://github.com/rollup/rollup/pull/4362): refactor: convert exportsByName object to map (@lukastaegert)
- [#4363](https://github.com/rollup/rollup/pull/4363): Do not warn unnecessarily for namespace conflicts (@lukastaegert)
- [#4364](https://github.com/rollup/rollup/pull/4364): Do not expose synthetic namespace export in entries and namespaces (@lukastaegert)

## 2.66.0

_2022-01-22_
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup",
"version": "2.66.0",
"version": "2.66.1",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
Expand Down
30 changes: 12 additions & 18 deletions src/Chunk.ts
Expand Up @@ -143,7 +143,7 @@ export default class Chunk {
private dynamicName: string | null = null;
private readonly exportNamesByVariable = new Map<Variable, string[]>();
private readonly exports = new Set<Variable>();
private readonly exportsByName: Record<string, Variable> = Object.create(null);
private readonly exportsByName = new Map<string, Variable>();
private fileName: string | null = null;
private implicitEntryModules: Module[] = [];
private readonly implicitlyLoadedBefore = new Set<Chunk>();
Expand Down Expand Up @@ -295,7 +295,7 @@ export default class Chunk {
for (const [variable, exportNames] of exportNamesByVariable) {
this.exportNamesByVariable.set(variable, [...exportNames]);
for (const exportName of exportNames) {
this.exportsByName[exportName] = variable;
this.exportsByName.set(exportName, variable);
}
remainingExports.delete(variable);
}
Expand Down Expand Up @@ -503,15 +503,11 @@ export default class Chunk {
}

getChunkName(): string {
return (
this.name || (this.name = this.outputOptions.sanitizeFileName(this.getFallbackChunkName()))
);
return (this.name ??= this.outputOptions.sanitizeFileName(this.getFallbackChunkName()));
}

getExportNames(): string[] {
return (
this.sortedExportNames || (this.sortedExportNames = Object.keys(this.exportsByName).sort())
);
return (this.sortedExportNames ??= Array.from(this.exportsByName.keys()).sort());
}

getRenderedHash(): string {
Expand All @@ -533,7 +529,7 @@ export default class Chunk {
hash.update(
this.getExportNames()
.map(exportName => {
const variable = this.exportsByName[exportName];
const variable = this.exportsByName.get(exportName)!;
return `${relativeId((variable.module as Module).id).replace(/\\/g, '/')}:${
variable.name
}:${exportName}`;
Expand Down Expand Up @@ -741,13 +737,13 @@ export default class Chunk {
hasExports,
id: this.id,
indent: this.indentString,
intro: addons.intro!,
intro: addons.intro,
isEntryFacade:
this.outputOptions.preserveModules ||
(this.facadeModule !== null && this.facadeModule.info.isEntry),
isModuleFacade: this.facadeModule !== null,
namedExportsMode: this.exportMode !== 'default',
outro: addons.outro!,
outro: addons.outro,
snippets,
usesTopLevelAwait,
warn: this.inputOptions.onwarn
Expand Down Expand Up @@ -868,14 +864,12 @@ export default class Chunk {
existingNames: Record<string, unknown>
): string {
const hash = createHash();
hash.update(
[addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':')
);
hash.update([addons.intro, addons.outro, addons.banner, addons.footer].join(':'));
hash.update(options.format);
const dependenciesForHashing = new Set<Chunk | ExternalModule>([this]);
for (const current of dependenciesForHashing) {
if (current instanceof ExternalModule) {
hash.update(':' + current.renderPath);
hash.update(`:${current.renderPath}`);
} else {
hash.update(current.getRenderedHash());
hash.update(current.generateId(addons, options, existingNames, false));
Expand Down Expand Up @@ -1013,7 +1007,7 @@ export default class Chunk {
for (const exportName of this.getExportNames()) {
if (exportName[0] === '*') continue;

const variable = this.exportsByName[exportName];
const variable = this.exportsByName.get(exportName)!;
if (!(variable instanceof SyntheticNamedExportVariable)) {
const module = variable.module;
if (module && this.chunkByModule.get(module as Module) !== this) continue;
Expand Down Expand Up @@ -1171,7 +1165,7 @@ export default class Chunk {
dependency = this.modulesById.get(id) as ExternalModule;
imported = exportName = '*';
} else {
const variable = this.exportsByName[exportName];
const variable = this.exportsByName.get(exportName)!;
if (variable instanceof SyntheticNamedExportVariable) continue;
const module = variable.module!;
if (module instanceof Module) {
Expand Down Expand Up @@ -1287,7 +1281,7 @@ export default class Chunk {
}: NormalizedOutputOptions) {
const syntheticExports = new Set<SyntheticNamedExportVariable>();
for (const exportName of this.getExportNames()) {
const exportVariable = this.exportsByName[exportName];
const exportVariable = this.exportsByName.get(exportName)!;
if (
format !== 'es' &&
format !== 'system' &&
Expand Down
6 changes: 3 additions & 3 deletions src/ExternalModule.ts
Expand Up @@ -64,13 +64,13 @@ export default class ExternalModule {
};
}

getVariableForExportName(name: string): ExternalVariable {
getVariableForExportName(name: string): [variable: ExternalVariable] {
let declaration = this.declarations[name];
if (declaration) return declaration;
if (declaration) return [declaration];

this.declarations[name] = declaration = new ExternalVariable(this, name);
this.exportedVariables.set(declaration, name);
return declaration;
return [declaration];
}

setRenderPath(options: NormalizedOutputOptions, inputBase: string): string {
Expand Down
2 changes: 1 addition & 1 deletion src/Graph.ts
Expand Up @@ -243,7 +243,7 @@ export default class Graph {
for (const importDescription of Object.values(module.importDescriptions)) {
if (
importDescription.name !== '*' &&
!importDescription.module.getVariableForExportName(importDescription.name)
!importDescription.module.getVariableForExportName(importDescription.name)[0]
) {
module.warn(
{
Expand Down

0 comments on commit 5ed64c7

Please sign in to comment.