Detalhes do pacote

@putout/bundler

putoutjs662MIT3.0.0

Lint Filesystem with 🐊Putout

putout, bundler, AST, babel

readme (leia-me)

Bundler License NPM version Build Status Coverage Status

Install

npm i @putout/bundle

API

import {bundle} from '@putout/bundler';

console.log(bundle(CWD, entry, filesystem));

Internals

Convert ESM to CommonJS

To Simplify things up all files converted to CommonJS first. Let's suppose none of them use top-level await to get things simpler.

Parse filenames

Traverse all files starting from entry and get all filenames.

Bundle all files to object

Traverse filesystem and create object that contains filename and file content:

const __filesystem = {
    '/entry.js': () => {
        const client = require('/client.js');
        console.log(client);
    },
    '/client.js': (exports, require, module) => {
        module.exports = 'hello';
    },
};

IIFE

Most likely we need IIFE so couple bundles can be loaded on page simultaneously.

Result Example

const __modules = {};
const __filesystem = {
    '/entry.js': () => {
        const client = require('/client.js');
        console.log(client);
    },
    '/client.js': (exports, require, module) => {
        module.exports = 'hello';
    },
};

const require = (name) => {
    const exports = {};
    const module = {
        exports,
    };

    if (__modules[name])
        return __modules[name];

    __filesystem[name](exports, require, module);
    __modules[name] = module.exports;

    return module.exports;
};

require('/entry.js');

License

MIT

changelog (log de mudanças)

2025.06.02, v3.0.0

feature:

  • 2cdd870 @putout/bundler: putout v40.3.0
  • 9383e65 @putout/bundler: estree-to-babel v11.0.3
  • 2b4793d @putout/bundler: eslint-plugin-putout v27.1.0
  • 162d7f6 @putout/bundler: @putout/processor-filesystem v7.0.1
  • 3eb81ec @putout/bundler: @putout/plugin-nodejs v16.4.0
  • f2eed36 @putout/bundler: @putout/plugin-filesystem v11.0.1
  • d4d3467 @putout/bundler: @putout/operator-filesystem v9.0.1
  • e9e899d @putout/bundler: @putout/engine-runner v25.0.3
  • 64dae36 @putout/bundler: drop support of node < 20

2025.03.25, v2.0.0

feature:

  • 368afc8 @putout/bundler: supertape v11.0.4
  • abee8e2 @putout/bundler: putout v39.0.13
  • 950cfda @putout/bundler: madrun v11.0.0
  • 3a97c1e @putout/bundler: ignore v7.0.3
  • e23988f @putout/bundler: estree-to-babel v10.5.0
  • ae37f85 @putout/bundler: eslint-plugin-putout v26.1.0
  • ed3ddfd @putout/bundler: c8 v10.1.3
  • 84f9f50 @putout/bundler: @putout/test v13.0.0
  • 030cac2 @putout/bundler: @putout/processor-filesystem v6.0.0
  • 903d934 @putout/bundler: @putout/plugin-nodejs v15.2.0
  • b133bbe @putout/bundler: @putout/plugin-filesystem v9.0.0
  • d752bec @putout/bundler: @putout/operator-filesystem v7.0.0
  • d72d23a @putout/bundler: @putout/engine-runner v24.0.2

2024.04.09, v1.1.1

feature:

  • 6f4cd2d @putout/bundler: @putout/plugin-filesystem v5.0.0
  • a5c7da0 @putout/bundler: eslint v9.0.0
  • e138f20 @putout/bundler: eslint-plugin-n: drop

2024.02.22, v1.1.0

feature:

  • 57efbc0 package: drop unused dependencies
  • 1ae4e71 bundler: improve support of external modules

2024.02.19, v1.0.2

fix:

  • 1cb74fe export: bundler -> bundle

2024.02.19, v1.0.1

fix:

  • 375e409 readme: internals
  • 080b5df readme: Bundle -> Bundler

feature:

  • a2caadd @putout/bundler: @putout/plugin-nodejs v11.0.0
  • 7ad6e51 @putout/bundler: add