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

isolated-externals-plugin

v2.5.0

Published

![Build Status](https://github.com/im-open/isolated-externals-plugin/actions/workflows/main.yml/badge.svg) [![npm version](https://badge.fury.io/js/isolated-externals-plugin.svg)](https://badge.fury.io/js/isolated-externals-plugin)

Downloads

2,739

Readme

isolated-externals-plugin

Build Status npm version

Installation

To install, simply run:

npm install --save-dev isolated-externals-plugin

Usage

The IsolatedExternalsPlugin allows you to load external dependencies inside the scope of your webpack bundle without having to have them in your global scope. If you're curious about why you might want this, there are some use cases listed below.

It's an opinionated plugin in this way:

  • The externals set with the IsolatedExternalsPlugin utilize externalsType.promise, which utilizes async/await syntax.

The plugin is built as an ES Module, so you'll need to load it in by using the default property:

const IsolatedExternalsPlugin = require('isolated-externals-plugin').default;

An IsolatedExternalsPlugin configuration might look like the following:

new IsolatedExternalsPlugin({
  entry1: {
    react: {
      url: 'https://unpkg.com/react@16/umd/react.development.js',
      globalName: 'React',
    },
    ['react-dom']: {
      url: 'https://unpkg.com/react-dom@16/umd/react-dom.development.js',
      globalName: 'ReactDOM',
    },
  },
  entry2: {
    react: {
      url: 'https://unpkg.com/react@16/umd/react.development.js',
      globalName: 'React',
    },
    ['react-dom']: {
      url: 'https://unpkg.com/react-dom@16/umd/react-dom.development.js',
      globalName: 'ReactDOM',
    },
  },
});

Each property of the configuration follows this structure:

[entryName]: {
  [packageName]: {
    url: [url],
    globalName: [globalName]
  }
}

| Part | Description | | ---------------- | --------------------------------------------------------------------------------------------------------- | | entryName* | The name of one of your webpack Entry Points. | | packageName* | The name of the import for your externalized dependency (like 'react-dom'). | | url* | The URL from which to load your dependency file. | | globalName | The UMD name of your dependency (like ReactDOM). See below for details | | urlTransformer | A path or module path to a module that exports a url transforming function. | | * | required |

globalName and other details

If globalName is not provided, IsolatedExternalsPlugin will try to match the packageName to one of your externals entries, and will use the value from that as the globalName

The external files will be loaded and applied to your context in the order that they're listed, so if you have dependencies that depend on other dependencies (like ReactDOM depends on React), then you'll want to make sure you list the ones they depend on first.

How It Works

IsolatedExternalsPlugin loads the text of your externals URLs via a shared Cache (or a shared global object if Cache is not available), and processes the text on a context object which is singular to your bundle. This allows you to load multiple bundles per page with different versions of a dependency—or with the same version of a dependency separately—without polluting a global scope, and without loading the same dependency over the wire more than once. This keeps bundle sizes down while also providing complete autonomy to any individual JS bundle.

Why load externals locally instead of globally?

Here are two valid use cases. There may be others, but these are the reason we built this plugin!:

  1. You want to load different javascript apps on the same page with different versions of the same dependency (like React).
  2. You want to load more than one javascript app onto the same page with the same dependency, but ignorant of each other and the global context (like in micro frontends). This allows each app to be small in byte size, and allows the overall page to never load the same dependency more than once.

Contributing

This package uses semantic-release. Changes will be compiled into a changelog and the package versioned, tagged and published automatically. Please ensure your commit messages adhere to the following structure:

<type>: <subject>
<BLANK LINE>
<body>

Only the header is mandatory. The supported types are based off of the ESLint Convention.