{"name":"oxc-parser","version":"0.102.0","keywords":["oxc","parser"],"author":{"name":"Boshen and oxc contributors"},"license":"MIT","_id":"oxc-parser@0.102.0","maintainers":[{"name":"boshen","email":"boshenc@gmail.com"}],"homepage":"https://oxc.rs","bugs":{"url":"https://github.com/oxc-project/oxc/issues"},"dist":{"shasum":"1a86a0b2e1c7a0a8280a0abde436afdbdcec770d","tarball":"http://registry-npm.ywwl.com/oxc-parser/download/oxc-parser-0.102.0.tgz","fileCount":30,"integrity":"sha512-xMiyHgr2FZsphQ12ZCsXRvSYzmKXCm1ejmyG4GDZIiKOmhyt5iKtWq0klOfFsEQ6jcgbwrUdwcCVYzr1F+h5og==","signatures":[{"sig":"MEQCIACoL+T4d4rdS82wrClIJ2gHV6/uCD7UyvPV+jaOhLlqAiBN2WlYwSsEMzvwlUG7hrLiJwUeW8zMdNAtXi4u5vQ8jA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/oxc-parser@0.102.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":1358396,"size":129908,"noattachment":false,"key":"/oxc-parser/-/oxc-parser-0.102.0.tgz"},"main":"src-js/index.js","napi":{"wasm":{"browser":{"fs":false}},"targets":["aarch64-apple-darwin","aarch64-linux-android","aarch64-pc-windows-msvc","aarch64-unknown-linux-gnu","aarch64-unknown-linux-musl","aarch64-unknown-linux-ohos","armv7-unknown-linux-gnueabihf","riscv64gc-unknown-linux-gnu","s390x-unknown-linux-gnu","wasm32-wasip1-threads","x86_64-apple-darwin","x86_64-pc-windows-msvc","x86_64-unknown-freebsd","x86_64-unknown-linux-gnu","x86_64-unknown-linux-musl"],"binaryName":"parser","packageName":"@oxc-parser/binding","dtsHeaderFile":"src-js/header.d.ts"},"type":"module","_from":"file:oxc-parser-0.102.0.tgz","types":"./src-js/index.d.ts","browser":"src-js/wasm.js","engines":{"node":"^20.19.0 || >=22.12.0"},"funding":{"url":"https://github.com/sponsors/Boshen"},"scripts":{"test":"tsc && pnpm run test-node run","bench":"vitest bench --run ./bench.bench.js","build":"pnpm run build-dev --features allocator --release","build-dev":"napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js","postbuild":"publint","test-node":"vitest --dir ./test","build-test":"pnpm run build-dev --profile coverage","build-wasi":"pnpm run build-dev --release --target wasm32-wasip1-threads","test-browser":"vitest -c vitest.config.browser.ts","build-npm-dir":"rm -rf npm-dir && napi create-npm-dirs --npm-dir npm-dir && pnpm napi artifacts --npm-dir npm-dir --output-dir src-js","postbuild-dev":"node scripts/patch.js","build-browser-bundle":"node scripts/build-browser-bundle.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a7f9443c-94dd-4d7b-8c41-26c4f78fae80"}},"_resolved":"/tmp/218b37a66e166c675d35b6c273a06da8/oxc-parser-0.102.0.tgz","_integrity":"sha512-xMiyHgr2FZsphQ12ZCsXRvSYzmKXCm1ejmyG4GDZIiKOmhyt5iKtWq0klOfFsEQ6jcgbwrUdwcCVYzr1F+h5og==","repository":{"url":"git+https://github.com/oxc-project/oxc.git","type":"git","directory":"napi/parser"},"_npmVersion":"11.6.4","description":"Oxc Parser Node API","directories":{},"_nodeVersion":"24.10.0","dependencies":{"@oxc-project/types":"^0.102.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"4.0.10","esbuild":"^0.25.0","tinypool":"^2.0.0","playwright":"^1.51.0","typescript":"5.9.3","@vitest/browser":"4.0.6","@napi-rs/wasm-runtime":"1.0.7","@codspeed/vitest-plugin":"^5.0.0","@vitest/browser-playwright":"4.0.6","@typescript-eslint/visitor-keys":"^8.44.0"},"optionalDependencies":{"@oxc-parser/binding-darwin-x64":"0.102.0","@oxc-parser/binding-freebsd-x64":"0.102.0","@oxc-parser/binding-wasm32-wasi":"0.102.0","@oxc-parser/binding-darwin-arm64":"0.102.0","@oxc-parser/binding-android-arm64":"0.102.0","@oxc-parser/binding-linux-x64-gnu":"0.102.0","@oxc-parser/binding-linux-x64-musl":"0.102.0","@oxc-parser/binding-win32-x64-msvc":"0.102.0","@oxc-parser/binding-linux-arm64-gnu":"0.102.0","@oxc-parser/binding-linux-s390x-gnu":"0.102.0","@oxc-parser/binding-linux-arm64-musl":"0.102.0","@oxc-parser/binding-win32-arm64-msvc":"0.102.0","@oxc-parser/binding-linux-riscv64-gnu":"0.102.0","@oxc-parser/binding-openharmony-arm64":"0.102.0","@oxc-parser/binding-linux-arm-gnueabihf":"0.102.0"},"_npmOperationalInternal":{"tmp":"tmp/oxc-parser_0.102.0_1765194785241_0.9198449939497471","host":"s3://npm-registry-packages-npm-production"},"readme":"# Oxc Parser\n\nSee [usage instructions](https://oxc.rs/docs/guide/usage/parser).\n\n## Features\n\n### Supports WASM\n\nSee https://stackblitz.com/edit/oxc-parser for usage example.\n\n### ESTree\n\nWhen parsing JS or JSX files, the AST returned is fully conformant with the\n[ESTree standard](https://github.com/estree/estree), the same as produced by\n[Acorn](https://npmx.dev/package/acorn).\n\nWhen parsing TypeScript, the AST conforms to [@typescript-eslint/typescript-estree](https://npmx.dev/package/@typescript-eslint/typescript-estree)'s TS-ESTree format.\n\nIf you need all ASTs in the same with-TS-properties format, use the `astType: 'ts'` option.\n\nThe only differences between Oxc's AST and ESTree / TS-ESTree are:\n\n- Support for Stage 3 [decorators](https://github.com/tc39/proposal-decorators).\n- Support for Stage 3 ECMA features [`import defer`](https://github.com/tc39/proposal-defer-import-eval)\n  and [`import source`](https://github.com/tc39/proposal-source-phase-imports).\n- In TS-ESTree AST, `import.defer(...)` and `import.source(...)` are represented as an `ImportExpression`\n  with `'defer'` or `'source'` in `phase` field (as in ESTree spec), where TS-ESLint represents these\n  as a `CallExpression` with `MetaProperty` as its `callee`.\n- Addition of a non-standard `hashbang` field to `Program`.\n\nThat aside, the AST should completely align with Acorn's ESTree AST or TS-ESLint's TS-ESTree.\nAny deviation would be considered a bug.\n\n### AST Types\n\n[@oxc-project/types](https://npmx.dev/package/@oxc-project/types) can be used. For example:\n\n```typescript\nimport { Statement } from \"@oxc-project/types\";\n```\n\n### Visitor\n\nAn AST visitor is provided. See example below.\n\nThis package also exports visitor keys which can be used with any other ESTree walker.\n\n```js\nimport { visitorKeys } from \"oxc-parser\";\n```\n\n### Fast Mode\n\nBy default, Oxc parser does not produce semantic errors where symbols and scopes are needed.\n\nTo enable semantic errors, apply the option `showSemanticErrors: true`.\n\nFor example,\n\n```js\nlet foo;\nlet foo;\n```\n\nDoes not produce any errors when `showSemanticErrors` is `false`, which is the default behavior.\n\nFast mode is best suited for parser plugins, where other parts of your build pipeline has already checked for errors.\n\nPlease note that turning off fast mode ​incurs​ a small performance overhead.\n\n### Returns ESM information.\n\nIt is likely that you are writing a parser plugin that requires ESM information.\n\nTo avoid walking the AST again, Oxc Parser returns ESM information directly.\n\nThis information can be used to rewrite import and exports with the help of [`magic-string`](https://npmx.dev/package/magic-string),\nwithout any AST manipulations.\n\n```ts\nexport interface EcmaScriptModule {\n  /**\n   * Has ESM syntax.\n   *\n   * i.e. `import` and `export` statements, and `import.meta`.\n   *\n   * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.\n   */\n  hasModuleSyntax: boolean;\n  /** Import statements */\n  staticImports: Array<StaticImport>;\n  /** Export statements */\n  staticExports: Array<StaticExport>;\n  /** Dynamic import expressions */\n  dynamicImports: Array<DynamicImport>;\n  /** Span positions of `import.meta` */\n  importMetas: Array<Span>;\n}\n```\n\n## API\n\n### Functions\n\n```typescript\n// Synchronous parsing\nparseSync(filename: string, sourceText: string, options?: ParserOptions): ParseResult\n\n// Asynchronous parsing\nparse(filename: string, sourceText: string, options?: ParserOptions): Promise<ParseResult>\n```\n\nUse `parseSync` for synchronous parsing. Use `parse` for asynchronous parsing, which can be beneficial in I/O-bound or concurrent scenarios, though it adds async overhead.\n\n### Example\n\n```javascript\nimport { parseSync, Visitor } from \"oxc-parser\";\n\nconst code = \"const url: String = /* 🤨 */ import.meta.url;\";\n\n// File extension is used to determine which dialect to parse source as.\nconst filename = \"test.tsx\";\n\nconst result = parseSync(filename, code);\n// Or use async version: const result = await parse(filename, code);\n\n// An array of errors, if any.\nconsole.log(result.errors);\n\n// AST and comments.\nconsole.log(result.program, result.comments);\n\n// ESM information - imports, exports, `import.meta`s.\nconsole.log(result.module);\n\n// Visit the AST\nconst visitations = [];\n\nconst visitor = new Visitor({\n  VariableDeclaration(decl) {\n    visitations.push(`enter ${decl.kind}`);\n  },\n  \"VariableDeclaration:exit\"(decl) {\n    visitations.push(`exit ${decl.kind}`);\n  },\n  Identifier(ident) {\n    visitations.push(ident.name);\n  },\n});\n\nvisitor.visit(result.program);\n\n// Logs: [ 'enter const', 'url', 'String', 'import', 'meta', 'url', 'exit const' ]\nconsole.log(visitations);\n```\n\n### Options\n\nAll options are optional.\n\n- `lang`: `'js'` | `'jsx'` | `'ts'` | `'tsx'`. Set language of source. If omitted, language is deduced from file extension.\n- `sourceType`: `'script'` | `'module'` | `'unambiguous'`. Set source type. Defaults to `'module'`.\n- `astType`: `'js'` | `'ts'`. Set to `'ts'` if you want ASTs of plain JS/JSX files to contain TypeScript-specific properties.\n- `range`: `true` | `false`. If `true`, AST nodes contain a `range` field. Defaults to `false`.\n- `preserveParens`: `true` | `false`. If `true`, parenthesized expressions are represented by (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` AST nodes. Defaults to `true`.\n- `showSemanticErrors`: `true` | `false`. If `true`, check file for semantic errors which parser does not otherwise emit e.g. `let x; let x;`. Has a small performance cost. Defaults to `false`.\n","publish_time":1765194785410,"_cnpm_publish_time":1765194785410,"dist-tags":{"latest":"0.159.0"}}