CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-rollup--plugin-buble

A Rollup plugin that compiles ES2015+ code with the Bublé compiler for fast transpilation to ES5

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

Rollup Bublé Plugin

@rollup/plugin-buble is a Rollup plugin that integrates the Bublé compiler to transpile ES2015+ JavaScript code to ES5-compatible code. It provides a simple and lightweight alternative to Babel for basic ES2015+ transformations with fast compilation and minimal configuration overhead.

Package Information

  • Package Name: @rollup/plugin-buble
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @rollup/plugin-buble --save-dev

Core Imports

import buble from '@rollup/plugin-buble';

For CommonJS:

const buble = require('@rollup/plugin-buble');

Basic Usage

import buble from '@rollup/plugin-buble';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [buble()]
};

Capabilities

Plugin Creation

Creates a Rollup plugin instance that transforms ES2015+ code using the Bublé compiler.

/**
 * Convert ES2015+ code with Bublé compiler
 * @param options - Configuration options for the plugin
 * @returns Rollup plugin instance
 */
function buble(options?: RollupBubleOptions): Plugin;

Usage Examples:

// Basic usage - no configuration needed
export default {
  plugins: [buble()]
};

// With transform options
export default {
  plugins: [buble({
    transforms: {
      forOf: false,
      dangerousForOf: true,
      arrow: true
    }
  })]
};

// With file filtering
export default {
  plugins: [buble({
    include: 'src/**/*.js',
    exclude: 'node_modules/**',
    transforms: { modules: false }
  })]
};

File Filtering

Controls which files are processed by the plugin using picomatch patterns.

interface RollupBubleOptions {
  /**
   * A picomatch pattern, or array of patterns, of files that should be
   * processed by this plugin (if omitted, all files are included by default)
   */
  include?: FilterPattern;
  /**
   * Files that should be excluded, if `include` is otherwise too permissive.
   */
  exclude?: FilterPattern;
}

Examples:

// Include only specific files
buble({
  include: ['src/**/*.js', 'lib/**/*.js']
})

// Exclude node_modules
buble({
  exclude: 'node_modules/**'
})

// Complex patterns
buble({
  include: 'src/**/*.{js,jsx}',
  exclude: ['**/*.test.js', '**/fixtures/**']
})

Transform Configuration

Configures Bublé compiler transformation options. All standard Bublé transform options are supported.

interface RollupBubleOptions extends TransformOptions {
  /**
   * Bublé transformation options - controls which ES2015+ features to transform
   * The 'modules' option is automatically set to false for Rollup compatibility
   */
  transforms?: {
    [feature: string]: boolean;
  };
  
  /**
   * Additional Bublé compiler options
   */
  objectAssign?: boolean | string;
  target?: { [key: string]: any };
}

Common Transform Options:

buble({
  transforms: {
    // Transform arrow functions (default: true)
    arrow: true,
    
    // Transform classes (default: true)
    classes: true,
    
    // Transform for-of loops (default: true)
    forOf: true,
    
    // Use dangerous for-of transform (faster but less safe)
    dangerousForOf: false,
    
    // Transform destructuring (default: true)
    destructuring: true,
    
    // Transform template literals (default: true)
    templateString: true,
    
    // Transform async/await (default: false - requires regenerator)
    asyncAwait: false,
    
    // Transform object spread (default: true)
    spreadRest: true
  },
  
  // Object.assign polyfill handling
  objectAssign: 'Object.assign', // or true for polyfill
  
  // Browser targets (affects which transforms are applied)
  target: {
    chrome: 58,
    firefox: 55,
    safari: 10,
    edge: 15
  }
})

Types

type FilterPattern = string | RegExp | Array<string | RegExp>;

interface TransformOptions {
  transforms?: { [key: string]: boolean };
  objectAssign?: boolean | string;
  target?: { [key: string]: any };
  source?: string;
  file?: string;
  includeContent?: boolean;
}

interface RollupBubleOptions extends TransformOptions {
  include?: FilterPattern;
  exclude?: FilterPattern;
}

interface Plugin {
  name: string;
  transform?: (code: string, id: string) => any;
}

Error Handling

The plugin enhances Bublé compilation errors with additional context:

  • e.plugin: Set to 'buble' to identify the source
  • e.loc.file: The file path where the error occurred
  • e.frame: Code snippet showing the error location

Error Example:

// If Bublé encounters invalid syntax:
// Error: Unexpected token (line 5, column 12)
// Plugin: buble
// File: /project/src/component.js
// Frame: [code snippet around error]

Key Features

  • Fast Compilation: Bublé is significantly faster than Babel for basic transformations
  • Zero Configuration: Works out of the box with sensible defaults
  • Selective Transforms: Choose exactly which ES2015+ features to transform
  • File Filtering: Process only the files you need with include/exclude patterns
  • Rollup Integration: Seamless integration with Rollup's plugin system
  • Error Enhancement: Clear error messages with file context
  • Type Safety: Full TypeScript support with complete type definitions
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@rollup/plugin-buble@1.0.x
Publish Source
CLI
Badge
tessl/npm-rollup--plugin-buble badge