refactor(compiler-vapor): remove source in codegen context

This commit is contained in:
三咲智子 Kevin Deng 2024-01-31 17:28:19 +08:00
parent 46e83e9681
commit 3817bbf134
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 5 additions and 4 deletions

View File

@ -29,7 +29,6 @@ export type CodeFragment =
export class CodegenContext { export class CodegenContext {
options: Required<CodegenOptions> options: Required<CodegenOptions>
source: string
code: CodeFragment[] code: CodeFragment[]
map?: SourceMapGenerator map?: SourceMapGenerator
@ -86,7 +85,10 @@ export class CodegenContext {
} }
genEffect?: (effects: IREffect[]) => CodeFragment[] genEffect?: (effects: IREffect[]) => CodeFragment[]
constructor(ir: RootIRNode, options: CodegenOptions) { constructor(
public ir: RootIRNode,
options: CodegenOptions,
) {
const defaultOptions = { const defaultOptions = {
mode: 'function', mode: 'function',
prefixIdentifiers: options.mode === 'module', prefixIdentifiers: options.mode === 'module',
@ -105,7 +107,6 @@ export class CodegenContext {
expressionPlugins: [], expressionPlugins: [],
} }
this.options = extend(defaultOptions, options) this.options = extend(defaultOptions, options)
this.source = ir.source
const [code, push] = buildCodeFragment() const [code, push] = buildCodeFragment()
this.code = code this.code = code
@ -117,7 +118,7 @@ export class CodegenContext {
if (!__BROWSER__ && sourceMap) { if (!__BROWSER__ && sourceMap) {
// lazy require source-map implementation, only in non-browser builds // lazy require source-map implementation, only in non-browser builds
this.map = new SourceMapGenerator() this.map = new SourceMapGenerator()
this.map.setSourceContent(filename, this.source) this.map.setSourceContent(filename, ir.source)
this.map._sources.add(filename) this.map._sources.add(filename)
} }
} }