lisonge / vite-plugin-monkey

A vite plugin server and build your.user.js for userscript engine like Tampermonkey, Violentmonkey, Greasemonkey, ScriptCat
MIT License
1.33k stars 70 forks source link

Userscript has incorrect name if `author` in package.json is specified as object #38

Closed 7nik closed 1 year ago

7nik commented 1 year ago

The author field in package.json can be specified as a string or the object

{
  name: string,
  email?: string,
  url?: string,
}

In the latter case, the author.name is used as the userscript name instead of the name field from package.json which is of course incorrect.

Example

If package.json has the following fields:

"name": "script_name",
"author": {
  "name": "author_name"
},

the userscript will be compiler with the name author_name instead of script_name.

lisonge commented 1 year ago

https://github.com/lisonge/vite-plugin-monkey/blob/2db294c01461a7134aa675d5a88bdabad18cd835/packages/vite-plugin-monkey/src/node/_util.ts#L113 should be

target.author = rawTarget.author?.name;
lisonge commented 1 year ago

fixed by v2.10.2