# durable-objects-webpack-commonjs **Repository Path**: mirrors_cloudflare/durable-objects-webpack-commonjs ## Basic Information - **Project Name**: durable-objects-webpack-commonjs - **Description**: Template for durable objects, webpack, commonjs - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-03-23 - **Last Updated**: 2026-03-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 👷 Durable Objects Counter template ## Note: You must use [wrangler](https://developers.cloudflare.com/workers/wrangler/get-started/#install) 2.0.0 or newer to use this template. ## Please read the [Durable Object documentation](https://developers.cloudflare.com/workers/learning/using-durable-objects) before using this template. A template for kick starting a Cloudflare Workers project using: - Durable Objects - Modules (commonjs modules to be specific) - Webpack - Wrangler Worker code is in `src/`. The Durable Object `Counter` class is in `src/counter.js`, and the eyeball script is in `index.js`. Webpack is configured to output a bundled CommonJS Module to `dist/index.js`. This project uses a shim ES module at `src/shim.mjs` that imports the commonjs bundle, and re-exports it. This is necessary because commonjs does not support named exports, and the only way to export a durable object class is using named exports. Once you have published the worker, you can interact with it as follows: ``` bash-3.2$ curl worker.your-account-name.workers.dev/ Select a Durable Object to contact by using the `name` URL query string parameter. e.g. ?name=A bash-3.2$ curl worker.your-account-name.workers.dev/?name=A Durable Object 'A' 0 is even bash-3.2$ curl worker.your-account-name.workers.dev/increment?name=A Durable Object 'A' 1 is odd bash-3.2$ curl worker.your-account-name.workers.dev/increment?name=A Durable Object 'A' 2 is even bash-3.2$ curl worker.your-account-name.workers.dev/decrement?name=A Durable Object 'A' 1 is odd ```