From 458f4931508516e025c935a519c9493aefaded9a Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 6 Sep 2022 15:31:17 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E4=BD=BF=E7=94=A8esbuildOptions?= =?UTF-8?q?=E5=AE=9A=E4=B9=89global?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/index.ts | 2 -- packages/editor/src/utils/polyfills.ts | 8 -------- packages/editor/vite.config.ts | 8 ++++++++ playground/src/main.ts | 2 -- playground/src/polyfills.ts | 21 --------------------- playground/vite.config.ts | 10 +++++++++- 6 files changed, 17 insertions(+), 34 deletions(-) delete mode 100644 packages/editor/src/utils/polyfills.ts delete mode 100644 playground/src/polyfills.ts diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts index 1baf1efb..ae4f1ebd 100644 --- a/packages/editor/src/index.ts +++ b/packages/editor/src/index.ts @@ -15,8 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import './utils/polyfills'; - import { App } from 'vue'; import Code from './fields/Code.vue'; diff --git a/packages/editor/src/utils/polyfills.ts b/packages/editor/src/utils/polyfills.ts deleted file mode 100644 index 2fb45308..00000000 --- a/packages/editor/src/utils/polyfills.ts +++ /dev/null @@ -1,8 +0,0 @@ -// serialize-javascript 依赖的 randombytes 依赖全局的 global 对象,因此此处需添加 global polyfill -if (typeof global === 'undefined') { - (window as any).global = window; -} - -if (typeof globalThis === 'undefined') { - (window as any).globalThis = window; -} diff --git a/packages/editor/vite.config.ts b/packages/editor/vite.config.ts index f89f5329..a8e12300 100644 --- a/packages/editor/vite.config.ts +++ b/packages/editor/vite.config.ts @@ -39,6 +39,14 @@ export default defineConfig({ ], }, + optimizeDeps: { + esbuildOptions: { + define: { + global: 'globalThis', + }, + }, + }, + build: { cssCodeSplit: false, sourcemap: true, diff --git a/playground/src/main.ts b/playground/src/main.ts index e0d3d7ae..8fbd434a 100644 --- a/playground/src/main.ts +++ b/playground/src/main.ts @@ -16,8 +16,6 @@ * limitations under the License. */ -import './polyfills'; - import { createApp } from 'vue'; import ElementPlus from 'element-plus'; import zhCn from 'element-plus/es/locale/lang/zh-cn'; diff --git a/playground/src/polyfills.ts b/playground/src/polyfills.ts deleted file mode 100644 index a33ab86a..00000000 --- a/playground/src/polyfills.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making TMagicEditor available. - * - * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -if (typeof (window as any).global === 'undefined') { - (window as any).global = window; -} diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 8b7734ac..b28210c8 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -33,7 +33,7 @@ export default defineConfig({ }), ], - base: '/tmagic-editor/playground', + base: '/tmagic-editor/playground/', resolve: { alias: [ @@ -53,6 +53,14 @@ export default defineConfig({ ], }, + optimizeDeps: { + esbuildOptions: { + define: { + global: 'globalThis', + }, + }, + }, + server: { fs: { strict: false,