npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rollup-plugin-iife

v0.7.1

Published

Convert ES modules into IIFEs.

Downloads

6,302

Readme

rollup-plugin-iife

Build Status codecov install size

Currently ([email protected]), rollup doesn't support code splitting with IIFE output. This plugin would transform ES module output into IIFEs.

Installation

npm install -D rollup-plugin-iife

Usage

import iife from "rollup-plugin-iife";

export default {
  input: ["entry.js", "entry2.js"],
  output: {
    dir: "dist",
    format: "es",
    globals: {
      vue: "Vue"
    }
  },
  externals: ["vue"],
  plugins: [iife()]
};

Define global variables for external imports

You can define global variables with output.globals just like before. You can also specify them with the plugin option names.

The plugin would first lookup names option then output.globals.

API

This module exports a single function.

iife

iife({
  names?: Function|Object,
  sourcemap?: Boolean,
  prefix?: String,
  strict?: Boolean
}) => PluginInstance

Create the plugin instance.

If names is a function, the signature is:

(moduleId: String) => globalVariableName: String

If names is an object, it is a moduleId/globalVariableName map. moduleId can be relative to the output folder (e.g. ./entry.js), the plugin would resolve it to the absolute path.

If the plugin can't find a proper variable name, it would generate one according to its filename with camelcase.

If sourcemap is false then don't generate the sourcemap. Default: true.

When prefix is defined, it will be used to prefix auto-generated variable names. It doesn't prefix names defined in the names option. It doesn't prefix external imports.

If strict is true then add 'use strict'; directive to the IIFE. Default: true.

Related projects

  • rollup-plugin-external-globals - transform imports into global variables at transform hook.
  • amd-script - a small AMD module cache that would work with AMD module chunks generated by Rollup. You have to load modules manually (e.g. load modules through <script> tags).
  • rollup-plugin-loadz0r - attach each chunk with a module loader so you don't have to include a module loader at runtime. Support workers.

Changelog

  • 0.7.1 (Feb 16, 2024)

    • Relax peer dependency. Support rollup 4.
  • 0.7.0 (Oct 20, 2022)

    • Breaking: bump to rollup@3.
    • Change: throw an error if output.dir is not defined.
  • 0.6.0 (Feb 11, 2022)

    • Add: handle import.meta.url. The plugin also throws and error if it sees unconverted import.meta.
  • 0.5.0 (Feb 18, 2021)

    • Now 'use strict'; directive is inserted by default.
    • Add: strict option.
  • 0.4.0 (Dec 28, 2020)

    • Fix: plugin name.
    • Bump dependencies. Update to [email protected], replace camelcase with lodash/camelCase.
  • 0.3.1 (Feb 8, 2020)

    • Fix: prefix local imports.
  • 0.3.0 (Aug 14, 2019)

  • 0.2.1 (Jun 23, 2019)

    • Fix: handle empty chunks.
  • 0.2.0 (Jan 26, 2019)

    • Breaking: bump rollup version to 1.x.
  • 0.1.2 (Jan 25, 2019)

    • Add: prefix option.
  • 0.1.1 (Sep 28, 2018)

    • Add: support output.globals option.
  • 0.1.0 (Aug 28, 2018)

    • First release.