Skip to content

Commit

Permalink
consistency: use arrow functions to pass 'this' context
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jan 23, 2022
1 parent fe7e0c4 commit e331522
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/Module.ts
Expand Up @@ -735,32 +735,36 @@ export default class Module {
timeStart('analyse ast', 3);

this.astContext = {
addDynamicImport: this.addDynamicImport.bind(this),
addExport: this.addExport.bind(this),
addImport: this.addImport.bind(this),
addImportMeta: this.addImportMeta.bind(this),
addDynamicImport: (node: ImportExpression): void => this.addDynamicImport(node),
addExport: (
node: ExportAllDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration
): void => this.addExport(node),
addImport: (node: ImportDeclaration): void => this.addImport(node),
addImportMeta: (node: MetaProperty): void => this.addImportMeta(node),
code, // Only needed for debugging
deoptimizationTracker: this.graph.deoptimizationTracker,
error: this.error.bind(this),
error: (props: RollupError, pos: number) => this.error(props, pos),
fileName, // Needed for warnings
getExports: this.getExports.bind(this),
getExports: () => this.getExports(),
getModuleExecIndex: () => this.execIndex,
getModuleName: this.basename.bind(this),
getModuleName: () => this.basename(),
getNodeConstructor: (name: string) => nodeConstructors[name] || nodeConstructors.UnknownNode,
getReexports: this.getReexports.bind(this),
getReexports: () => this.getReexports(),
importDescriptions: this.importDescriptions,
includeAllExports: () => this.includeAllExports(true),
includeDynamicImport: this.includeDynamicImport.bind(this),
includeVariableInModule: this.includeVariableInModule.bind(this),
includeDynamicImport: (node: ImportExpression) => this.includeDynamicImport(node),
includeVariableInModule: (variable: Variable) => this.includeVariableInModule(variable),
magicString: this.magicString,
module: this,
moduleContext: this.context,
options: this.options,
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
traceExport: this.getVariableForExportName.bind(this),
traceVariable: this.traceVariable.bind(this),
requestTreeshakingPass: () => {
this.graph.needsTreeshakingPass = true;
},
traceExport: (name: string) => this.getVariableForExportName(name),
traceVariable: (name: string) => this.traceVariable(name),
usesTopLevelAwait: false,
warn: this.warn.bind(this)
warn: (warning: RollupWarning, pos: number) => this.warn(warning, pos)
};

this.scope = new ModuleScope(this.graph.scope, this.astContext);
Expand Down

0 comments on commit e331522

Please sign in to comment.