{"id":14155536,"url":"https://github.com/alloc/nebu","last_synced_at":"2025-07-04T10:04:33.936Z","repository":{"id":57104972,"uuid":"134107688","full_name":"alloc/nebu","owner":"alloc","description":"Fast, extensible, statically typed, and light Javascript transformer 🌿","archived":false,"fork":false,"pushed_at":"2024-08-28T19:34:24.000Z","size":288,"stargazers_count":16,"open_issues_count":16,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-04T10:04:33.298Z","etag":null,"topics":["estree","extensible","javascript","magic-string","meriyah","transformer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/alloc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-05-20T00:23:06.000Z","updated_at":"2024-09-19T22:43:18.000Z","dependencies_parsed_at":"2024-01-16T22:19:05.663Z","dependency_job_id":"8b6aabbb-863a-4a8c-a9b2-1cd7a2b06603","html_url":"https://github.com/alloc/nebu","commit_stats":null,"previous_names":["aleclarson/nebu"],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/alloc/nebu","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fnebu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fnebu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fnebu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fnebu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alloc","download_url":"https://codeload.github.com/alloc/nebu/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alloc%2Fnebu/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263489674,"owners_count":23474526,"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":["estree","extensible","javascript","magic-string","meriyah","transformer"],"created_at":"2024-08-17T08:03:48.535Z","updated_at":"2025-07-04T10:04:33.916Z","avatar_url":"https://github.com/alloc.png","language":"TypeScript","funding_links":["https://paypal.me/alecdotbiz"],"categories":["javascript","TypeScript"],"sub_categories":[],"readme":"# nebu\n\n[![npm](https://img.shields.io/npm/v/nebu.svg)](https://www.npmjs.com/package/nebu)\n[![Code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/alecdotbiz)\n\nFast, extensible, statically typed, and light Javascript transformer. (pronounced `nee-boo`)\n\n**Why bother?** Nebu saves developers from the slow and heavy [Babel][1] compiler. Nebu skips AST-to-code generation, preferring simple string mutations, while keeping sourcemap support. This improves performance, preserves coding style, and makes plugins less clunky.\n\nIf you need to transpile ES6+ to ES5, use [Bublé][2] *after* using Nebu.\n\nIf you believe in Nebu's mission, consider building a Nebu plugin. The ecosystem is practically non-existent. It needs your help! 🤓\n\n**This is still experimental! Please report bugs and contribute if you can!** 🙂\n\n[1]: https://github.com/babel/babel\n[2]: https://github.com/Rich-Harris/buble\n\n\u0026nbsp;\n\n## Examples\n\nSee the `examples` folder for plugin examples.\n\nYou can test these examples like so:\n\n```sh\ngit clone https://github.com/alloc/nebu\ncd nebu \u0026\u0026 pnpm i\ncd examples \u0026\u0026 pnpm i\n./try nebu-strip-dev\n```\n\n\u0026nbsp;\n\n## Usage\n\n```js\nconst nebu = require('nebu');\n\nnebu.process(code, {\n  ast: {}, // use an existing ESTree object\n  plugins: [{\n    Identifier(node) {\n      if (node.name == 'foo') {\n        node.replace('bar')\n      }\n    }\n  }],\n})\n```\n\nThe `process` function traverses the AST depth-first, which means children are\nvisited before neighbors, and parents are visited before children.\n\nThe `process` function has the following options:\n- `ast?: object` pre-existing ESTree object\n- `state?: object` state passed to each visitor\n- `plugins: object[]` array of visitor maps\n- `filename?: string` path to the source code\n- `sourceMap?: boolean | \"inline\"` sourcemap type\n- `sourceMapTarget?: string` sourcemap path (relative to `filename`)\n- `generatedFile?: string` path to the generated code\n- `includeContent?: boolean` include source content in sourcemap\n- `jsx?: boolean` enable JSX parsing\n\nThe `plugins` array is required. Plugins are objects whose keys are ESTree node types and each value is a function that receives the node and shared state. The `plugins` array supports a plugin being wrapped in `{default: plugin}` for ESM interop.\n\nThe `state` object is useful when a plugin analyzes the structure of your code and needs to communicate this information back to you. Another use case is inter-visitor communication.\n\nThe `sourceMap` option defaults to false, so no sourcemap is generated. Setting `sourceMap` to `true` will generate a `SourceMap` object and return it as the `map` property of the result object. Setting `sourceMap` to `\"inline\"` will append a `//# sourceMappingURL` comment to the generated code.\n\nThe `includeContent` option defaults to true. You must explicitly specify `false` to exclude source content from the sourcemap.\n\n### Utilities\n\nThe `nebu/utils` module exports a few utility functions you may find useful when developing a plugin.\n\n```js\nimport { findParent } from 'nebu/utils'\n```\n\n## Node API\n\nEvery node (except the root node) has these properties:\n- `parent: Node` the nearest container node\n- `ref: string` the parent property that contains us\n\nNOTE: Methods that take a `code` argument do *not* validate it for syntax errors. So be careful!\n\n### isLiteral(type)\n\nCheck if `node.type` equals `\"Literal\"` and `typeof node.value` equals the given string.\n\n### toString()\n\nSlice the source code using `node.start` and `node.end` as boundaries.\n\nNOTE: This does *not* include mutations, so the return value is static.\n\n### process(state, plugins)\n\nProcess a node with a separate set of plugins.\n\nThe `state` argument is optional. You may pass null or only the plugins array if your plugins are stateless.\n\nAll changes are included in the result of `nebu.process`.\n\nThe return value is the processed node.\n\n### walk(prop, iter)\n\nCall the `iter` function for each child node that exists at the given property name. Before your function is called, the children have their `parent` and `ref` properties set accordingly. The `iter` argument is optional.\n\n### yield(resume)\n\nCall the `resume` function after all children have been traversed. No arguments are passed. This method may be called multiple times, and by any other node.\n\n### set(prop, code)\n\nUpdate some property of the node.\n\nProperties that typically equal a `Node` object or an array of `Node` objects should be compatible with this method.\n\nImproving the capability of this method is tracked by [#8](https://github.com/aleclarson/nebu/issues/8).\n\n### push(prop, code)\n\nAppend a string of code to an array of child nodes.\n\n### unshift(prop, code)\n\nPrepend a string of code to an array of child nodes.\n\n### splice(prop, index, n, code)\n\nLike `[].splice`, you can remove child nodes from an array, insert code at the given index, or both.\n\nThe `n` argument indicates the number of children to remove.\n\n### before(code)\n\nInsert code before the node.\n\nYou should append a line break to `code` if you want it on a separate line.\n\n### after(code)\n\nInsert code after the node.\n\nYou should prepend a line break to `code` if you want it on a separate line.\n\n### indent(depth)\n\nIncrease the node's indentation level.\n\nThe tab/space width is auto-detected.\n\nThe `depth` argument defaults to 1.\n\n### dedent(depth)\n\nDecrease the node's indentation level.\n\nThe tab/space width is auto-detected.\n\nThe `depth` argument defaults to 1.\n\n### replace(code)\n\nReplace the node with a string of code.\n\n### remove(prop)\n\nRemove some property of the node.\n\nWhen `prop` is undefined, remove the node entirely.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fnebu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falloc%2Fnebu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falloc%2Fnebu/lists"}