{"id":16048924,"url":"https://github.com/devongovett/unplugin-parcel-macros","last_synced_at":"2025-05-15T22:11:58.599Z","repository":{"id":220247323,"uuid":"751143654","full_name":"devongovett/unplugin-parcel-macros","owner":"devongovett","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-28T19:40:47.000Z","size":173,"stargazers_count":228,"open_issues_count":6,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-09T10:39:06.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/devongovett.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}},"created_at":"2024-02-01T02:28:11.000Z","updated_at":"2025-05-03T19:39:27.000Z","dependencies_parsed_at":"2024-10-04T08:06:45.520Z","dependency_job_id":"c6faf862-5bec-4d46-8c0d-627ec6027089","html_url":"https://github.com/devongovett/unplugin-parcel-macros","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.045454545454545414","last_synced_commit":"8f7764ff4b1e3a31e69d5b3c79a9bb6c199f9b30"},"previous_names":["devongovett/unplugin-parcel-macros"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Funplugin-parcel-macros","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Funplugin-parcel-macros/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Funplugin-parcel-macros/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devongovett%2Funplugin-parcel-macros/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devongovett","download_url":"https://codeload.github.com/devongovett/unplugin-parcel-macros/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430331,"owners_count":22069909,"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":[],"created_at":"2024-10-09T00:11:17.386Z","updated_at":"2025-05-15T22:11:53.571Z","avatar_url":"https://github.com/devongovett.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# unplugin-parcel-macros\n\nAn [Unplugin](https://unplugin.vercel.app) that lets you use Parcel's [macro](https://parceljs.org/features/macros/) implementation in webpack, Vite, Rollup, esbuild, Next.js, and more.\n\nMacros are JavaScript functions that run at build time. The value returned by a macro is inlined into the bundle in place of the original function call. This allows you to generate constants, code, and even additional assets without any custom plugins.\n\nMacros are imported using an [import attribute](https://github.com/tc39/proposal-import-attributes) to indicate that they should run at build time rather than being bundled into the output. You can import any JavaScript or TypeScript module as a macro, including built-in Node modules and packages from npm.\n\n## Example\n\nThis example uses the [regexgen](https://github.com/devongovett/regexgen) library to generate an optimized regular expression from a set of strings at build time.\n\n```js\nimport regexgen from 'regexgen' with {type: 'macro'};\n\nconst regex = regexgen(['foobar', 'foobaz', 'foozap', 'fooza']);\nconsole.log(regex);\n```\n\nThis compiles to the following bundle:\n\n```js\nconsole.log(/foo(?:zap?|ba[rz])/);\n```\n\nAs you can see, the `regexgen` library has been completely compiled away, and we are left with a static regular expression!\n\n## Setup\n\n### webpack\n\n```js\n// webpack.config.js\nconst macros = require('unplugin-parcel-macros');\n\nmodule.exports = {\n  // ...\n  plugins: [\n    macros.webpack()\n  ]\n};\n```\n\n### Next.js\n\n```js\n// next.config.js\nconst macros = require('unplugin-parcel-macros');\n\n// Create a single instance of the plugin that's shared between server and client builds.\nlet plugin = macros.webpack();\n\nmodule.exports = {\n  webpack(config) {\n    config.plugins.push(plugin);\n    return config;\n  }\n};\n```\n\n### Vite\n\n```js\n// vite.config.js\nimport macros from 'unplugin-parcel-macros';\n\nexport default {\n  plugins: [\n    macros.vite()\n  ]\n};\n```\n\n### Rollup\n\n```js\n// rollup.config.js\nimport macros from 'unplugin-parcel-macros';\n\nexport default {\n  plugins: [\n    macros.rollup()\n  ]\n};\n```\n\n### Esbuild\n\n```js\nimport {build} from 'esbuild';\nimport macros from 'unplugin-parcel-macros';\n\nbuild({\n  plugins: [\n    macros.esbuild()\n  ]\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Funplugin-parcel-macros","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevongovett%2Funplugin-parcel-macros","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevongovett%2Funplugin-parcel-macros/lists"}