Skip to content

Commit

Permalink
fix(bundle-utils): switch to acorn (#236)
Browse files Browse the repository at this point in the history
* fix(bundle-utils): switch to acorn

* estree-walker downgrade to 2.x
  • Loading branch information
kazupon committed Mar 9, 2023
1 parent db0aacd commit 381dbe2
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 633 deletions.
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

0 comments on commit 381dbe2

Please sign in to comment.