Bit-Bundler Service

2.0.0 · abandoned · verified Tue Apr 21

bit-bundler-service is a standalone web service, currently at version 2.0.0, that exposes a GraphQL API for bundling JavaScript modules. It allows users to specify npm modules, optionally with versions, which are then bundled, minified, and provided with sourcemaps. Key goals for this experimental project included bundling GitHub projects, bundle splitting, Babel integration, and providing hypermedia responses and webhooks. The service offers a GraphQL interface to create and retrieve these bundles, aiming to simplify the module bundling process via an API. The project README indicates it's an experiment, suggesting a non-active release cadence and a focus on exploring GraphQL integration with bit-bundler rather than robust production deployment.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up and run the bit-bundler-service locally, then interact with its GraphQL API to create and retrieve a bundled JavaScript module. It shows how to pass module details to `createBundle` and then fetch the resulting bundle using its ID.

npm install # In the cloned bit-bundler-service directory

# Start the service with GraphiQL enabled for easy testing
DEBUG=true node index.js &

# Wait for the server to start, then make a GraphQL request
# (e.g., using curl or a GraphQL client like Insomnia/GraphiQL)

# Example GraphQL Query (save as createBundle.graphql):
// query bundler($modules: [Module]) {
//   bundler {
//     createBundle(modules: $modules)
//   }
// }

# Example GraphQL Variables (save as createBundleVariables.json):
// {
//   "modules": [
//     {
//       "name": "spromise",
//       "version": "^1.0.0"
//     },
//     {
//       "name": "lodash.get",
//       "version": "^4.4.2"
//     }
//   ]
// }

# Send the request to create a bundle
curl -X POST -H "Content-Type: application/json" \
  --data '{"query": "query bundler($modules: [Module]) { bundler { createBundle(modules: $modules) } }", "variables": { "modules": [ { "name": "spromise", "version": "^1.0.0" }, { "name": "lodash.get", "version": "^4.4.2" } ] } }' \
  http://localhost:4000/graphql

# The response will contain a bundle ID. Use it to retrieve the bundle:
# Assuming 'BUNDLE_ID' is the ID returned from createBundle (e.g., e91671086147d525a5887479b9ad6bfd02f0d1ad)
curl -X POST -H "Content-Type: application/json" \
  --data '{"query": "query getBundle { bundler { getBundle(id: \"e91671086147d525a5887479b9ad6bfd02f0d1ad\") { hash, bundle, sourcemap } } }"}' \
  http://localhost:4000/graphql

view raw JSON →