{"id":37191510,"url":"https://github.com/hsiaosiyuan0/mole","last_synced_at":"2026-01-14T22:11:20.013Z","repository":{"id":57638088,"uuid":"394664922","full_name":"hsiaosiyuan0/mole","owner":"hsiaosiyuan0","description":"Mole is a collection of parsers to parse the frontend stuffs.","archived":false,"fork":false,"pushed_at":"2022-10-31T07:11:45.000Z","size":5111,"stargazers_count":24,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-21T05:02:46.526Z","etag":null,"topics":["ecmascript","go","lint","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hsiaosiyuan0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-10T13:29:03.000Z","updated_at":"2024-06-21T05:02:46.527Z","dependencies_parsed_at":"2023-01-20T16:30:48.439Z","dependency_job_id":null,"html_url":"https://github.com/hsiaosiyuan0/mole","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/hsiaosiyuan0/mole","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiaosiyuan0%2Fmole","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiaosiyuan0%2Fmole/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiaosiyuan0%2Fmole/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiaosiyuan0%2Fmole/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hsiaosiyuan0","download_url":"https://codeload.github.com/hsiaosiyuan0/mole/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hsiaosiyuan0%2Fmole/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["ecmascript","go","lint","parser"],"created_at":"2026-01-14T22:11:19.478Z","updated_at":"2026-01-14T22:11:20.005Z","avatar_url":"https://github.com/hsiaosiyuan0.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mole\n\nMole is a collection of parsers to parse the frontend stuffs.\n\n\u003cdetails\u003e\n  \u003csummary\u003eWhy Golang\u003c/summary\u003e\n\n~~A little bit explanation is good for why Golang is preferred in this project. Nowadays, a programming language is not only the grammar things, it's consist of runtime, stdlib, 3rd-party modules and a healthy community, all these are out-of-box by using Golang, more specifically:~~\n\n- ~~Golang is productive, its simplicity philosophy(something like Grammar and Garbage-collection) saves more time to the functionalities themselves.~~\n- ~~the functionalities like lint and bundle maybe needed to run as web services while Golang has been proved by many impressive projects such k8s that it's good at service things.~~\n\nFine, just all because I'm too fool to use a fancy language\n\n\u003c/details\u003e\n\n## Features\n\n- JavaScript Parser\n\n  - ECMAScript up to [ES2021](https://262.ecma-international.org/12.0/)\n  - [JSX](https://github.com/facebook/jsx)\n  - [ESTree](https://github.com/estree/estree) compatible outputs ([AST explorer on WASM](http://blog.thehardways.me/mole-is-more/#/))\n\n- TypeScript Parser\n\n  - Type information retained\n  - [babel/typescript](https://babeljs.io/docs/en/babel-types#typescript) compatible outputs\n\n### WIP\n\n- [ ] CSS parser\n- [ ] Less parser\n- [ ] Scss parser\n\n## Using the parser\n\nFor using the parser in Mole, the first step is using `go get` to add Mole as your project's dependency\n\n```bash\ngo get github.com/hsiaosiyuan0/mole\n\n# or using go get via a proxy if you have some network issues\nhttps_proxy=127.0.0.1:1080 go get github.com/hsiaosiyuan0/mole\n```\n\nAfter the installation is succeeded, below code can be used as a demo:\n\n\u003cdetails\u003e\n  \u003csummary\u003eClick to expand the demo\u003c/summary\u003e\n\n```go\npackage main\n\nimport (\n  \"bytes\"\n  \"encoding/json\"\n  \"fmt\"\n  \"log\"\n\n  \"github.com/hsiaosiyuan0/mole/ecma/estree\"\n  \"github.com/hsiaosiyuan0/mole/ecma/parser\"\n  \"github.com/hsiaosiyuan0/mole/span\"\n)\n\nfunc main() {\n  // imitate the source code you want to parse\n  code := `console.log(\"hello world\")`\n\n  // create a Source instance to handle to the source code\n  s := span.NewSource(\"\", code)\n\n  // create a parser, here we use the default options\n  opts := parser.NewParserOpts()\n  p := parser.NewParser(s, opts)\n\n  // inform the parser do its parsing process\n  ast, err := p.Prog()\n  if err != nil {\n    log.Fatal(err)\n  }\n\n  // by default the parsed AST is not the ESTree form because the latter has a little redundancy,\n  // however Mole supports to convert its AST to ESTree by using the `estree.ConvertProg` function\n  b, err := json.Marshal(estree.ConvertProg(ast.(*parser.Prog), estree.NewConvertCtx(p)))\n  if err != nil {\n    log.Fatal(err)\n  }\n\n  // below is nothing new, we just print the ESTree in JSON form\n  var out bytes.Buffer\n  json.Indent(\u0026out, b, \"\", \"  \")\n  fmt.Println(out.String())\n}\n```\n\nThe produced AST can be consumed by the ast-walker in Mole, more runnable demos see [mole-demo](https://github.com/hsiaosiyuan0/mole-demo)\n\n\u003c/details\u003e\n\n## Development\n\nSee [dev.md](/docs/dev.md) to get more information about how to start development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsiaosiyuan0%2Fmole","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsiaosiyuan0%2Fmole","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsiaosiyuan0%2Fmole/lists"}