一覧へ戻る
patrickhulce/rollup-plugin-shim(新しいタブで開きます)
主要言語: JavaScript
Plugin for rollup to provide a shim implementation for a module.
- star 数
- 3
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 14
- 最終更新
- 2022/12/07
主要言語: JavaScript
Plugin for rollup to provide a shim implementation for a module.
Plugin for rollup to provide a shim implementation for a module. Replaces required dependencies with the specified string instead, especially useful for shimming small dev-time APIs with a big footprint you don't want in production (like debug). For larger fully functional implementations that you want to use a file for you might want to consider the rollup-plugin-alias package instead.
yarn add -D rollup-plugin-shim
src/main.js
import {writeFileSync} from 'fs' import debug from 'debug' import {bigFunction} from './local-dep' const log = debug('mypackage:main') // ...
rollup.config.js
import {join} from 'path' import shim from 'rollup-plugin-shim' export default { entry: 'src/main.js', plugins: [ shim({ // replace fs with a noop shim fs: `export function writeFileSync() { }`, // replace debug to return a noop function debug: `export default () => () => undefined`, // replace a local dependency with a noop // can also use './local-dep' as the key if that's the only way it's required [join(__dirname, 'src/local-dep')]: `export function bigFunction() { }`, }), ], }