{"id":13727367,"url":"https://github.com/meriyah/meriyah","last_synced_at":"2025-05-13T20:18:58.847Z","repository":{"id":39639604,"uuid":"185327227","full_name":"meriyah/meriyah","owner":"meriyah","description":"A 100% compliant, self-hosted javascript parser  - https://meriyah.github.io/meriyah","archived":false,"fork":false,"pushed_at":"2025-05-11T03:30:44.000Z","size":11357,"stargazers_count":1110,"open_issues_count":12,"forks_count":48,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-05-11T04:22:03.880Z","etag":null,"topics":["acorn","ast","ecmascript","esnext","estree","javascript","jsx","parser","parsing","performance","stability","tc39","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meriyah.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-07T05:32:23.000Z","updated_at":"2025-05-11T03:30:46.000Z","dependencies_parsed_at":"2023-01-30T06:46:11.888Z","dependency_job_id":"904b6577-2147-4939-8e46-ddd73deb20fb","html_url":"https://github.com/meriyah/meriyah","commit_stats":{"total_commits":704,"total_committers":24,"mean_commits":"29.333333333333332","dds":"0.47443181818181823","last_synced_commit":"8226a6088273eb8af03ae2da5273c58c5bf73566"},"previous_names":[],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meriyah%2Fmeriyah","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meriyah%2Fmeriyah/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meriyah%2Fmeriyah/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meriyah%2Fmeriyah/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meriyah","download_url":"https://codeload.github.com/meriyah/meriyah/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020659,"owners_count":22000757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acorn","ast","ecmascript","esnext","estree","javascript","jsx","parser","parsing","performance","stability","tc39","typescript"],"created_at":"2024-08-03T01:03:52.153Z","updated_at":"2025-05-13T20:18:58.840Z","avatar_url":"https://github.com/meriyah.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eMeriyah\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e 100% compliant, self-hosted javascript parser with high focus on both performance and stability. Stable and already used in production.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.npmjs.com/package/meriyah\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/meriyah.svg?style=flat-square\" alt=\"Meriyah NPM\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/meriyah/meriyah/actions/workflows/node.js.yml?query=branch%3Amain\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/meriyah/meriyah/node.js.yml?branch=main\u0026label=test\u0026style=flat-square\" alt=\"Node.js CI\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/meriyah/meriyah/blob/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/github/license/meriyah/meriyah.svg?style=flat-square\" alt=\"License\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n[Interactive Playground](https://meriyah.github.io/meriyah)\n[Benchmark](https://meriyah.github.io/meriyah/performance)\n\n## Features\n\n- Conforms to the standard ECMAScript® 2024 (ECMA-262 15th Edition) language specification\n  - See [RegExp support](#regexp-support)\n- Support some TC39 stage 3 proposals via option \"next\"\n- Support for additional ECMAScript features for Web Browsers (Annex B)\n- JSX support via option \"jsx\"\n- Does **NOT** support TypeScript or Flow syntax\n- Track syntactic node locations with option \"ranges\" or \"loc\"\n- Emits an ESTree-compatible abstract syntax tree\n- No backtracking\n- Low memory usage\n\n## ESNext Stage 3 features\n\n### Supported stage 3 features:\n\nThese features need to be enabled with the `next` option.\n\n- [Decorators](https://github.com/tc39/proposal-decorators)\n- [Import Attributes](https://github.com/tc39/proposal-import-attributes)\n- [JSON Modules](https://github.com/tc39/proposal-json-modules)\n\n### Not yet supported stage 3 features:\n\n- [Explicit resource management](https://github.com/tc39/proposal-explicit-resource-management)\n- [Source phase import](https://github.com/tc39/proposal-source-phase-imports)\n\n## RegExp support\n\nMeriyah doesn't parse RegExp internal syntax, ESTree spec didn't require internal structure of RegExp. Meriyah\ndoes use JavaScript runtime to validate the RegExp literal. That means Meriyah's RegExp support is only as good\nas JavaScript runtime's RegExp support.\n\nAs of May 2025, some latest RegExp features requires Node.js\u003e=24.\n\n- [RegExp modifiers](https://github.com/tc39/proposal-regexp-modifiers)\n- [RegExp duplicate named groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups)\n\nIn addition, RegExp v flag (unicodeSets) only works on Nodejs v20+ and latest browsers.\n\n## Installation\n\n```sh\nnpm install meriyah --save-dev\n```\n\n## API\n\nMeriyah generates `AST` according to [ESTree AST format](https://github.com/estree/estree), and can be used to perform [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program, and with `ES2015` and later a JavaScript program can be either [a script or a module](https://tc39.github.io/ecma262/index.html#sec-ecmascript-language-scripts-and-modules).\n\nThe `parse` method exposed by meriyah takes an optional `options` object which allows you to specify whether to parse in [`script`](https://tc39.github.io/ecma262/#sec-parse-script) mode (the default) or in [`module`](https://tc39.github.io/ecma262/#sec-parsemodule) mode.\n\n```js\n// There are also \"parseScript\" and \"parseModule\" exported.\nimport { parse } from 'meriyah';\nconst result = parse('let some = \"code\";', { ranges: true });\n```\n\nThe available options:\n\n```js\n{\n  // The flag to allow module code\n  module: false;\n\n  // The flag to enable stage 3 support (ESNext)\n  next: false;\n\n  // The flag to enable start, end offsets and range: [start, end] to each node\n  ranges: false;\n\n  // Enable web compatibility\n  webcompat: false;\n\n  // The flag to enable line/column location information to each node\n  loc: false;\n\n  // The flag to attach raw property to each literal and identifier node\n  raw: false;\n\n  // The flag to allow return in the global scope\n  globalReturn: false;\n\n  // The flag to enable implied strict mode\n  impliedStrict: false;\n\n  // Allows comment extraction. Accepts either a function or array\n  onComment: [];\n\n  // Allows detection of automatic semicolon insertion. Accepts a callback function that will be passed the character offset where the semicolon was inserted\n  onInsertedSemicolon: (pos) =\u003e {};\n\n  // Allows token extraction. Accepts either a function or array\n  onToken: [];\n\n  // Enable non-standard parenthesized expression node\n  preserveParens: false;\n\n  // Enable lexical binding and scope tracking\n  lexical: false;\n\n  // Adds a source attribute in every node’s loc object when the locations option is `true`\n  source: undefined; // Set to source: 'source-file.js'\n\n  // Enable React JSX parsing\n  jsx: false;\n}\n```\n\n### onComment and onToken\n\nIf an array is supplied, comments/tokens will be pushed to the array, the item in the array contains `start/end/range` information when ranges flag is true, it will also contain `loc` information when loc flag is true.\n\nIf a function callback is supplied, the signature must be\n\n```ts\ndeclare function onComment(type: string, value: string, start: number, end: number, loc: SourceLocation): void;\n\ndeclare function onToken(token: string, start: number, end: number, loc: SourceLocation): void;\n```\n\nNote the `start/end/loc` information are provided to the function callback regardless of the settings on ranges and loc flags. onComment callback has one extra argument `value: string` for the body string of the comment.\n\n### onInsertedSemicolon\n\nIf a function callback is supplied, the signature must be\n\n```ts\ndeclare function onInsertedSemicolon(position: number): void;\n```\n\n## Example usage\n\n```js\nimport { parseScript } from './meriyah';\n\nparseScript('({x: [y] = 0} = 1)');\n```\n\nThis will return when serialized in json:\n\n```js\n{\n    type: \"Program\",\n    sourceType: \"script\",\n    body: [\n        {\n            type: \"ExpressionStatement\",\n            expression: {\n                type: \"AssignmentExpression\",\n                left: {\n                    type: \"ObjectPattern\",\n                    properties: [\n                        {\n                            type: \"Property\",\n                            key: {\n                                type: \"Identifier\",\n                                name: \"x\"\n                            },\n                            value: {\n                                type: \"AssignmentPattern\",\n                                left: {\n                                    type: \"ArrayPattern\",\n                                    elements: [\n                                        {\n                                            \"type\": \"Identifier\",\n                                            \"name\": \"y\"\n                                        }\n                                    ]\n                                },\n                                right: {\n                                    type: \"Literal\",\n                                    value: 0\n                                }\n                            },\n                            kind: \"init\",\n                            computed: false,\n                            method: false,\n                            shorthand: false\n                        }\n                    ]\n                },\n                operator: \"=\",\n                right: {\n                    type: \"Literal\",\n                    value: 1\n                }\n            }\n        }\n    ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeriyah%2Fmeriyah","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeriyah%2Fmeriyah","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeriyah%2Fmeriyah/lists"}