{"id":22746140,"url":"https://github.com/rspack-contrib/prebundle","last_synced_at":"2025-04-10T04:56:53.439Z","repository":{"id":235957547,"uuid":"791197311","full_name":"rspack-contrib/prebundle","owner":"rspack-contrib","description":"Prebundle Node.js dependencies, output a single js file, a package.json file and the dts files.","archived":false,"fork":false,"pushed_at":"2025-04-01T05:38:17.000Z","size":257,"stargazers_count":25,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-03T03:09:10.015Z","etag":null,"topics":["dependencies","ncc","prebundle","webpack"],"latest_commit_sha":null,"homepage":"","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/rspack-contrib.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-04-24T09:13:58.000Z","updated_at":"2025-04-01T05:38:19.000Z","dependencies_parsed_at":"2024-04-25T04:31:50.985Z","dependency_job_id":"7c6cd271-d7e6-434a-8488-007cbed2c384","html_url":"https://github.com/rspack-contrib/prebundle","commit_stats":null,"previous_names":["rspack-contrib/prebundle"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Fprebundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Fprebundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Fprebundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspack-contrib%2Fprebundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspack-contrib","download_url":"https://codeload.github.com/rspack-contrib/prebundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161262,"owners_count":21057554,"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":["dependencies","ncc","prebundle","webpack"],"created_at":"2024-12-11T02:11:38.294Z","updated_at":"2025-04-10T04:56:53.431Z","avatar_url":"https://github.com/rspack-contrib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prebundle\n\nPrebundle Node.js dependencies, output a single js file, a package.json file and the dts files.\n\nBased on [ncc](https://github.com/vercel/ncc) and [rollup-plugin-dts](https://www.npmjs.com/package/rollup-plugin-dts).\n\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.com/package/prebundle\"\u003e\n   \u003cimg src=\"https://img.shields.io/npm/v/prebundle?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square\u0026colorA=564341\u0026colorB=EDED91\" alt=\"license\" /\u003e\n\u003c/p\u003e\n\n## Motivation\n\nPrebundle is used to:\n\n- Reduce dependencies of core packages, install faster.\n- Improve stability by locking the sub-dependency version .\n- Fix peer dependency warning of some packages.\n\n## Command\n\nRun following command to prebundle all dependencies:\n\n```bash\nnpx prebundle\n```\n\nRun following command to prebundle single dependencies:\n\n```bash\nnpx prebundle \u003cpkgName\u003e\n\n# For example, prebundle commander\nnpx prebundle commander\n```\n\n## Dependency Config\n\nSupported dependency config:\n\n### externals\n\nExternals to leave as requires of the build.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      externals: {\n        webpack: '../webpack',\n      },\n    },\n  ],\n};\n```\n\nYou can also configure `externals` for all packages like this:\n\n```ts\n// prebundle.config.mjs\nexport default {\n  externals: {\n    webpack: '../webpack',\n  },\n  dependencies: [{ name: 'foo' }, { name: 'foo' }],\n};\n```\n\n### dtsExternals\n\nExternals for dts.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      dtsExternals: ['webpack'],\n    },\n  ],\n};\n```\n\n### minify\n\nWhether to minify the code, default `false`.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      minify: false,\n    },\n  ],\n};\n```\n\n### packageJsonField\n\nCopy extra fields from original package.json to target package.json.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      packageJsonField: ['options'],\n    },\n  ],\n};\n```\n\nFollowing fields will be copied by default:\n\n- `name`\n- `author`\n- `version`\n- `funding`\n- `license`\n- `types`\n- `typing`\n- `typings`\n\n### beforeBundle\n\nCallback before bundle.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      beforeBundle(task) {\n        console.log('do something');\n      },\n    },\n  ],\n};\n```\n\n### emitFiles\n\nEmit extra entry files to map imports.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      emitFiles: [\n        {\n          path: 'foo.js',\n          content: `module.exports = require('./').foo;`,\n        },\n      ],\n    },\n  ],\n};\n```\n\n### ignoreDts\n\nIgnore the original .d.ts declaration file, then generate a fake .d.ts file.\n\nThis can be used to reduce file size for the packages that do not require type definitions, such as webpack plugin.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      ignoreDts: true,\n    },\n  ],\n};\n```\n\n### copyDts\n\nCopy all type definitions files rather than bundle them via `rollup-plugin-dts`.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [{ name: 'foo', copyDts: true }],\n};\n```\n\n### target\n\nTarget ECMAScript version, default `es2021`.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  dependencies: [\n    {\n      name: 'foo',\n      target: 'es2015',\n    },\n  ],\n};\n```\n\n### prettier\n\nWhether to prettier the code and strip comments, default `false`.\n\n```ts\n// prebundle.config.mjs\nexport default {\n  prettier: true,\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Fprebundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspack-contrib%2Fprebundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspack-contrib%2Fprebundle/lists"}