From 5508dbbeb05c0815758d3ae846c89e6a774a97a0 Mon Sep 17 00:00:00 2001 From: Nihal Gonsalves Date: Mon, 17 May 2021 16:13:21 +0200 Subject: [PATCH] fix(plugin-legacy): turn off babel loose mode (#3406) --- packages/playground/legacy/__tests__/legacy.spec.ts | 5 +++++ packages/playground/legacy/index.html | 1 + packages/playground/legacy/main.js | 6 ++++++ packages/plugin-legacy/index.js | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/playground/legacy/__tests__/legacy.spec.ts b/packages/playground/legacy/__tests__/legacy.spec.ts index aff02741711964..0a9a214808c666 100644 --- a/packages/playground/legacy/__tests__/legacy.spec.ts +++ b/packages/playground/legacy/__tests__/legacy.spec.ts @@ -7,3 +7,8 @@ test('should work', async () => { test('import.meta.env.LEGACY', async () => { expect(await page.textContent('#env')).toMatch(isBuild ? 'true' : 'false') }) + +// https://github.com/vitejs/vite/issues/3400 +test('transpiles down iterators correctly', async () => { + expect(await page.textContent('#iterators')).toMatch('hello') +}) diff --git a/packages/playground/legacy/index.html b/packages/playground/legacy/index.html index aef4bccfc61f74..b2e2c85155799f 100644 --- a/packages/playground/legacy/index.html +++ b/packages/playground/legacy/index.html @@ -1,3 +1,4 @@

+
diff --git a/packages/playground/legacy/main.js b/packages/playground/legacy/main.js index 631f589eb541d8..18db0a9b7b84c7 100644 --- a/packages/playground/legacy/main.js +++ b/packages/playground/legacy/main.js @@ -15,3 +15,9 @@ if (import.meta.env.LEGACY) { } document.getElementById('env').textContent = `is legacy: ${isLegacy}` + +// Iterators + +document.getElementById('iterators').textContent = [...new Set(['hello'])].join( + '' +) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 1b449c963dda4f..cb21e5f63ec42a 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -263,7 +263,7 @@ function viteLegacyPlugin(options = {}) { targets, modules: false, bugfixes: true, - loose: true, + loose: false, useBuiltIns: needPolyfills ? 'usage' : false, corejs: needPolyfills ? { version: 3, proposals: false }