Registry / devops / lionel-commonjs-bundler

lionel-commonjs-bundler

JSON →
library1.1.1jsnpmunverified

Lionel CommonJS Bundler is a lightweight JavaScript module bundler designed to transform CommonJS modules into a single, browser-compatible JavaScript file. It is currently at version 1.1.1, with its last update approximately three years ago, suggesting a maintenance rather than actively developed phase. The bundler prioritizes simplicity and ease of use, offering minimal configuration options, which differentiates it from more complex tools like Webpack or Rollup. Its primary runtime dependency is `uglify-js` for minification. The bundler is notably used by the Lionel App by default. It supports bundling both directly from code content and from specified file paths.

npm install lionel-commonjs-bundler
INSTALL
IMPORT
SIG · LIONEL-COMMONJS-BU
L
lionel-commonjs-bundler
devopsjavascriptv1.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

commonJSBundler
const { commonJSBundler } = require('lionel-commonjs-bundler/index');
import { commonJSBundler } from 'lionel-commonjs-bundler'; // ESM import will not work, also incorrect path
The library is exclusively CommonJS. Direct ESM `import` statements are not supported. The entry point is specifically `/index`.
makeCode
const { commonJSBundler } = require('lionel-commonjs-bundler/index'); const bundle = commonJSBundler.makeCode(content, dir);
const bundle = require('lionel-commonjs-bundler').makeCode(content, dir); // May lead to undefined if `commonJSBundler` isn't the direct default export.
Access `makeCode` as a method of the named export `commonJSBundler`.
makeFile
const { commonJSBundler } = require('lionel-commonjs-bundler/index'); const bundle = commonJSBundler.makeFile(filePath, dir);
import { makeFile } from 'lionel-commonjs-bundler/index'; // ESM import will not work.
Like `makeCode`, `makeFile` is a method accessed via the `commonJSBundler` named export.

Demonstrates how to use `makeFile` to bundle a CommonJS JavaScript file along with its local dependencies into a single browser-compatible string.

const { commonJSBundler } = require('lionel-commonjs-bundler/index'); const path = require('path'); const contentOfFile = ` const dep = require('./dependency'); module.exports = 'Hello ' + dep; `; const dependencyContent = ` module.exports = 'World'; `; // Create dummy files for demonstration const fs = require('fs'); const tempDir = path.join(__dirname, 'temp_bundler_test'); if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir); fs.writeFileSync(path.join(tempDir, 'main.js'), contentOfFile); fs.writeFileSync(path.join(tempDir, 'dependency.js'), dependencyContent); try { const bundle = commonJSBundler.makeFile(path.join(tempDir, 'main.js'), tempDir); console.log('Successfully bundled code:\n', bundle); // Expected output (minified): 'var dep=require("./dependency");module.exports="Hello "+dep;' (after resolution) } catch (error) { console.error('Bundling failed:', error); } finally { // Clean up dummy files fs.unlinkSync(path.join(tempDir, 'main.js')); fs.unlinkSync(path.join(tempDir, 'dependency.js')); fs.rmdirSync(tempDir); }
lionel-bundle --version
Debug
Known issues
gotchaThe package has not been updated in approximately three years. This may mean it lacks support for newer JavaScript language features (ESM, top-level await, etc.) or security patches for its dependencies, which could be critical for production use.
fix
Evaluate alternatives like Webpack, Rollup, or Esbuild for projects requiring active maintenance, modern features, or broader ecosystem compatibility.
affects: <=1.1.1
gotchaThis bundler is specifically designed for CommonJS modules. It does not support ES Modules (ESM) syntax (`import`/`export`) as input. Attempting to bundle ESM will likely result in parsing errors or incorrect output.
fix
Ensure all input source code uses CommonJS `require()` and `module.exports` syntax. For projects requiring ESM, consider alternative bundlers that explicitly support it.
affects: >=1.0.0
gotchaThe bundler emphasizes simplicity with 'not much configuration options'. This lack of advanced configuration (e.g., extensive plugin ecosystem, granular optimization, tree-shaking) might limit its applicability for complex bundling scenarios or custom requirements found in larger applications.
fix
For projects with complex needs, consider bundlers like Webpack, Rollup, or Parcel that offer extensive configuration and plugin capabilities. Understand the limitations before committing to this bundler.
affects: >=1.0.0
deprecatedWhile CommonJS itself is not deprecated in Node.js, the shift towards ES Modules is significant, with tools and libraries increasingly adopting ESM. Using a bundler exclusively for CJS might lead to interoperability issues with newer dependencies.
fix
For new projects, strongly consider using bundlers and module systems (ESM) that align with current JavaScript ecosystem trends to ensure future compatibility and access to modern features.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: commonJSBundler is not a function
Attempting to call `commonJSBundler()` directly as a function, instead of accessing its methods like `makeCode` or `makeFile`.
fix
Ensure you are calling methods on the `commonJSBundler` object, e.g., `commonJSBundler.makeCode(content, dir)`.
Error: Cannot find module 'lionel-commonjs-bundler'
Incorrect import path or failure to specify the `index` entry point for the CommonJS module. Or, trying to use ESM `import` with a CJS-only package.
fix
Use the exact CommonJS `require` path as specified: `require('lionel-commonjs-bundler/index')`. If using `import`, it will not work as this package is CJS-only.
Error: EACCES: permission denied, open 'output.js'
The Node.js process does not have sufficient write permissions to create or modify the output file at the specified path.
fix
Check the permissions of the directory where the output file is being written. Run your script with appropriate permissions or choose an output path in a user-writable directory.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
uglify-jsrequiredUsed for JavaScript minification during the bundling process.
commanderrequiredLikely used for command-line interface parsing, though not explicitly shown in quickstart.
fs-extrarequiredProvides extended file system functionalities for reading and writing files.
Agent activity
2 hits · last 30 days
node
2
Resources