refactor(compiler): switch to acorn
This commit is contained in:
parent
9c9dd73017
commit
b33f0ceff1
@ -345,6 +345,6 @@ describe('compiler: expression transform', () => {
|
|||||||
test('should handle parse error', () => {
|
test('should handle parse error', () => {
|
||||||
const onError = jest.fn()
|
const onError = jest.fn()
|
||||||
parseWithExpressionTransform(`{{ a( }}`, { onError })
|
parseWithExpressionTransform(`{{ a( }}`, { onError })
|
||||||
expect(onError.mock.calls[0][0].message).toMatch(`Expected ')'`)
|
expect(onError.mock.calls[0][0].message).toMatch(`Unexpected token (1:4)`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-core#readme",
|
"homepage": "https://github.com/vuejs/vue/tree/dev/packages/compiler-core#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"acorn": "^7.1.0",
|
||||||
"estree-walker": "^0.8.1",
|
"estree-walker": "^0.8.1",
|
||||||
"meriyah": "^1.7.2",
|
|
||||||
"source-map": "^0.7.3"
|
"source-map": "^0.7.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
import { SourceLocation, Position, ElementNode, NodeTypes } from './ast'
|
import { SourceLocation, Position, ElementNode, NodeTypes } from './ast'
|
||||||
import { parseScript } from 'meriyah'
|
import { parse } from 'acorn'
|
||||||
import { walk } from 'estree-walker'
|
import { walk } from 'estree-walker'
|
||||||
|
|
||||||
// cache node requires
|
// cache node requires
|
||||||
// lazy require dependencies so that they don't end up in rollup's dep graph
|
// lazy require dependencies so that they don't end up in rollup's dep graph
|
||||||
// and thus can be tree-shaken in browser builds.
|
// and thus can be tree-shaken in browser builds.
|
||||||
let _parseScript: typeof parseScript
|
let _parse: typeof parse
|
||||||
let _walk: typeof walk
|
let _walk: typeof walk
|
||||||
|
|
||||||
export const parseJS: typeof parseScript = (code: string, options: any) => {
|
export const parseJS: typeof parse = (code: string, options: any) => {
|
||||||
assert(
|
assert(
|
||||||
!__BROWSER__,
|
!__BROWSER__,
|
||||||
`Expression AST analysis can only be performed in non-browser builds.`
|
`Expression AST analysis can only be performed in non-browser builds.`
|
||||||
)
|
)
|
||||||
const parse = _parseScript || (_parseScript = require('meriyah').parseScript)
|
const parse = _parse || (_parse = require('acorn').parse)
|
||||||
return parse(code, options)
|
return parse(code, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4780,11 +4780,6 @@ merge2@^1.2.3:
|
|||||||
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.4.tgz#c9269589e6885a60cf80605d9522d4b67ca646e3"
|
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.4.tgz#c9269589e6885a60cf80605d9522d4b67ca646e3"
|
||||||
integrity sha512-FYE8xI+6pjFOhokZu0We3S5NKCirLbCzSh2Usf3qEyr4X8U+0jNg9P8RZ4qz+V2UoECLVwSyzU3LxXBaLGtD3A==
|
integrity sha512-FYE8xI+6pjFOhokZu0We3S5NKCirLbCzSh2Usf3qEyr4X8U+0jNg9P8RZ4qz+V2UoECLVwSyzU3LxXBaLGtD3A==
|
||||||
|
|
||||||
meriyah@^1.7.2:
|
|
||||||
version "1.7.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/meriyah/-/meriyah-1.7.2.tgz#c47d07d8f1284577658827cd134b180e80ae4bef"
|
|
||||||
integrity sha512-bBXN6hJ9RHA0mEae5O2Ocr6giK0S87nsz/W7tnBRm4kpW04LEEpXSOfwaID9GZgPRVcn3rAHzHHDDD68DLQgWw==
|
|
||||||
|
|
||||||
micromatch@^3.1.10, micromatch@^3.1.4:
|
micromatch@^3.1.10, micromatch@^3.1.4:
|
||||||
version "3.1.10"
|
version "3.1.10"
|
||||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
|
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
|
||||||
|
Loading…
Reference in New Issue
Block a user