1.1.0 • Published 8 months ago

toypack v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Toypack

The sandbox bundler for static sites.

Toypack is a library for bundling codes in the browser. It is particularly useful for creating JS playgrounds like Codepen or CodeSandbox.

Read full documentation here

Installation

NPM

npm install toypack;

IMPORTANT NOTE: If you're opting for the npm installation (as you should) instead of using the CDN version, please ensure you add polyfills for path, fs, process, and Buffer to avoid any issues.

CDN

<script src="https://jsdelivr.com/package/npm/toypack"></script>

Basic Usage

import { Toypack } from "toypack";
const toypack = new Toypack();

// Add assets
toypack.addOrUpdateAsset("/index.js", "console.log(123);");

// Run
const result = await toypack.run();
console.log(result.js.content);