{"id":27062227,"url":"https://github.com/facebook/prepack","last_synced_at":"2025-04-05T15:01:57.983Z","repository":{"id":20529188,"uuid":"45147841","full_name":"facebookarchive/prepack","owner":"facebookarchive","description":"A JavaScript bundle optimizer.","archived":true,"fork":false,"pushed_at":"2022-02-11T05:19:57.000Z","size":19054,"stargazers_count":14217,"open_issues_count":232,"forks_count":424,"subscribers_count":262,"default_branch":"main","last_synced_at":"2024-10-29T10:45:18.598Z","etag":null,"topics":["javascript","optimization"],"latest_commit_sha":null,"homepage":"http://prepack.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facebookarchive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-28T23:25:08.000Z","updated_at":"2024-10-29T05:28:49.000Z","dependencies_parsed_at":"2022-08-08T10:16:02.366Z","dependency_job_id":null,"html_url":"https://github.com/facebookarchive/prepack","commit_stats":null,"previous_names":["facebook/prepack"],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fprepack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fprepack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fprepack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facebookarchive%2Fprepack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facebookarchive","download_url":"https://codeload.github.com/facebookarchive/prepack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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":["javascript","optimization"],"created_at":"2025-04-05T15:01:57.766Z","updated_at":"2025-04-05T15:01:57.975Z","avatar_url":"https://github.com/facebookarchive.png","language":"JavaScript","readme":"# Prepack [![Circle CI](https://circleci.com/gh/facebook/prepack.png?style=shield\u0026circle-token=1109197a81e634fd06e162c25d309a420585acd5)](https://circleci.com/gh/facebook/prepack)\n\n\u003cimg src=\"assets/PrepackLogo.png\" width=150 align=right\u003e\n\nPrepack is a partial evaluator for JavaScript. Prepack rewrites a JavaScript bundle, resulting in JavaScript code that executes more efficiently.\nFor initialization-heavy code, Prepack works best in an environment where JavaScript parsing is effectively cached.\n\nSee the official [prepack.io](https://prepack.io) website for an introduction and an [interactive REPL playground](https://prepack.io/repl.html).\n\n## Status\n\n**We, the Prepack team at Facebook, have temporarily set down work on Prepack including the React compiler project. You won't see many Prepack PRs while we are currently prioritizing some other projects.**\n\n## How to use Prepack\n\nInstall the CLI via npm,\n\n```bash\n$ npm install -g prepack\n```\n\nOr if you prefer yarn, make sure you get yarn first,\n```bash\n$ npm install -g yarn\n```\nand then install the Prepack CLI via yarn:\n\n```bash\n$ yarn global add prepack\n```\nYou may need to `prepend` (pun intended!) the command with `sudo` in some cases.\n\n### Let the party begin\n\nTo compile a file and print the output to the console:\n\n```bash\n$ prepack script.js\n```\n\nIf you want to compile a file and output to another file:\n\n```bash\n$ prepack script.js --out script-processed.js\n```\n\nDetailed instructions and the API can be found at [Prepack CLI: Getting Started](https://prepack.io/getting-started.html)\n\n### Plugins to other tools\nThe following are a few plugins to other tools. They have been created and are maintained separately from Prepack itself. If you run into any issues with those plugins, please ask the plugin maintainers for support.\n\n- [A Rollup plugin for Prepack](https://www.npmjs.com/package/rollup-plugin-prepack)\n- [A Webpack plugin for Prepack](https://www.npmjs.com/package/prepack-webpack-plugin)\n- [A Parcel plugin for Prepack](https://www.npmjs.com/package/parcel-plugin-prepack)\n- [A Visual Studio code plugin for Prepack](https://marketplace.visualstudio.com/items?itemName=RobinMalfait.prepack-vscode)\n- [A babel plugin which transforms Flow annotations into prepack model declarations](https://www.npmjs.com/package/babel-plugin-flow-prepack).\n\n## Test Results and Code Coverage\n\n- [test262 status on master branch](https://circleci.com/api/v1/project/facebook/prepack/latest/artifacts/0/$CIRCLE_ARTIFACTS/test262-status.txt?branch=master)\n- [code coverage report for serialization tests](https://circleci.com/api/v1/project/facebook/prepack/latest/artifacts/0/$CIRCLE_ARTIFACTS/coverage-report-sourcemapped/index.html?branch=master)\n- To see the status for a pull request, look for the message *All checks have passed* or *All checks have failed*. Click on *Show all checks*, *Details*, *Artifacts*, and then *test262-status.txt* or *coverage-report-sourcemapped/index.html*.\n\n## How to get the code\n\n0. Clone repository and make it your current directory.\n1. `git submodule init`\n2. `git submodule update --init`\n3. Get yarn and node, then do\n   `yarn`\n\nNote: For development work you really need `yarn`, as many scripts require it.\n\n### How to build, lint, type check\n\n0. Get the code\n1. `yarn build`  \n   You can later run `yarn watch` in the background to just compile changed files on the fly.\n2. `yarn lint`\n3. `yarn flow`\n\n### How to run tests\n\n0. Get the code\n1. Make sure the code is built, either by running `yarn build` or `yarn watch`\n2. `yarn test`\n\nYou can run individual test suites as follows:\n- `yarn test-serializer`  \n  This tests the interpreter and serializer. All tests should pass.\n- `yarn test-test262`  \n  This tests conformance against the test262 suite. Not all will pass, increasing conformance is work in progress.\n\n## How to run the interpreter\n\n0. Get the code\n1. Make sure the code is built, either by running `yarn build` or `yarn watch`\n2. `yarn repl`  \n   This starts an interactive interpreter session.\n\n## How to run Prepack\n\n0. Get the code\n1. Make sure the code is built, either by running `yarn build` or `yarn watch`.\n2. Have a JavaScript file handy that you want to prepack, for example:  \n   `echo \"function hello() { return 'hello'; } function world() { return 'world'; } s = hello() + ' ' + world();\" \u003e/tmp/sample.js`\n\n3. `cat /tmp/sample.js | yarn prepack-cli`  \n   Try `--help` for more options.\n\n## How to validate changes\n\nInstead of building, linting, type checking, testing separately, the following does everything together:  \n`yarn validate`\n\n## How to edit the website\n\nThe content for [prepack.io](https://prepack.io) resides in the [website directory](https://github.com/facebook/prepack/tree/master/website) of this repository. To make changes, submit a pull request, just like for any code changes.\n\nIn order to run the website locally at [localhost:8000](http://localhost:8000):\n1. Build prepack into the website: `yarn build \u0026\u0026 mv prepack.min.js website/js`\n2. Run `python -m SimpleHTTPServer` (Python 2) or `python -m http.server` (Python 3) from the `website/` directory\n\n## How to contribute\n\nTo read more about the project, check out this [suggested reading wiki](https://github.com/facebook/prepack/wiki/Suggested-reading)\n\nFor more information about contributing pull requests and issues, see our [Contribution Guidelines](./CONTRIBUTING.md).\n\n## License\n\nPrepack is BSD-licensed. We also provide an additional patent grant.\n","funding_links":[],"categories":["JavaScript","打包工具","REPLs","底层相关","Tools"],"sub_categories":["Linting \u0026 Formatting:","React Components"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebook%2Fprepack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacebook%2Fprepack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacebook%2Fprepack/lists"}