From 732120abe033ce291c3fc22b53d859f1d3a886c7 Mon Sep 17 00:00:00 2001 From: Nihal Gonsalves Date: Thu, 13 May 2021 14:06:07 +0200 Subject: [PATCH 1/2] fix: turn off babel loose mode Info: https://github.com/babel/babel/issues/7958 --- packages/plugin-legacy/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 60dee775aaa5d2..1f937df06e515c 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -248,7 +248,7 @@ function viteLegacyPlugin(options = {}) { targets, modules: false, bugfixes: true, - loose: true, + loose: false, useBuiltIns: needPolyfills ? 'usage' : false, corejs: needPolyfills ? { version: 3, proposals: false } From bd10d603117c1fda8dac1bee28ea3162ea96cce7 Mon Sep 17 00:00:00 2001 From: Nihal Gonsalves Date: Thu, 13 May 2021 14:34:29 +0200 Subject: [PATCH 2/2] test: add set down-transpile test --- packages/playground/legacy/__tests__/legacy.spec.ts | 5 +++++ packages/playground/legacy/index.html | 1 + packages/playground/legacy/main.js | 6 ++++++ 3 files changed, 12 insertions(+) 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( + '' +)