Skip to content

Commit 5348c02

Browse files
fix(plugin-legacy): turn off babel loose mode (#3406)
1 parent 5fe0550 commit 5348c02

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

packages/playground/legacy/__tests__/legacy.spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ test('should work', async () => {
77
test('import.meta.env.LEGACY', async () => {
88
expect(await page.textContent('#env')).toMatch(isBuild ? 'true' : 'false')
99
})
10+
11+
// https://github.com/vitejs/vite/issues/3400
12+
test('transpiles down iterators correctly', async () => {
13+
expect(await page.textContent('#iterators')).toMatch('hello')
14+
})

packages/playground/legacy/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<h1 id="app"></h1>
22
<div id="env"></div>
3+
<div id="iterators"></div>
34
<script type="module" src="./main.js"></script>

packages/playground/legacy/main.js

+6
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ if (import.meta.env.LEGACY) {
1515
}
1616

1717
document.getElementById('env').textContent = `is legacy: ${isLegacy}`
18+
19+
// Iterators
20+
21+
document.getElementById('iterators').textContent = [...new Set(['hello'])].join(
22+
''
23+
)

packages/plugin-legacy/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function viteLegacyPlugin(options = {}) {
263263
targets,
264264
modules: false,
265265
bugfixes: true,
266-
loose: true,
266+
loose: false,
267267
useBuiltIns: needPolyfills ? 'usage' : false,
268268
corejs: needPolyfills
269269
? { version: 3, proposals: false }

0 commit comments

Comments
 (0)