Tokamak is an isomorphic self-bundling bundler (version 0.0.15) aimed at Node.js and browser environments. It converts all modules to CommonJS (CJS) format, deliberately deviating from the ESM trend. Key differentiators include support for CJS-only npm modules and easier automatic HMR isolation. Drawbacks include lack of ESM circular dependency support and export-by-value semantics (e.g., `export let` modifications are not propagated). The bundler runs a static analysis to build a require graph, then generates a dynamic require function for the browser. Actively maintained with irregular releases.
npm install tokamakVerified import paths — ran on the pinned version, not inferred.
Shows the bundle function being called with common options like entry, outDir, minify, and sourceMap.
Refactor circular dependencies to use CJS-compatible patterns or avoid cycles.
Use object-style exports (e.g., export const obj = { foo: 'bar' }) if mutation is needed.Upgrade Node.js to >=14.17.0.
Replace `preserveModules: true` with `outDir: './dist'`.
Install the missing module as a dependency or remove it from the `external` array.
Ensure all babel transforms are disabled or use Tokamak's default transform pipeline by not providing custom babel config.
Either install the dependency or add it to the `external` array and ensure it's available at runtime.
Set `target` to a suitable ECMAScript version (e.g., 'es2015') or ensure the input files are already in CJS format.