wip(ssr): remove cjs codegen mode
This commit is contained in:
		
							parent
							
								
									6a5ed49ea9
								
							
						
					
					
						commit
						ba263c909c
					
				@ -267,8 +267,8 @@ export function generate(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
 | 
					function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
 | 
				
			||||||
  const { mode, helper, prefixIdentifiers, push, newline } = context
 | 
					  const { ssr, helper, prefixIdentifiers, push, newline } = context
 | 
				
			||||||
  const VueBinding = mode === 'function' ? `Vue` : `require("vue")`
 | 
					  const VueBinding = ssr ? `require("vue")` : `Vue`
 | 
				
			||||||
  // Generate const declaration for helpers
 | 
					  // Generate const declaration for helpers
 | 
				
			||||||
  // In prefix mode, we place the const declaration at top so it's done
 | 
					  // In prefix mode, we place the const declaration at top so it's done
 | 
				
			||||||
  // only once; But if we not prefixing, we place the declaration inside the
 | 
					  // only once; But if we not prefixing, we place the declaration inside the
 | 
				
			||||||
@ -746,7 +746,7 @@ function genCacheExpression(node: CacheExpression, context: CodegenContext) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) {
 | 
					function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) {
 | 
				
			||||||
  const { push } = context
 | 
					  const { push, indent, deindent } = context
 | 
				
			||||||
  push('`')
 | 
					  push('`')
 | 
				
			||||||
  for (let i = 0; i < node.elements.length; i++) {
 | 
					  for (let i = 0; i < node.elements.length; i++) {
 | 
				
			||||||
    const e = node.elements[i]
 | 
					    const e = node.elements[i]
 | 
				
			||||||
@ -754,7 +754,9 @@ function genTemplateLiteral(node: TemplateLiteral, context: CodegenContext) {
 | 
				
			|||||||
      push(e.replace(/`/g, '\\`'))
 | 
					      push(e.replace(/`/g, '\\`'))
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      push('${')
 | 
					      push('${')
 | 
				
			||||||
 | 
					      indent()
 | 
				
			||||||
      genNode(e, context)
 | 
					      genNode(e, context)
 | 
				
			||||||
 | 
					      deindent()
 | 
				
			||||||
      push('}')
 | 
					      push('}')
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -60,10 +60,8 @@ export interface CodegenOptions {
 | 
				
			|||||||
  // - Function mode will generate a single `const { helpers... } = Vue`
 | 
					  // - Function mode will generate a single `const { helpers... } = Vue`
 | 
				
			||||||
  //   statement and return the render function. It is meant to be used with
 | 
					  //   statement and return the render function. It is meant to be used with
 | 
				
			||||||
  //   `new Function(code)()` to generate a render function at runtime.
 | 
					  //   `new Function(code)()` to generate a render function at runtime.
 | 
				
			||||||
  // - CommonJS mode is like function mode except it retrives helpers from
 | 
					 | 
				
			||||||
  //   `require('vue')`.
 | 
					 | 
				
			||||||
  // - Default: 'function'
 | 
					  // - Default: 'function'
 | 
				
			||||||
  mode?: 'module' | 'function' | 'cjs'
 | 
					  mode?: 'module' | 'function'
 | 
				
			||||||
  // Generate source map?
 | 
					  // Generate source map?
 | 
				
			||||||
  // - Default: false
 | 
					  // - Default: false
 | 
				
			||||||
  sourceMap?: boolean
 | 
					  sourceMap?: boolean
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,6 @@ export function compile(
 | 
				
			|||||||
  options: CompilerOptions = {}
 | 
					  options: CompilerOptions = {}
 | 
				
			||||||
): CodegenResult {
 | 
					): CodegenResult {
 | 
				
			||||||
  options = {
 | 
					  options = {
 | 
				
			||||||
    mode: 'cjs',
 | 
					 | 
				
			||||||
    ...options,
 | 
					    ...options,
 | 
				
			||||||
    // apply DOM-specific parsing options
 | 
					    // apply DOM-specific parsing options
 | 
				
			||||||
    ...parserOptions,
 | 
					    ...parserOptions,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user