{"name":"oxc-parser","version":"0.125.0","keywords":["ast","estree","javascript","oxc","parser","typescript"],"author":{"name":"Boshen and oxc contributors"},"license":"MIT","_id":"oxc-parser@0.125.0","maintainers":[{"name":"boshen","email":"boshenc@gmail.com"}],"homepage":"https://oxc.rs/docs/guide/usage/parser","bugs":{"url":"https://github.com/oxc-project/oxc/issues"},"dist":{"shasum":"50f6765d6540fd1178ac5d0dd979454d92add16b","tarball":"http://registry-npm.ywwl.com/oxc-parser/download/oxc-parser-0.125.0.tgz","fileCount":30,"integrity":"sha512-6M0gEDDVMGGy+Ckg/mlLh4PL87sfKRMlkQJTVTxdcEREwDa4usWjM9n4jC6Jxa5+nc3YlZTecUs4hHjoTVWKaw==","signatures":[{"sig":"MEUCIQC9vhMV/VOnKsUL/o8SqX3F/dz3d+HD2ikWqYX+JdpvTwIgUMyu/3OKm5fITq+yBTjfXdYSiBGAUtlxCqtb5Sbm+As=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/oxc-parser@0.125.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":1374309,"size":134229,"noattachment":false,"key":"/oxc-parser/-/oxc-parser-0.125.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-linux-androideabi","armv7-unknown-linux-gnueabihf","armv7-unknown-linux-musleabihf","i686-pc-windows-msvc","powerpc64le-unknown-linux-gnu","riscv64gc-unknown-linux-gnu","riscv64gc-unknown-linux-musl","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.125.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":"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":"napi build --target wasm32-wasip1-threads","build-wasm":"pnpm run build-wasm-dev --release","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-wasm-dev":"pnpm run build-dev --target wasm32-wasip1-threads","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/73a466eaea0f3719e61432b7dd572b13/oxc-parser-0.125.0.tgz","_integrity":"sha512-6M0gEDDVMGGy+Ckg/mlLh4PL87sfKRMlkQJTVTxdcEREwDa4usWjM9n4jC6Jxa5+nc3YlZTecUs4hHjoTVWKaw==","repository":{"url":"git+https://github.com/oxc-project/oxc.git","type":"git","directory":"napi/parser"},"_npmVersion":"11.12.1","description":"Oxc Parser Node API","directories":{},"_nodeVersion":"24.14.0","dependencies":{"@oxc-project/types":"^0.125.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"4.1.4","esbuild":"^0.28.0","publint":"0.3.18","tinypool":"^2.0.0","playwright":"^1.51.0","@types/node":"24.1.0","@napi-rs/cli":"3.6.1","@vitest/browser":"4.1.4","@napi-rs/wasm-runtime":"1.1.3","@codspeed/vitest-plugin":"^5.0.0","@vitest/browser-playwright":"4.1.4","@typescript-eslint/visitor-keys":"^8.54.0"},"optionalDependencies":{"@oxc-parser/binding-darwin-x64":"0.125.0","@oxc-parser/binding-freebsd-x64":"0.125.0","@oxc-parser/binding-wasm32-wasi":"0.125.0","@oxc-parser/binding-darwin-arm64":"0.125.0","@oxc-parser/binding-android-arm64":"0.125.0","@oxc-parser/binding-linux-x64-gnu":"0.125.0","@oxc-parser/binding-linux-x64-musl":"0.125.0","@oxc-parser/binding-win32-x64-msvc":"0.125.0","@oxc-parser/binding-linux-arm64-gnu":"0.125.0","@oxc-parser/binding-linux-ppc64-gnu":"0.125.0","@oxc-parser/binding-linux-s390x-gnu":"0.125.0","@oxc-parser/binding-win32-ia32-msvc":"0.125.0","@oxc-parser/binding-android-arm-eabi":"0.125.0","@oxc-parser/binding-linux-arm64-musl":"0.125.0","@oxc-parser/binding-win32-arm64-msvc":"0.125.0","@oxc-parser/binding-linux-riscv64-gnu":"0.125.0","@oxc-parser/binding-openharmony-arm64":"0.125.0","@oxc-parser/binding-linux-riscv64-musl":"0.125.0","@oxc-parser/binding-linux-arm-gnueabihf":"0.125.0","@oxc-parser/binding-linux-arm-musleabihf":"0.125.0"},"_npmOperationalInternal":{"tmp":"tmp/oxc-parser_0.125.0_1776076855649_0.643768537553904","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":1776076855804,"_cnpm_publish_time":1776076855804,"dist-tags":{"latest":"0.159.0"}}