Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.01 KB

File metadata and controls

32 lines (22 loc) · 1.01 KB

rolldown-plugin-userscript

Warning

I broke the automatically setting @grants part and this breaks in production due to Rolldown stripping the comments. Probably just use Rollup instead of using this, rollup-plugin-userscript should work with Rolldown anyway.

NPM License Downloads

Automatically parse metadata and set @grants.

With this plugin, @grants for GM_* functions will be added at compile time.

Usage

Add the plugin to rolldown.config.js:

import userscript from 'rolldown-plugin-userscript';

const plugins = [
  // ...
  userscript(meta => meta.replace('process.env.AUTHOR', pkg.author)),
];

Import the metadata file with a suffix ?userscript-metadata in your script:

import './meta.js?userscript-metadata';