Registry / devops / closure-calculate-chunks

closure-calculate-chunks

JSON →
library3.2.2jsnpmunverified

A utility to parse JavaScript files, resolve dependencies using Node module resolution, and produce Closure Compiler chunk and file definitions based on dynamic import split points. Version 3.2.2 is the current stable release, with irregular releases. It differs from other bundlers by directly targeting Google Closure Compiler's chunk API, supporting Closure-Library style goog.provide/goog.require dependencies, and providing a visualization mode for dependency graphs. It outputs JSON for use with closure-compiler --chunk and --js flags.

npm install closure-calculate-chunks
INSTALL
IMPORT
SIG · CLOSURE-CALCULATE-
C
closure-calculate-chunks
devopsjavascriptv3.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import calculateChunks from 'closure-calculate-chunks'
const calculateChunks = require('closure-calculate-chunks')
The package is ESM-only and does not support require() by default.
calculateChunks
import calculateChunks from 'closure-calculate-chunks'
import { calculateChunks } from 'closure-calculate-chunks'
The default export is a function; there is no named export 'calculateChunks'.
types
import type { Options } from 'closure-calculate-chunks'
TypeScript types are exported from a separate path; check package.json exports.

Shows building a chunk definition programmatically with all available options.

import calculateChunks from 'closure-calculate-chunks'; const result = await calculateChunks({ entrypoint: ['./src/js/entry.js'], manualEntrypoints: ['chunkName:./src/js/extra.js'], closureLibraryBaseJsPath: './node_modules/google-closure-library/closure/goog/base.js', depsFiles: ['./deps.js'], extraDeps: ['my.namespace:./src/ns.js'], packageJsonEntryNames: ['module', 'main'], namingStyle: 'entrypoint', namePrefix: '' }); console.log(JSON.stringify(result));
closure-calculate-chunks --version
Debug
Known issues
breakingVersion 3.x changed the output format of the CLI and programmatic API.
fix
Upgrade to 3.2.2 and adjust code to expect the new JSON structure with 'chunk' array containing strings, not objects.
affects: >=3.0.0
breakingRequires Node >=14.0.0 as of version 3.0.0.
fix
Update Node.js to 14 or later.
affects: >=3.0.0
breakingSwitched from CommonJS to ESM-only in version 3.0.0.
fix
Use import syntax instead of require(). For CommonJS projects, use dynamic import() or migrate to ESM.
affects: >=3.0.0
deprecatedThe --closure-library-base-js-path flag may be deprecated in future versions as Closure Library usage declines.
fix
Use --extra-deps for individual namespaces instead of relying on base.js.
affects: >=3.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/closure-calculate-chunks/index.js from /path/to/your.js not supported.
The package is ESM-only and cannot be required with CommonJS require().
fix
Use dynamic import('closure-calculate-chunks') or convert your project to ESM.
TypeError: calculateChunks is not a function
Importing as a named export instead of default export.
fix
Use: import calculateChunks from 'closure-calculate-chunks'
SyntaxError: Unexpected token 'export'
The package uses ESM syntax but your Node version is older than 12.22.
fix
Update Node to >=14.0.0.
Upgrade
Version history
3.2.2latest on npm
Audit
Dependencies
escaladerequiredUsed for directory climbing when resolving package.json files.
resolve-pkg-mapsrequiredUsed to resolve package exports maps.
get-tsconfigrequiredUsed to resolve TypeScript config files.
Agent activity
6 hits · last 30 days
node
4
Resources
closure-calculate-chunks — npm install closure-calculate-chunks · libregistry