From e776afa02ea5a1b188598f7b05d8d6763a56a395 Mon Sep 17 00:00:00 2001 From: lisonge Date: Fri, 7 Jun 2024 10:48:37 +0800 Subject: [PATCH 1/4] fix: invalid import.meta.url when build (#163) --- packages/vite-plugin-monkey/src/client/window.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/vite-plugin-monkey/src/client/window.ts b/packages/vite-plugin-monkey/src/client/window.ts index e7ca5850..be51ca09 100644 --- a/packages/vite-plugin-monkey/src/client/window.ts +++ b/packages/vite-plugin-monkey/src/client/window.ts @@ -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; From 1de048b09e2cbf7c81736e8c2aa31fbcfad3b6b3 Mon Sep 17 00:00:00 2001 From: lisonge Date: Fri, 7 Jun 2024 10:50:22 +0800 Subject: [PATCH 2/4] chore: v4.0.1 --- packages/vite-plugin-monkey/CHANGELOG.md | 10 ++-------- packages/vite-plugin-monkey/package.json | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/vite-plugin-monkey/CHANGELOG.md b/packages/vite-plugin-monkey/CHANGELOG.md index b4e1c91f..d922cf23 100644 --- a/packages/vite-plugin-monkey/CHANGELOG.md +++ b/packages/vite-plugin-monkey/CHANGELOG.md @@ -1,11 +1,5 @@ -# v4.0.0 - -## Breaking Changes - -- drop commonjs support, now it is esm only -- require vite `^5.0.0` +# v4.0.1 ## 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: invalid import.meta.url when build (#163) diff --git a/packages/vite-plugin-monkey/package.json b/packages/vite-plugin-monkey/package.json index d81f4835..78c7a422 100644 --- a/packages/vite-plugin-monkey/package.json +++ b/packages/vite-plugin-monkey/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-monkey", - "version": "4.0.0", + "version": "4.0.1", "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", From 6929f5dc93976aad686379b1d6de7b5aa9f02014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=9C=E6=AA=B8Cirtron?= <45784494+lcandy2@users.noreply.github.com> Date: Mon, 3 Jun 2024 20:01:21 +0800 Subject: [PATCH 3/4] fix: zhimg cdn use the url like unpkg --- packages/vite-plugin-monkey/src/node/cdn.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite-plugin-monkey/src/node/cdn.ts b/packages/vite-plugin-monkey/src/node/cdn.ts index c47b5c1b..860d3389 100644 --- a/packages/vite-plugin-monkey/src/node/cdn.ts +++ b/packages/vite-plugin-monkey/src/node/cdn.ts @@ -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}`; }, ]; }; From fc166416f503bcf66c2f430703fc07b864b27a6a Mon Sep 17 00:00:00 2001 From: lisonge Date: Fri, 7 Jun 2024 10:58:21 +0800 Subject: [PATCH 4/4] chore: v4.0.2 --- packages/vite-plugin-monkey/CHANGELOG.md | 4 ++-- packages/vite-plugin-monkey/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/vite-plugin-monkey/CHANGELOG.md b/packages/vite-plugin-monkey/CHANGELOG.md index d922cf23..286fd156 100644 --- a/packages/vite-plugin-monkey/CHANGELOG.md +++ b/packages/vite-plugin-monkey/CHANGELOG.md @@ -1,5 +1,5 @@ -# v4.0.1 +# v4.0.2 ## Bug Fixes -- fix: invalid import.meta.url when build (#163) +- fix: zhimg cdn use the url like unpkg (#160) diff --git a/packages/vite-plugin-monkey/package.json b/packages/vite-plugin-monkey/package.json index 78c7a422..d10ea936 100644 --- a/packages/vite-plugin-monkey/package.json +++ b/packages/vite-plugin-monkey/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-monkey", - "version": "4.0.1", + "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",