@jsenv/bundling
[![github package](https://img.shields.io/github/package-json/v/jsenv/jsenv-bundling.svg?label=package&logo=github)](https://github.com/jsenv/jsenv-bundling/packages) [![ci status](https://github.com/jsenv/jsenv-bundling/workflows/ci/badge.svg)](https://g
Last updated 23 days ago by dmail .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @jsenv/bundling 
SYNC missed versions from official npm registry.

jsenv bundling

github package ci status codecov

Introduction

@jsenv/bundling is used by jsenv projects to generate files published on npm.

It has the following exports

  • generateGlobalBundle
  • generateCommonJsBundle
  • generateSystemJsBundle

How to use

To understand how to use jsenv bundling let's use it on a "real" project.
We will setup a basic project and generate different bundle formats.

Basic project setup

  1. Create basic project file structure

    — see ./docs/basic-project

  2. Install dependencies

    npm install
    

generateGlobalBundle example

node ./generate-global-bundle.js

Once done, terminal will contain a log with the path to the generated bundle.

— see ./docs/basic-project/dist/global/main.js

generateCommonJsBundle example

node ./generate-commonjs-bundle.js

Once done, terminal will contain a log with the path to the generated bundle.

— see ./docs/basic-project/dist/commonjs/main.js

generateSystemJsBundle example

node ./generate-systemjs-bundle.js

Once done, terminal will contain a log with the path to the generated bundle.

— see ./docs/basic-project/dist/systemjs/main.js

Bundling functions documentation

If you want to know more about these functions, there is a dedicated page for that.
— see bundling functions documentation

Supported codebase

jsenv bundling can work with syntax like top level await.
However some syntax are compatible only with a subset of the available bundle formats.
For instance generateCommonJsBundle throw an error if it encounters a top level await in your codebase.

You can find below some code examples and the associated bundle format compatibility.

top level await

const answer = await Promise.resolve(42)

Compatibility: global, commonjs, systemjs.

dynamic import

import("./file.js").then((namespace) => {
  console.log(namespace)
})

Compatibility: global, commonjs, systemjs.

import.meta.url

const whereAMI = import.meta.url

Compatibility: global, commonjs, systemjs.

import.meta.resolve

import.meta.resolve("./file.js")

const lodashHref = import.meta.resolve("lodash")
// importMap are applied so that lodashHref might be /node_modules/lodash/index.js

Compatibility: global, commonjs.

leading slash import

import "/src/file.js"
// search file at "/Users/you/folder/src/file.js"

Compatibility: global, commonjs, systemjs.

import remapping

import memoize from "lodash"
// search file at "/node_modules/lodash/index.js"

Compatibility: global, commonjs, systemjs.

json

import data from "./data.json"

Compatibility: global, commonjs, systemjs.

globalThis

globalThis.console.log("Hello")

Compatibility: global, commonjs, systemjs.

Installation

npm install --save-dev @jsenv/bundling@5.7.0
yarn add @jsenv/bundling@5.7.0 --dev

Current Tags

  • 6.3.0                                ...           latest (23 days ago)

53 Versions

  • 6.3.0                                ...           23 days ago
  • 6.2.0                                ...           25 days ago
  • 6.1.0                                ...           a month ago
  • 6.0.0                                ...           a month ago
  • 5.17.0                                ...           a month ago
  • 5.16.0                                ...           a month ago
  • 5.15.0                                ...           a month ago
  • 5.14.0                                ...           a month ago
  • 5.13.0                                ...           a month ago
  • 5.12.0                                ...           a month ago
  • 5.11.0                                ...           a month ago
  • 5.10.0                                ...           a month ago
  • 5.8.0                                ...           a month ago
  • 5.7.0                                ...           a month ago
  • 5.6.0                                ...           a month ago
  • 5.4.0                                ...           a month ago
  • 5.3.0                                ...           2 months ago
  • 5.2.0                                ...           2 months ago
  • 5.1.0                                ...           2 months ago
  • 5.0.0                                ...           2 months ago
  • 4.2.0                                ...           2 months ago
  • 4.1.0                                ...           2 months ago
  • 4.0.0                                ...           2 months ago
  • 3.6.0                                ...           2 months ago
  • 3.5.0                                ...           2 months ago
  • 3.4.0                                ...           2 months ago
  • 3.3.0                                ...           2 months ago
  • 3.2.0                                ...           2 months ago
  • 3.1.0                                ...           2 months ago
  • 3.0.0                                ...           2 months ago
  • 2.4.0                                ...           2 months ago
  • 2.3.0                                ...           2 months ago
  • 2.2.0                                ...           2 months ago
  • 2.1.0                                ...           2 months ago
  • 2.0.0                                ...           2 months ago
  • 1.18.0                                ...           2 months ago
  • 1.17.0                                ...           2 months ago
  • 1.16.0                                ...           2 months ago
  • 1.15.0                                ...           2 months ago
  • 1.14.0                                ...           2 months ago
  • 1.13.0                                ...           2 months ago
  • 1.12.0                                ...           3 months ago
  • 1.11.0                                ...           3 months ago
  • 1.10.0                                ...           3 months ago
  • 1.8.0                                ...           3 months ago
  • 1.7.0                                ...           3 months ago
  • 1.6.0                                ...           3 months ago
  • 1.5.0                                ...           3 months ago
  • 1.4.0                                ...           3 months ago
  • 1.3.0                                ...           3 months ago
  • 1.2.0                                ...           3 months ago
  • 1.1.0                                ...           3 months ago
  • 1.0.0                                ...           3 months ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 444

Copyright 2014 - 2016 © taobao.org |