Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Dev to Main #164

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/vite-plugin-monkey/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# v4.0.0

## Breaking Changes

- drop commonjs support, now it is esm only
- require vite `^5.0.0`
# v4.0.2

## Bug Fixes

- module can not be resolved if it is only esm
- use jsdelivr to replace bootcdn because bootcdn will return virus-infected code
- fix: zhimg cdn use the url like unpkg (#160)
2 changes: 1 addition & 1 deletion packages/vite-plugin-monkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-monkey",
"version": "4.0.0",
"version": "4.0.2",
"description": "A vite plugin server and build your.user.js for userscript engine like Tampermonkey and Violentmonkey and Greasemonkey",
"main": "dist/node/index.mjs",
"types": "dist/node/index.d.ts",
Expand Down
11 changes: 9 additions & 2 deletions packages/vite-plugin-monkey/src/client/window.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { MonkeyWindow } from './types';
import type { MonkeyWindow } from './types';

const key =
`__monkeyWindow-` + new URL(import.meta.url || location.href).origin;
`__monkeyWindow-` +
(() => {
try {
return new URL(import.meta.url).origin;
} catch {
return location.origin;
}
})();

// @ts-ignore
export const monkeyWindow: MonkeyWindow = document[key] ?? window;
2 changes: 1 addition & 1 deletion packages/vite-plugin-monkey/src/node/cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export const zhimg = (
exportVarName,
(version, name, _importName = '', resolveName = '') => {
const p = pathname || resolveName;
return `https://unpkg.zhimg.com/${name}/${version}/${p}`;
return `https://unpkg.zhimg.com/${name}@${version}/${p}`;
},
];
};
Expand Down
Loading