FlandreDaisuki/rollup-plugin-userscript-metablock(opens in a new tab)
Language: JavaScript
Transform json file to userscript metablock and append on.
- stars
- 36
- watchers
- 1
- forks
- 7
- open issues
- 1
- Last updated
- 10/22/2026
Language: JavaScript
Transform json file to userscript metablock and append on.
Transform json file to userscript metablock and append on.
Metakeys documents:
npm install --save-dev rollup-plugin-userscript-metablock
simplest
import metablock from 'rollup-plugin-userscript-metablock'; export default { input: 'main.js', output: { file: 'bundle.user.js', format: 'esm' }, plugins: [metablock()], };
common
import metablock from 'rollup-plugin-userscript-metablock'; import pkg from './package.json' with { type: 'json' }; export default { input: 'main.js', output: { file: 'bundle.user.js', format: 'esm' }, plugins: [metablock({ file: './meta.json', override: { name: pkg.name, version: pkg.version, description: pkg.description, homepage: pkg.homepage, author: pkg.author, license: pkg.license, } })], };
You can find the options detail here, and meta details here.
JSON metadata files can reference the schema shipped with this package for editor completion and validation. The file itself is the metadata object, so its top-level properties are metakeys without the leading @:
{
"$schema": "https://cdn.jsdelivr.net/npm/rollup-plugin-userscript-metablock@latest/userscript-metadata.schema.json",
"name": "My userscript",
"match": "https://example.com/*",
"grant": "none"
}The same schema is also available from UNPKG. The plugin ignores the $schema property when it renders the metablock.
The file option also accepts .js, .mjs, and .cjs modules. Use defineMetadata to get IDE auto-completion:
// metablock.mjs import { defineMetadata } from 'rollup-plugin-userscript-metablock'; export default defineMetadata({ name: 'My userscript', grant: 'none', });
// metablock.cjs const { defineMetadata } = require('rollup-plugin-userscript-metablock'); module.exports = defineMetadata({ name: 'My userscript', grant: 'none', });
This plugin also works with Rolldown. See the complete Rolldown example.
@grant none explicitly
MIT