Skip to content

Commit

Permalink
mor type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Dec 29, 2021
1 parent 1a6b965 commit 1b8eee5
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions browser/resolveId.ts
Expand Up @@ -13,9 +13,9 @@ export async function resolveId(
importer: string | undefined,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean | undefined,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null
) => Promise<ResolvedId | null>,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null,
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean
): Promise<ResolveIdResult> {
Expand Down
46 changes: 23 additions & 23 deletions src/Chunk.ts
Expand Up @@ -108,7 +108,7 @@ function getGlobalName(
globals: GlobalsOption,
hasExports: boolean,
warn: WarningHandler
) {
): string | undefined {
const globalName = typeof globals === 'function' ? globals(module.id) : globals[module.id];
if (globalName) {
return globalName;
Expand All @@ -126,7 +126,7 @@ function getGlobalName(
}

export default class Chunk {
entryModules: Module[] = [];
readonly entryModules: Module[] = [];
execIndex: number;
exportMode: 'none' | 'named' | 'default' = 'named';
facadeModule: Module | null = null;
Expand All @@ -136,27 +136,27 @@ export default class Chunk {
suggestedVariableName: string;
variableName = '';

private accessedGlobalsByScope = new Map<ChildScope, Set<string>>();
private readonly accessedGlobalsByScope = new Map<ChildScope, Set<string>>();
private dependencies = new Set<ExternalModule | Chunk>();
private dynamicDependencies = new Set<ExternalModule | Chunk>();
private dynamicEntryModules: Module[] = [];
private readonly dynamicDependencies = new Set<ExternalModule | Chunk>();
private readonly dynamicEntryModules: Module[] = [];
private dynamicName: string | null = null;
private exportNamesByVariable = new Map<Variable, string[]>();
private exports = new Set<Variable>();
private exportsByName: Record<string, Variable> = Object.create(null);
private readonly exportNamesByVariable = new Map<Variable, string[]>();
private readonly exports = new Set<Variable>();
private readonly exportsByName: Record<string, Variable> = Object.create(null);
private fileName: string | null = null;
private implicitEntryModules: Module[] = [];
private implicitlyLoadedBefore = new Set<Chunk>();
private imports = new Set<Variable>();
private readonly implicitlyLoadedBefore = new Set<Chunk>();
private readonly imports = new Set<Variable>();
private indentString: string = undefined as never;
private readonly isEmpty: boolean = true;
private isEmpty = true;
private name: string | null = null;
private renderedDependencies: Map<ExternalModule | Chunk, ModuleDeclarationDependency> | null =
null;
private renderedExports: ChunkExports | null = null;
private renderedHash: string = undefined as never;
private renderedModuleSources = new Map<Module, MagicString>();
private renderedModules: {
private renderedHash: string | undefined = undefined;
private readonly renderedModuleSources = new Map<Module, MagicString>();
private readonly renderedModules: {
[moduleId: string]: RenderedModule;
} = Object.create(null);
private renderedSource: MagicStringBundle | null = null;
Expand Down Expand Up @@ -251,7 +251,7 @@ export default class Chunk {
return chunk;
}

canModuleBeFacade(module: Module, exposedVariables: Set<Variable>): boolean {
canModuleBeFacade(module: Module, exposedVariables: ReadonlySet<Variable>): boolean {
const moduleExportNamesByVariable = module.getExportNamesByVariable();
for (const exposedVariable of this.exports) {
if (!moduleExportNamesByVariable.has(exposedVariable)) {
Expand Down Expand Up @@ -429,9 +429,9 @@ export default class Chunk {
preserveModulesRelativeDir: string,
options: NormalizedOutputOptions,
existingNames: Record<string, unknown>,
unsetOptions: Set<string>
unsetOptions: ReadonlySet<string>
): string {
const id = this.orderedModules[0].id;
const [{ id }] = this.orderedModules;
const sanitizedId = this.outputOptions.sanitizeFileName(id);
let path: string;

Expand Down Expand Up @@ -641,7 +641,7 @@ export default class Chunk {
this.renderedSource = magicString.trim();
}

this.renderedHash = undefined as never;
this.renderedHash = undefined;

if (this.isEmpty && this.getExportNames().length === 0 && this.dependencies.size === 0) {
const chunkName = this.getChunkName();
Expand Down Expand Up @@ -811,9 +811,9 @@ export default class Chunk {
}

private addDependenciesToChunk(
moduleDependencies: Set<Module | ExternalModule>,
moduleDependencies: ReadonlySet<Module | ExternalModule>,
chunkDependencies: Set<Chunk | ExternalModule>
) {
): void {
for (const module of moduleDependencies) {
if (module instanceof Module) {
const chunk = this.chunkByModule.get(module);
Expand All @@ -826,7 +826,7 @@ export default class Chunk {
}
}

private assignFacadeName({ fileName, name }: FacadeName, facadedModule: Module) {
private assignFacadeName({ fileName, name }: FacadeName, facadedModule: Module): void {
if (fileName) {
this.fileName = fileName;
} else {
Expand Down Expand Up @@ -870,7 +870,7 @@ export default class Chunk {
hash.update(
[addons.intro, addons.outro, addons.banner, addons.footer].map(addon => addon || '').join(':')
);
hash.update(options.format as string);
hash.update(options.format);
const dependenciesForHashing = new Set<Chunk | ExternalModule>([this]);
for (const current of dependenciesForHashing) {
if (current instanceof ExternalModule) {
Expand Down Expand Up @@ -1306,7 +1306,7 @@ export default class Chunk {
break;
}
}
const usedNames = new Set<string>(['Object', 'Promise']);
const usedNames = new Set(['Object', 'Promise']);
if (this.needsExportsShim) {
usedNames.add(MISSING_EXPORT_SHIM_VARIABLE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ModuleLoader.ts
Expand Up @@ -176,7 +176,7 @@ export class ModuleLoader {
importer: string | undefined,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean | undefined,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null = null
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null = null
): Promise<ResolvedId | null> => {
return this.addDefaultsToResolvedId(
this.getNormalizedResolvedIdWithoutDefaults(
Expand Down
12 changes: 6 additions & 6 deletions src/utils/PluginDriver.ts
Expand Up @@ -69,19 +69,19 @@ function throwInvalidHookError(hookName: string, pluginName: string) {
}

export class PluginDriver {
public emitFile: EmitFile;
public readonly emitFile: EmitFile;
public finaliseAssets: () => void;
public getFileName: (fileReferenceId: string) => string;
public setOutputBundle: (
public readonly setOutputBundle: (
outputBundle: OutputBundleWithPlaceholders,
outputOptions: NormalizedOutputOptions,
facadeChunkByModule: Map<Module, Chunk>
) => void;

private fileEmitter: FileEmitter;
private pluginCache: Record<string, SerializablePluginCache> | undefined;
private pluginContexts = new Map<Plugin, PluginContext>();
private plugins: Plugin[];
private readonly fileEmitter: FileEmitter;
private readonly pluginCache: Record<string, SerializablePluginCache> | undefined;
private readonly pluginContexts = new Map<Plugin, PluginContext>();
private readonly plugins: Plugin[];

constructor(
private readonly graph: Graph,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/commondir.ts
@@ -1,9 +1,9 @@
import * as path from './path';
import { dirname } from './path';

// ported from https://github.com/substack/node-commondir
export default function commondir(files: readonly string[]): string {
if (files.length === 0) return '/';
if (files.length === 1) return path.dirname(files[0]);
if (files.length === 1) return dirname(files[0]);
const commonSegments = files.slice(1).reduce((commonSegments, file) => {
const pathSegements = file.split(/\/+|\\+/);
let i;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/getOriginalLocation.ts
@@ -1,7 +1,7 @@
import { DecodedSourceMapOrMissing, ExistingDecodedSourceMap } from '../rollup/types';

export function getOriginalLocation(
sourcemapChain: DecodedSourceMapOrMissing[],
sourcemapChain: readonly DecodedSourceMapOrMissing[],
location: { column: number; line: number; name?: string; source?: string }
): { column: number; line: number } {
const filteredSourcemapChain = sourcemapChain.filter(
Expand Down
6 changes: 3 additions & 3 deletions src/utils/getStaticDependencies.ts
Expand Up @@ -4,8 +4,8 @@ import Module from '../Module';

export function getStaticDependencies(
chunk: Chunk,
orderedModules: Module[],
chunkByModule: Map<Module, Chunk>
orderedModules: readonly Module[],
chunkByModule: ReadonlyMap<Module, Chunk>
): Set<Chunk | ExternalModule> {
const staticDependencyBlocks: (Chunk | ExternalModule)[][] = [];
const handledDependencies = new Set<Module>();
Expand All @@ -31,7 +31,7 @@ function addStaticDependencies(
staticDependencies: (Chunk | ExternalModule)[],
handledModules: Set<Module>,
chunk: Chunk,
chunkByModule: Map<Module, Chunk>
chunkByModule: ReadonlyMap<Module, Chunk>
): void {
const dependencies = module.getDependenciesToBeIncluded();
for (const dependency of dependencies) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/resolveId.ts
Expand Up @@ -14,9 +14,9 @@ export async function resolveId(
importer: string | undefined,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean | undefined,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null
) => Promise<ResolvedId | null>,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null,
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean
): Promise<ResolveIdResult> {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/resolveIdViaPlugins.ts
Expand Up @@ -17,9 +17,9 @@ export function resolveIdViaPlugins(
importer: string | undefined,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean | undefined,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null
) => Promise<ResolvedId | null>,
skip: { importer: string | undefined; plugin: Plugin; source: string }[] | null,
skip: readonly { importer: string | undefined; plugin: Plugin; source: string }[] | null,
customOptions: CustomPluginOptions | undefined,
isEntry: boolean
): Promise<ResolveIdResult> {
Expand Down

0 comments on commit 1b8eee5

Please sign in to comment.