Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bundle-utils): switch to acorn #236

Merged
merged 2 commits into from Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/bundle-utils/package.json
Expand Up @@ -18,16 +18,18 @@
}
},
"dependencies": {
"@babel/parser": "^7.21.2",
"@babel/traverse": "^7.21.2",
"@intlify/message-compiler": "next",
"@intlify/shared": "next",
"acorn": "^8.8.2",
"esquery": "^1.5.0",
"estree-walker": "^2.0.2",
"jsonc-eslint-parser": "^1.0.1",
"source-map": "0.6.1",
"yaml-eslint-parser": "^0.3.2"
},
"devDependencies": {
"@babel/types": "^7.21.2"
"@types/esquery": "^1.0.2",
"@types/estree": "^1.0.0"
},
"engines": {
"node": ">= 12"
Expand Down
8 changes: 5 additions & 3 deletions packages/bundle-utils/src/codegen.ts
Expand Up @@ -28,6 +28,7 @@ export interface Position {
}

export interface SourceLocationable {
start?: number
loc?: {
start: Position
end: Position
Expand Down Expand Up @@ -96,9 +97,10 @@ export interface CodeGenerator {
/**
* @internal
*/
export interface CodeGenResult<ASTNode> {
export interface CodeGenResult<ASTNode, CodeGenError extends Error = Error> {
code: string
ast: ASTNode
errors?: CodeGenError[]
map?: RawSourceMap
}

Expand Down Expand Up @@ -131,8 +133,8 @@ export function createCodeGenerator(
name?: string
): void {
_context.code += code
if (_context.map) {
if (node && node.loc && node.loc !== LocationStub) {
if (_context.map && node) {
if (node.loc && node.loc !== LocationStub) {
addMapping(node.loc.start, name)
}
advancePositionWithSource(_context as Position, code)
Expand Down