https://github.com/robertklep/package-bundler
Bundle a Node.js package into a single file.
https://github.com/robertklep/package-bundler
Last synced: 9 months ago
JSON representation
Bundle a Node.js package into a single file.
- Host: GitHub
- URL: https://github.com/robertklep/package-bundler
- Owner: robertklep
- Created: 2022-11-21T13:20:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-31T13:09:35.000Z (over 3 years ago)
- Last Synced: 2025-02-15T02:43:08.358Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Package Bundler
Bundle a Node.js module into a single file.
## Prerequisites
Depends on having a working, and recent, Node.js installation (including `npm`).
## Installation
Install the bundler script using NPM (requires Git to be installed as a CLI tool):
```
$ npm install -g https://github.com/robertklep/package-bundler
```
Alternatively, you can [download the code from Github as a ZIP file](https://github.com/robertklep/package-bundler/archive/refs/heads/main.zip) and run `npm install -g` from the `package-bundler-main` directory after unzipping the file.
## How to use
#### Bundle a complete Node.js package
```
$ package-bundler lodash
```
#### Bundle some specific imports from a package
```
$ package-bundler lodash flattenDeep merge
```
#### Bundle a specific package version
```
$ package-bundler lodash@4.0.0
```
## What it does
The script will create a temporary directory in which it will install the Node.js package to be bundled. Then it will write a small wrapper file that exports the package (or just the specific imports).
It will then run `ncc` against the wrapper file to bundle everything into a single file inside a directory named after the package. It will move this directory into your current working directory, and you should be able to load it from your main code.
## Limitations
* Not all packages can be bundled, especially ones that use dynamic `require` calls or packages like `require-all`.