{"id":22231,"library":"rollup-plugin-strict-alias","title":"rollup-plugin-strict-alias","description":"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.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/adriantoine/rollup-plugin-strict-alias","tags":["javascript","rollup","rollup-plugin","resolve","alias"],"install":[{"cmd":"npm install rollup-plugin-strict-alias","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-strict-alias","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-strict-alias","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a default function; both ESM and CJS are supported. In CJS environments, use require().default if using ES interop.","wrong":"const alias = require('rollup-plugin-strict-alias')","symbol":"alias","correct":"import alias from 'rollup-plugin-strict-alias'"},{"note":"There is no named export 'alias'; only a default export is provided.","wrong":"import { alias } from 'rollup-plugin-strict-alias'","symbol":"default (no named exports)","correct":"import alias from 'rollup-plugin-strict-alias'"},{"note":"TypeScript users should import the default function and optionally use Rollup's Plugin type. The package does not export its own type.","wrong":"import { alias as RollupAliasPlugin } from 'rollup-plugin-strict-alias'","symbol":"Plugin type (TypeScript)","correct":"import type { Plugin } from 'rollup'; import alias from 'rollup-plugin-strict-alias'"}],"quickstart":{"code":"import { rollup } from 'rollup';\nimport alias from 'rollup-plugin-strict-alias';\n\nrollup({\n  input: './src/index.js',\n  plugins: [\n    alias({\n      'react': './vendor/react.js',\n      'lodash': './node_modules/lodash-es'\n    })\n  ]\n}).then(bundle => bundle.write({ file: 'dist/bundle.js', format: 'esm' }));","lang":"javascript","description":"Configures Rollup with strict aliases for 'react' and 'lodash', then bundles an ES module."},"warnings":[{"fix":"Define aliases for full import paths if submodule mapping is needed, or use a plugin that supports wildcard/regex patterns.","message":"Aliases are matched exactly (===) not via startsWith. A path like 'lodash/map' will NOT be replaced if the alias is 'lodash'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using alternative plugins like @rollup/plugin-alias (maintained by the Rollup team).","message":"The package has not been updated since 2016. No security patches or Rollup API compatibility updates.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use absolute paths or ensure the alias path is correct relative to process.cwd().","message":"Local aliases (starting with './') are resolved relative to the current working directory, not the importing file.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Provide an explicit `resolve` array with the extensions you want (e.g., ['.js', '.jsx']).","message":"If the `resolve` option is not provided, local aliases implicitly append '.js' extension. Other extensions like '.jsx' or '.ts' are not tried.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure this plugin is placed early in the plugins array, before any plugin that transforms imports.","message":"The plugin replaces import specifiers before other plugins run. If another plugin later modifies the specifier, the alias may not apply.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install rollup-plugin-strict-alias --save-dev` or add to package.json dependencies.","cause":"The package is not installed or not in node_modules.","error":"Error: Cannot find module 'rollup-plugin-strict-alias'"},{"fix":"Change to `import alias from 'rollup-plugin-strict-alias'`.","cause":"Using named import { alias } instead of default import.","error":"TypeError: alias is not a function"},{"fix":"Check the path and ensure the file exists with an extension included in the `resolve` option. Use absolute paths if needed.","cause":"The aliased local path does not exist or the file extension is missing.","error":"(!) Plugin strict-alias: Could not resolve './some/path' from 'CWD'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}