{"id":15701126,"url":"https://github.com/kettanaito/webpack-http-server","last_synced_at":"2025-10-04T06:41:54.943Z","repository":{"id":59161664,"uuid":"533830184","full_name":"kettanaito/webpack-http-server","owner":"kettanaito","description":"On-demand runtime webpack compilations over HTTP.","archived":false,"fork":false,"pushed_at":"2023-02-09T15:04:27.000Z","size":115,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T02:29:36.032Z","etag":null,"topics":["compiler","http","on-demand","runtime","webpack"],"latest_commit_sha":null,"homepage":"https://npm.im/webpack-http-server","language":"TypeScript","has_issues":false,"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/kettanaito.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}},"created_at":"2022-09-07T15:38:23.000Z","updated_at":"2023-09-08T18:37:35.000Z","dependencies_parsed_at":"2024-03-17T02:04:39.445Z","dependency_job_id":"dd624cf9-8ac9-4852-84d5-e8d9ac3d016b","html_url":"https://github.com/kettanaito/webpack-http-server","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/kettanaito/webpack-http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kettanaito%2Fwebpack-http-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kettanaito%2Fwebpack-http-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kettanaito%2Fwebpack-http-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kettanaito%2Fwebpack-http-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kettanaito","download_url":"https://codeload.github.com/kettanaito/webpack-http-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kettanaito%2Fwebpack-http-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260951294,"owners_count":23087661,"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":["compiler","http","on-demand","runtime","webpack"],"created_at":"2024-10-03T20:00:15.426Z","updated_at":"2025-10-04T06:41:49.925Z","avatar_url":"https://github.com/kettanaito.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-http-server\n\nOn-demand runtime webpack compilations over HTTP.\n\n## Overview\n\nThis package is, effectively, an Express server that exposes webpack compilations over HTTP. This means you can request to compile a module on runtime by dispatching a request like this:\n\n```\nPOST http://127.0.0.1:8080/compilation\nContent-Type: application/json\n\n{\"entry\":\"/Users/you/some/module.js\"}\n```\n\nThe server will respond you with the compilation info:\n\n```ts\n{\n  \"id\": \"COMPILATION_ID\",\n  \"previewUrl\": \"http://127.0.0.1/compilation/\"\n}\n```\n\nEach compilation request creates a unique compilation ID and `/compilations/:id` route to preview the runtime of the given module after it's compiled.\n\n## Motivation\n\nI've build this library because I'm a fan of example-driven testing. When I employ it on bigger projects, it means that every test I have has a runtime usage example alongside it. While I could compile those examples before tests, I chose to have a runtime compilation server instead. Here are my reasons:\n\n1. Compilation server guarantees up-to-date examples. I may forget to run `npm run build:examples` before running tests, which will yield irrelevant test results.\n1. Compilation server is more performant. By using the server and compiling only those examples that my current test run needs, I can save resources by skipping irrelevant examples.\n1. Compilation server creates a runtime. Even if I build examples before tests, I still need something to serve them. This server does that as well via compilation previews.\n\n### Why not `webpack-dev-server`?\n\nWebpack Dev Server is a great tool to run your compilation over HTTP. However, it's scoped to _a single compilation_. You cannot change the entrypoint for your dev server without having to stop it, modify the webpack config, and re-run the server. This is extremely time consuming and unreliable.\n\n## Getting started\n\n### Install\n\n```sh\nnpm install webpack-http-server\n```\n\n### Create a server\n\n```js\nimport { WebpackHttpServer } from 'webpack-http-server'\n\nconst server = new WebpackHttpServer()\nawait server.listen()\n\nconsole.log('Compilation server listening at \"%s\"', server.serverUrl)\n```\n\n\u003e The compilation server runs on a random vacant port. Rely on the `serverUrl` property to get its full address.\n\n### Request a compilation\n\nThere are two ways to request a compilation: HTTP request and Node.js API.\n\n#### HTTP request\n\n```js\nfetch(`${server.serverUrl}/compilation`, {\n  method: 'POST',\n  headers: {\n    'Content-Type': 'application/json',\n  },\n  body: JSON.stringify({\n    entry: '/Users/octocat/projects/demo/index.js',\n  }),\n})\n```\n\n#### Node.js API\n\n```js\nconst result = await server.compile(['/Users/octocat/projects/demo/index.js'])\nconsole.log('preview is running on \"%s\"', result.previewUrl)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkettanaito%2Fwebpack-http-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkettanaito%2Fwebpack-http-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkettanaito%2Fwebpack-http-server/lists"}