From 8a898593c74f2712d5386714a1e58dc1a4f2b6b2 Mon Sep 17 00:00:00 2001 From: zhangtao25 Date: Thu, 21 Nov 2024 19:45:11 +0800 Subject: [PATCH] feat: update --- plugins/vite-plugin-canyon/package.json | 2 +- plugins/vite-plugin-canyon/src/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/vite-plugin-canyon/package.json b/plugins/vite-plugin-canyon/package.json index 6f4f7675..a5db418c 100644 --- a/plugins/vite-plugin-canyon/package.json +++ b/plugins/vite-plugin-canyon/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-canyon", - "version": "0.0.1-alpha.13", + "version": "0.0.1-alpha.14", "license": "MIT", "files": [ "dist/*" diff --git a/plugins/vite-plugin-canyon/src/index.ts b/plugins/vite-plugin-canyon/src/index.ts index ed626fc7..be6cae25 100644 --- a/plugins/vite-plugin-canyon/src/index.ts +++ b/plugins/vite-plugin-canyon/src/index.ts @@ -42,7 +42,7 @@ function instrumentedData(args: canyonPluginOptions): string { // 自动获取 instrumentCwd: args.instrumentCwd || process.cwd(), } - return `(new Function("return this")()).__canyon__ = ${JSON.stringify(canyon)}`; + return `(function () {var isBrowser = typeof window!== 'undefined';var globalObj = isBrowser? window : global;return globalObj})().__canyon__ = ${JSON.stringify(canyon)}`; } export default function canyonPlugin(opts: canyonPluginOptions = {}): Plugin {