{"_id":"oxc-parser@0.159.0","bugs":"https://github.com/oxc-project/oxc/issues","dist":{"shasum":"cc3a6c830bb3e73503bd77597a3a39c2efcdd67b","tarball":"http://registry-npm.ywwl.com/oxc-parser/download/oxc-parser-0.159.0.tgz","fileCount":35,"integrity":"sha512-Z1OaHU1EeTtobDHlYOAijfCTZr13PpWs/ZvwbJHaz5zOHfV6fLSmYZwB6klE8cggz51syi8HmLikHju0orJr4g==","signatures":[{"sig":"MEQCIENKYr7SVLukS9MmFNQfdkl7L8LIr6XX/77wwxvoUENzAiBorJzS9ycmI7Z2fJtGwz+XOW86ruenULB9nVfKfEry+g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHNlXOaKMqgaJiPWgffYHGpzNpODTCkgHQ+usUcqMvWYAiEA40/pzWu6mQk3m+INlgJNw5Roabbswrh8Ws5JEBs+Iio="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/oxc-parser@0.159.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":3065291,"size":702416,"noattachment":false,"key":"/oxc-parser/-/oxc-parser-0.159.0.tgz"},"main":"src-js/index.js","name":"oxc-parser","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","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","author":"Boshen and oxc contributors","browser":"src-js/wasm.js","engines":{"node":"^20.19.0 || >=22.12.0"},"exports":{".":{"node":"./src-js/index.js","import":"./src-js/index.js","browser":"./src-js/wasm.js","default":"./src-js/index.js"},"./*":"./*","./wasm":{"types":"./parser.wasm32-wasip1.wasm.d.mts","default":"./parser.wasm32-wasip1.wasm"},"./src-js":"./src-js/index.js","./package":"./package.json","./workerd":{"types":"./parser.wasm32-wasip1.workerd.d.mts","default":"./parser.wasm32-wasip1.workerd.mjs"},"./wasm.wasm":{"types":"./parser.wasm32-wasip1.wasm.d.mts","default":"./parser.wasm32-wasip1.wasm"},"./src-js/wasm":"./src-js/wasm.js","./src-js/wrap":"./src-js/wrap.js","./src-js/index":"./src-js/index.js","./src-js/visit":"./src-js/visit/index.js","./src-js/bindings":"./src-js/bindings.js","./src-js/visit/index":"./src-js/visit/index.js","./src-js/visit/visitor":"./src-js/visit/visitor.js","./src-js/raw-transfer/lazy":"./src-js/raw-transfer/lazy.js","./src-js/raw-transfer/eager":"./src-js/raw-transfer/eager.js","./src-js/generated/constants":"./src-js/generated/constants.js","./src-js/generated/lazy/walk":"./src-js/generated/lazy/walk.js","./src-js/raw-transfer/common":"./src-js/raw-transfer/common.js","./src-js/generated/visit/keys":"./src-js/generated/visit/keys.js","./src-js/generated/visit/walk":"./src-js/generated/visit/walk.js","./src-js/raw-transfer/visitor":"./src-js/raw-transfer/visitor.js","./src-js/raw-transfer/supported":"./src-js/raw-transfer/supported.js","./src-js/generated/lazy/type_ids":"./src-js/generated/lazy/type_ids.js","./src-js/raw-transfer/node-array":"./src-js/raw-transfer/node-array.js","./src-js/generated/deserialize/js":"./src-js/generated/deserialize/js.js","./src-js/generated/deserialize/ts":"./src-js/generated/deserialize/ts.js","./src-js/generated/visit/type_ids":"./src-js/generated/visit/type_ids.js","./src-js/raw-transfer/lazy-common":"./src-js/raw-transfer/lazy-common.js","./src-js/generated/lazy/constructors":"./src-js/generated/lazy/constructors.js","./src-js/generated/deserialize/js_range":"./src-js/generated/deserialize/js_range.js","./src-js/generated/deserialize/ts_range":"./src-js/generated/deserialize/ts_range.js"},"funding":{"url":"https://github.com/sponsors/oxc-project"},"license":"MIT","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 --features tokens --profile coverage","build-wasi":"napi build --config-path napi.wasm.json --target wasm32-wasip1-threads --dts parser.wasi.d.cts --no-dts-header","build-wasm":"pnpm run build-wasm-dev --release","build-wasip1":"pnpm run build-wasip1-dev --release","test-browser":"vitest -c vitest.config.browser.ts","build-npm-dir":"rm -rf npm-dir && napi create-npm-dirs --config-path napi.wasm.json --npm-dir npm-dir && pnpm napi artifacts --config-path napi.wasm.json --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 --dts parser.wasi.d.cts --no-dts-header","build-wasip1-dev":"pnpm run build-dev --target wasm32-wasip1 --dts parser.wasip1.d.cts --no-dts-header","build-browser-bundle":"node scripts/build-browser-bundle.js"},"version":"0.159.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"a7f9443c-94dd-4d7b-8c41-26c4f78fae80"}},"homepage":"https://oxc.rs/docs/guide/usage/parser","keywords":["ast","estree","javascript","oxc","parser","typescript"],"repository":{"url":"git+https://github.com/oxc-project/oxc.git","type":"git","directory":"napi/parser"},"description":"Oxc Parser Node API","directories":{},"maintainers":[{"name":"boshen","email":"boshenc@gmail.com"}],"dependencies":{"@oxc-project/types":"^0.159.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"5.0.3","publint":"0.3.25","rolldown":"1.2.14","tinypool":"^2.0.0","playwright":"^1.51.0","@types/node":"26.6.6","@emnapi/core":"2.0.0-alpha.6","@napi-rs/cli":"3.10.8","@emnapi/runtime":"2.0.0-alpha.6","@vitest/browser":"5.0.3","@napi-rs/wasm-runtime":"1.2.5","@codspeed/vitest-plugin":"^6.0.0","@vitest/browser-playwright":"5.0.3","@typescript-eslint/visitor-keys":"^8.54.0"},"optionalDependencies":{"@oxc-parser/binding-darwin-x64":"0.159.0","@oxc-parser/binding-freebsd-x64":"0.159.0","@oxc-parser/binding-darwin-arm64":"0.159.0","@oxc-parser/binding-android-arm64":"0.159.0","@oxc-parser/binding-linux-x64-gnu":"0.159.0","@oxc-parser/binding-linux-x64-musl":"0.159.0","@oxc-parser/binding-win32-x64-msvc":"0.159.0","@oxc-parser/binding-linux-arm64-gnu":"0.159.0","@oxc-parser/binding-linux-ppc64-gnu":"0.159.0","@oxc-parser/binding-linux-s390x-gnu":"0.159.0","@oxc-parser/binding-win32-ia32-msvc":"0.159.0","@oxc-parser/binding-android-arm-eabi":"0.159.0","@oxc-parser/binding-linux-arm64-musl":"0.159.0","@oxc-parser/binding-win32-arm64-msvc":"0.159.0","@oxc-parser/binding-linux-riscv64-gnu":"0.159.0","@oxc-parser/binding-openharmony-arm64":"0.159.0","@oxc-parser/binding-linux-riscv64-musl":"0.159.0","@oxc-parser/binding-linux-arm-gnueabihf":"0.159.0","@oxc-parser/binding-linux-arm-musleabihf":"0.159.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/oxc-parser_0.159.0_1794836452011_0.20351394825753544"},"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 the Stage 3 ECMA feature [`import source`](https://github.com/tc39/proposal-source-phase-imports).\n- Addition of a non-standard `hashbang` field to `Program`.\n- Non-standard `ParenthesizedExpression` and `TSParenthesizedType` nodes when\n  `preserveParens` is enabled (the default). Set `preserveParens: false` to omit them.\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#### Property order\n\nESTree and TS-ESTree do not define an order for node properties. `oxc-parser` emits them in this\norder:\n\n1. `type`.\n2. Node-specific fields in Oxc's defined serialization order. Properties containing child nodes\n   have the same relative order as the entries in `visitorKeys[node.type]`.\n3. `start`, then `end`.\n4. `range`, when the `range` option is enabled.\n\n`visitorKeys` is an exported map from a node type to the properties containing that node's children,\nin traversal order. For example, `visitorKeys.ConditionalExpression` is\n`['test', 'consequent', 'alternate']`. This is not alphabetical order: walking `alternate` before\n`test` would not match the syntax or evaluation order of a conditional expression.\n\nFields omitted by the selected `astType` do not change the relative order of the remaining fields.\nA generic walker which recursively inspects `Object.keys(node)` therefore visits standard ESTree\nchildren in the same relative order as Oxc's `Visitor` and the exported `visitorKeys`.\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\nPrefer `parseSync` for most workloads. `parse` moves Rust parsing to a worker-pool thread,\nbut AST deserialization still runs synchronously on the calling thread and usually accounts\nfor most of the work. To parse multiple files in parallel, use `parseSync` in worker threads.\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'` | `'dts'`. Set language of source. If omitted, language is deduced from file extension.\n- `sourceType`: `'script'` | `'module'` | `'commonjs'` | `'unambiguous'`. Override the module kind. When both `sourceType` and `lang` are omitted, `.mjs` / `.mts` use module mode, `.cjs` / `.cts` use CommonJS mode, and `.js` / `.jsx` / `.ts` / `.tsx` use unambiguous mode. An explicit `lang` uses unambiguous mode, except `'dts'`, which uses module mode. An explicit `sourceType` takes precedence.\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":1794836452120,"_cnpm_publish_time":1794836452120,"dist-tags":{"latest":"0.159.0"}}