
Security News
Free Certified Patch for Critical Rails Active Storage Vulnerability
Socket has released a free Certified Patch for a critical Rails Active Storage vulnerability, giving developers time to upgrade to a secure Rails version.
rollup-plugin-magic-string
Advanced tools
string mutation plugin for rollup
# npm
npm install -D rollup-plugin-magic-string
# yarn
yarn add -D rollup-plugin-magic-string
The default functionality gives you a magic-string object from the code of a module and allows you to perform any operations that magic-string supports.
Most often, you'll want to perform one of these very common operations. This module provides shortcut access to these, and thanks to magic-string, they are fully source-map supported.
import { append } from 'rollup-plugin-magic-string'
export default {
// ... rollup config here
plugins: [append('THE END' /*, [options] */)],
}
import { prepend } from 'rollup-plugin-magic-string'
export default {
// ... rollup config here
plugins: [prepend('Hi there\n\n' /*, [options] */)],
}
import { wrap } from 'rollup-plugin-magic-string'
export default {
// ... rollup config here
plugins: [wrap('THE GAME', 'Ha, made you lose!')],
}
The above are useful shorthands, however as mentioned this plugin really gives you access to any operation that magic-string supports:
import magicString from 'rollup-plugin-magic-string'
rollup({
plugins: [
magicString(
/* options = */ {
// `magic` MUST be a function and is required
magic(code, id, string) {
// `code` is the source code of a module
// `id` is the id of that module
// `string` is an instance of MagicString that wraps `code`
// you can now use `string` to do all kinds of string manipulations
string.overwrite(0, 5, 'ABC').indent(' ')
},
// The options `include`, `exclude` and `sourceMap` are also supported
// and behave as you would expect from a rollup plugin.
},
),
],
})
FAQs
magic-string plugin for rollup
The npm package rollup-plugin-magic-string receives a total of 0 weekly downloads. As such, rollup-plugin-magic-string popularity was classified as not popular.
We found that rollup-plugin-magic-string demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Socket has released a free Certified Patch for a critical Rails Active Storage vulnerability, giving developers time to upgrade to a secure Rails version.

Security News
/Threat Research
A malicious Ruby gem runs a credential-stealing worm during installation, poisons AI coding tools, and can wipe files when a stolen GitHub token is revoked.

Security News
GitHub is tightening GitHub Actions security with new restrictions on privileged pull request workflows. Here's what changes and how maintainers are affected.