From 0fd64223304442bb483c55d818fcf808b7ffbaa8 Mon Sep 17 00:00:00 2001 From: Svilen Ivanov Date: Thu, 10 Mar 2022 07:33:42 +0200 Subject: [PATCH] docs(vite-legacy): Note about using `regenerator-runtime` in Content Security Policy environment (#7234) Co-authored-by: Bjorn Lu --- packages/plugin-legacy/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/plugin-legacy/README.md b/packages/plugin-legacy/README.md index c56b769061e267..b5bf572e53fa2c 100644 --- a/packages/plugin-legacy/README.md +++ b/packages/plugin-legacy/README.md @@ -173,6 +173,8 @@ These values (without the `sha256-` prefix) can also be retrieved via const { cspHashes } = require('@vitejs/plugin-legacy') ``` +When using the `regenerator-runtime` polyfill, it will attempt to use the `globalThis` object to register itself. If `globalThis` is not available (it is [fairly new](https://caniuse.com/?search=globalThis) and not widely supported, including IE 11), it attempts to perform dynamic `Function(...)` call which violates the CSP. To avoid dynamic `eval` in the absence of `globalThis` consider adding `core-js/proposals/global-this` to `additionalLegacyPolyfills` to define it. + ## References - [Vue CLI modern mode](https://cli.vuejs.org/guide/browser-compatibility.html#modern-mode)