wip: compileScriptSetup

This commit is contained in:
Evan You
2020-07-06 15:56:24 -04:00
parent 1ad3f975ed
commit 1359cc3a28
8 changed files with 252 additions and 14 deletions

View File

@@ -31,8 +31,8 @@
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme",
"dependencies": {
"@vue/shared": "3.0.0-beta.20",
"@babel/parser": "^7.8.6",
"@babel/types": "^7.8.6",
"@babel/parser": "^7.10.4",
"@babel/types": "^7.10.4",
"estree-walker": "^0.8.1",
"source-map": "^0.6.1"
}

View File

@@ -22,10 +22,15 @@ import {
parseJS,
walkJS
} from '../utils'
import { isGloballyWhitelisted, makeMap } from '@vue/shared'
import {
isGloballyWhitelisted,
makeMap,
babelParserDefautPlugins
} from '@vue/shared'
import { createCompilerError, ErrorCodes } from '../errors'
import { Node, Function, Identifier, ObjectProperty } from '@babel/types'
import { validateBrowserExpression } from '../validateExpression'
import { ParserPlugin } from '@babel/parser'
const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this')
@@ -127,12 +132,7 @@ export function processExpression(
ast = parseJS(source, {
plugins: [
...context.expressionPlugins,
// by default we enable proposals slated for ES2020.
// full list at https://babeljs.io/docs/en/next/babel-parser#plugins
// this will need to be updated as the spec moves forward.
'bigInt',
'optionalChaining',
'nullishCoalescingOperator'
...(babelParserDefautPlugins as ParserPlugin[])
]
}).program
} catch (e) {