Registry / devops / rollup-plugin-strict-alias

rollup-plugin-strict-alias

JSON →
library1.0.0jsnpmunverified

A Rollup plugin for defining import aliases with exact string matching (===) rather than prefix matching (startsWith). Version 1.0.0 is the current stable release. This plugin emulates Webpack's resolve.alias behavior, avoiding false positives that occur with substring replacement (e.g., 'react' won't accidentally match 'react-router'). It supports local file resolution with configurable extensions. Unlike rollup-plugin-alias, this plugin provides strict alias substitution and handles submodule imports (e.g., 'lodash/map'). The package is authored by adriantoine and has minimal maintenance commitment; last release is final. Suitable for projects using Rollup that need precise alias mapping.

npm install rollup-plugin-strict-alias
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-STRI
R
rollup-plugin-strict-alias
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

alias
import alias from 'rollup-plugin-strict-alias'
const alias = require('rollup-plugin-strict-alias')
The package exports a default function; both ESM and CJS are supported. In CJS environments, use require().default if using ES interop.
default (no named exports)
import alias from 'rollup-plugin-strict-alias'
import { alias } from 'rollup-plugin-strict-alias'
There is no named export 'alias'; only a default export is provided.
Plugin type (TypeScript)
import type { Plugin } from 'rollup'; import alias from 'rollup-plugin-strict-alias'
import { alias as RollupAliasPlugin } from 'rollup-plugin-strict-alias'
TypeScript users should import the default function and optionally use Rollup's Plugin type. The package does not export its own type.

Configures Rollup with strict aliases for 'react' and 'lodash', then bundles an ES module.

import { rollup } from 'rollup'; import alias from 'rollup-plugin-strict-alias'; rollup({ input: './src/index.js', plugins: [ alias({ 'react': './vendor/react.js', 'lodash': './node_modules/lodash-es' }) ] }).then(bundle => bundle.write({ file: 'dist/bundle.js', format: 'esm' }));
Debug
Known issues
gotchaAliases are matched exactly (===) not via startsWith. A path like 'lodash/map' will NOT be replaced if the alias is 'lodash'.
fix
Define aliases for full import paths if submodule mapping is needed, or use a plugin that supports wildcard/regex patterns.
affects: >=1.0.0
deprecatedThe package has not been updated since 2016. No security patches or Rollup API compatibility updates.
fix
Consider using alternative plugins like @rollup/plugin-alias (maintained by the Rollup team).
affects: >=1.0.0
gotchaLocal aliases (starting with './') are resolved relative to the current working directory, not the importing file.
fix
Use absolute paths or ensure the alias path is correct relative to process.cwd().
affects: >=1.0.0
gotchaIf the `resolve` option is not provided, local aliases implicitly append '.js' extension. Other extensions like '.jsx' or '.ts' are not tried.
fix
Provide an explicit `resolve` array with the extensions you want (e.g., ['.js', '.jsx']).
affects: >=1.0.0
gotchaThe plugin replaces import specifiers before other plugins run. If another plugin later modifies the specifier, the alias may not apply.
fix
Ensure this plugin is placed early in the plugins array, before any plugin that transforms imports.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-strict-alias'
The package is not installed or not in node_modules.
fix
Run `npm install rollup-plugin-strict-alias --save-dev` or add to package.json dependencies.
TypeError: alias is not a function
Using named import { alias } instead of default import.
fix
Change to `import alias from 'rollup-plugin-strict-alias'`.
(!) Plugin strict-alias: Could not resolve './some/path' from 'CWD'
The aliased local path does not exist or the file extension is missing.
fix
Check the path and ensure the file exists with an extension included in the `resolve` option. Use absolute paths if needed.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
rollup-plugin-strict-alias — npm install rollup-plugin-strict-alias · libregistry