Version 1.0.0
@stackline/rollup-plugin-inject
Scan modules for global variables and injects `import` statements where necessary
Independent maintenance of @rollup/plugin-inject 5.0.5. Original authors and licenses are retained.
Installation
# Preserve existing imports with an npm alias
npm install @rollup/plugin-inject@npm:@stackline/rollup-plugin-inject@1.0.0
# Or use the scoped package name in your imports
npm install @stackline/rollup-plugin-inject@1.0.0Node.js: >=14.0.0. Read the compatibility and maintenance notes before migrating.
Usage and API
The reference below may retain upstream package names. Use the alias installation above to run those imports with this Stackline release.
@rollup/plugin-inject
š£ A Rollup plugin which scans modules for global variables and injects import statements where necessary.
Requirements
This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.
Install
Using npm:
npm install @rollup/plugin-inject --save-dev
Usage
Create a rollup.config.js configuration file and import the plugin:
import inject from '@rollup/plugin-inject';
export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [
inject({
Promise: ['es6-promise', 'Promise']
})
]
};
Then call rollup either via the CLI or the API.
This configuration above will scan all your files for global Promise usage and plugin will add import to desired module (import { Promise } from 'es6-promise' in this case).
Examples:
{
// import { Promise } from 'es6-promise'
Promise: [ 'es6-promise', 'Promise' ],
// import { Promise as P } from 'es6-promise'
P: [ 'es6-promise', 'Promise' ],
// import $ from 'jquery'
$: 'jquery',
// import * as fs from 'fs'
fs: [ 'fs', '*' ],
// use a local module instead of a third-party one
'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
}
Typically, @rollup/plugin-inject should be placed in plugins before other plugins so that they may apply optimizations, such as dead code removal.
Options
In addition to the properties and values specified for injecting, users may also specify the options below.
exclude
Type: String | Array[...String]
Default: null
A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.
include
Type: String | Array[...String]
Default: null
A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.
Meta
Upstream issues and maintenance review
Upstream origin and triage
- Original package:
@rollup/plugin-inject@5.0.5 - Repository: https://github.com/rollup/plugins
- Source commit: https://github.com/rollup/plugins/commit/d55ce9c6d76a008b0d0bcec86b310e1e51636384
- Source directory:
packages/inject - npm tarball: https://registry.npmjs.org/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz
- SHA512 integrity:
sha512-2+DEJbNBoPROPkgTDNe8/1YXWcqxbN5DTjASVIOx8HS+pITXushyNiBV56RB08zuptzz8gT3YfkqriTBVycepg== - npm last-release age selects maintenance scope; it does not imply no ongoing source development.
Reviewed issues
Primary-source snapshot: 2026-09-29T00:22:07.903653+00:00. Most recently updated 100 open and 30 closed issue/PR entries; PRs removed. This is triage evidence, not a claim of exhaustive review.
Maintenance adoption with preserved runtime payload. No runtime defect correction is claimed. Reports remain visible for subsequent targeted reproduction.
- 2024: @rollup/plugin-virtual: TS2349: This expression is not callable under modern "moduleResolution": "NodeNext"
- 1860:
typesare wrong configed - 2023: Typescript and noEmitOnError regressions/issues
- 2022: typescript
6.0.3dependency issue - 2016:
@rollup/plugin-typescript- Support for TypeScript 7 - 2015: Support js-yaml v5
- 1874: [node-resolve] Replace
resolveand some rollup-bakedexportsfields handling with a Rust-based resolver - 2014: Babel 8 support
- 2011: replace: Should property accessors be replaced or not?
- 2008:
@rollup/plugin-typescriptshould error on TypeScript import of missing.jsonfile (bundled with a different name by@rollup/plugin-json) - 2005: @rollup/plugin-babel causes SOURCEMAP_ERROR while reporting THIS_IS_UNDEFINED from unmapped generated helper code
- 1885: [@rollup/plugin-commonjs] Bring back named exports in commonjs entry points
- 1992: import YAML file, RollupError: 'Legacy octal escape is not permitted in strict mode'
- 1948: [@rollup/plugin-typescript]: Source-map source paths break if "sourceRoot" is specified
- 1970: plugin-terser does not share nameCache between minify invocations when chunking across multiple entrypoint and common files
- 1973: Minification removes class identifiers causing observable runtime change in Class.name
- 1966: Incorrect sourcemap sources paths when outDir differs from source directory
- 1935: charlie: ESM update of auto-install
- 1918: @rollup/plugin-url does not use the asset mechanism
- 1946: node-resolve plugin discards this re-exported file
- 1941: Allow typescript transpilation not to match rollup file option
- 1672: [@rollup/plugin-commonjs] engine-v8-version.js:25 Uncaught TypeError: userAgent.match is not a function at engine-v8-version.js:25:21 in core-js
- 986: commonjs - Missing export (Error: ... is not exported by ...)
- 1873: [node-resolve]: the external module render path is not expected
- 1739: Wasm plugin to support latest ESM Integration & Source Phase Imports
- 1858:
@rollup/plugin-typescriptseems not recognizing.d.[ext].tsstyle definition files? - 1851: Typescript conflict in Deno
- 539: Proposal: Add support for full ES-Node interop
- 3: Core-Critical Plugin Script
The structured snapshot in .stackline/issue-triage.json also records recently closed reports. Issues for unrelated packages in shared monorepositories were qualified as outside this forkās runtime scope. No maintainer was contacted.
Release files and references
Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.