All Projects → Comandeer → rollup-lib-bundler

Comandeer / rollup-lib-bundler

Licence: MIT License
Simple lib bundler

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to rollup-lib-bundler

React Modern Library Boilerplate
Boilerplate for publishing modern React modules with Rollup
Stars: ✭ 285 (+2092.31%)
Mutual labels:  babel, rollup
Bili
Bili makes it easier to bundle JavaScript libraries.
Stars: ✭ 949 (+7200%)
Mutual labels:  babel, rollup
Create React Library
⚡CLI for creating reusable react libraries.
Stars: ✭ 4,554 (+34930.77%)
Mutual labels:  babel, rollup
Rollup Plugin Ts
A Typescript Rollup plugin that bundles declarations and respects Browserslists
Stars: ✭ 273 (+2000%)
Mutual labels:  babel, rollup
Babel React Rollup Starter
A simple boilerplate for web apps with React, Babel, and Rollup.
Stars: ✭ 124 (+853.85%)
Mutual labels:  babel, rollup
Ts Monorepo
Template for setting up a TypeScript monorepo
Stars: ✭ 459 (+3430.77%)
Mutual labels:  babel, rollup
Serverless Plugin Typescript
Serverless plugin for zero-config Typescript support
Stars: ✭ 611 (+4600%)
Mutual labels:  babel, rollup
Svelte Example
🚀 📚 Some examples to test the Svelte Framework
Stars: ✭ 85 (+553.85%)
Mutual labels:  babel, rollup
Babel Plugin Prismjs
A babel plugin to use PrismJS with standard bundlers.
Stars: ✭ 114 (+776.92%)
Mutual labels:  babel, rollup
Shortstack
🥞 minimal Rollup + PostCSS modern syntax starter template
Stars: ✭ 94 (+623.08%)
Mutual labels:  babel, rollup
Xdm
a modern MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins
Stars: ✭ 206 (+1484.62%)
Mutual labels:  babel, rollup
Klap
zero config, zero dependency bundler for tiny javascript packages
Stars: ✭ 143 (+1000%)
Mutual labels:  babel, rollup
stan
🔨 Collection of front-end engineering tools
Stars: ✭ 19 (+46.15%)
Mutual labels:  babel, rollup
2life-server
💌 双生:遇见另一半的美好:)(服务端)
Stars: ✭ 66 (+407.69%)
Mutual labels:  babel
babel-plugin-dedent
Remove indentation from multiline template strings
Stars: ✭ 32 (+146.15%)
Mutual labels:  babel
babel-preset-react-native-web3
deprecated: babel preset for react native, web3 and babel 6
Stars: ✭ 22 (+69.23%)
Mutual labels:  babel
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (+161.54%)
Mutual labels:  babel
babel-plugin-source-map-support
A Babel plugin which automatically makes stack traces source-map aware
Stars: ✭ 41 (+215.38%)
Mutual labels:  babel
sample-ui-react
Material-UI+ React.js + Redux [ Pug / Scss / Babel ]
Stars: ✭ 15 (+15.38%)
Mutual labels:  babel
cerebro-web
Website for Cerebro
Stars: ✭ 21 (+61.54%)
Mutual labels:  babel

@comandeer/rollup-lib-bundler

Build Status codecov npm (scoped)

Super opinionated library bundler using Rollup, Babel and terser.

Installation

npm install @comandeer/rollup-lib-bundler --save-dev

Usage

Just make it a npm script:

"scripts": {
	"build": "rlb"
}

Configuration

No configuration. Consider it a feature.

How does it work?

It gets package.json from the current working directory, parses it and get neeeded info:

  • name, author, version and license to create beautiful banner comment,
  • exports.require or main to get path for saving CJS bundle,
  • exports.import, module or jsnext:main for saving ESM bundle.

Then the bundling happens. The default entry point for Rollup is src/index.js. Please note that dist/ directory is purged before bundling! So if anything should be there alongside the bundle, it should be added there after the bundling.

Assumed file structure

This is very opinionated bundler and it assumes that the project's file structure looks like the one below:

package/
|- package.json
|- src/
|     |- index.js
|     |- some-other-chunk.js
|- dist/
|      |- bundled-index.cjs
|      |- bundled-index.cjs.map
|      |- bundled-index.mjs
|      |- bundled-index.mjs.map
|      |- bundled-some-other-chunk.cjs
|      |- bundled-some-other-chunk.cjs.map
|      |- bundled-some-other-chunk.mjs
|      |- bundled-some-other-chunk.mjs.map
  • package.json is in the root of the package (the only bit we all agree on!),
  • src/ directory contains package's source,
    • index.js is the main entrypoint of the package,
    • some-other-chunk.js is the optional additional entrypoint (see [#mutliple-bundles](Multiple bundles) section for more info),
  • dist/ directory contains bundled code.

Multiple bundles

By default, src/index.js is treated as the only entry point. However, using subpath exports you can create several bundled chunks/files. Example:

"exports": {
	".": {
		"require": "./dist/es5.cjs",
		"import": "./dist/es6.mjs"
	},

	"./chunk": {
		"require": "./dist/chunk.cjs",
		"import": "./dist/chunk.mjs"
	}
}

In this case two source files will be bundled:

  • src/index.js:
    • ESM output: dist/es6.mjs,
    • CJS output: dist/es5.cjs,
  • src/chunk.js:
    • ESM output: dist/chunk.mjs,
    • CJS output: dist/chunk.cjs.

Although Node.js supports several different syntaxes for subpath exports, this bundler supports only the form presented on the example above (so each subpath needs two properties – require for CJS bundle and import for ESM bundle).

Each subpath is translated to appropriate file in src directory. Basically, ./ at the beginning is translated to src/ and the name of the subpath is translated to <subpath>.js (e.g. ./chunksrc/chunk.js). The only exception is the . subpath, which is translated to src/index.js.

License

See LICENSE file for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].