-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(legacy): fix broken build when renderModernChunks=false & polyfil…
- Loading branch information
Showing
10 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
playground/legacy/__tests__/no-polyfills-no-systemjs/no-polyfills-no-systemjs.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect, test } from 'vitest' | ||
import { isBuild, page, untilUpdated, viteTestUrl } from '~utils' | ||
|
||
test.runIf(isBuild)('includes only a single script tag', async () => { | ||
await page.goto(viteTestUrl + '/no-polyfills-no-systemjs.html') | ||
|
||
await untilUpdated( | ||
() => page.getAttribute('#vite-legacy-entry', 'data-src'), | ||
/.\/assets\/index-legacy-(.+)\.js/, | ||
true, | ||
) | ||
|
||
expect(await page.locator('script').count()).toBe(1) | ||
expect(await page.locator('#vite-legacy-polyfill').count()).toBe(0) | ||
expect(await page.locator('#vite-legacy-entry').count()).toBe(1) | ||
}) |
20 changes: 20 additions & 0 deletions
20
playground/legacy/__tests__/no-polyfills/no-polyfills.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { test } from 'vitest' | ||
import { isBuild, page, untilUpdated, viteTestUrl } from '~utils' | ||
|
||
test('should load and execute the JS file', async () => { | ||
await page.goto(viteTestUrl + '/no-polyfills.html') | ||
await untilUpdated(() => page.textContent('main'), '👋', true) | ||
}) | ||
|
||
test.runIf(isBuild)('includes a script tag for SystemJS', async () => { | ||
await untilUpdated( | ||
() => page.getAttribute('#vite-legacy-polyfill', 'src'), | ||
/.\/assets\/polyfills-legacy-(.+)\.js/, | ||
true, | ||
) | ||
await untilUpdated( | ||
() => page.getAttribute('#vite-legacy-entry', 'data-src'), | ||
/.\/assets\/index-legacy-(.+)\.js/, | ||
true, | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<meta charset="UTF-8" /> | ||
<main></main> | ||
<script type="module" src="./no-polyfills-no-systemjs.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
document.querySelector('main').innerHTML = '👋' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<meta charset="UTF-8" /> | ||
<main></main> | ||
<script type="module" src="./no-polyfills.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
document.querySelector('main').innerHTML = '👋' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import path from 'node:path' | ||
import legacy from '@vitejs/plugin-legacy' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
base: './', | ||
plugins: [ | ||
legacy({ | ||
renderModernChunks: false, | ||
polyfills: false, | ||
externalSystemJS: true, | ||
}), | ||
{ | ||
name: 'remove crossorigin attribute', | ||
transformIndexHtml: (html) => html.replaceAll('crossorigin', ''), | ||
enforce: 'post', | ||
}, | ||
], | ||
|
||
build: { | ||
rollupOptions: { | ||
input: { | ||
index: path.resolve(__dirname, 'no-polyfills-no-systemjs.html'), | ||
}, | ||
}, | ||
}, | ||
testConfig: { | ||
baseRoute: '/no-polyfills-no-systemjs/', | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import path from 'node:path' | ||
import legacy from '@vitejs/plugin-legacy' | ||
import { defineConfig } from 'vite' | ||
|
||
export default defineConfig({ | ||
base: './', | ||
plugins: [ | ||
legacy({ | ||
renderModernChunks: false, | ||
polyfills: false, | ||
}), | ||
{ | ||
name: 'remove crossorigin attribute', | ||
transformIndexHtml: (html) => html.replaceAll('crossorigin', ''), | ||
enforce: 'post', | ||
}, | ||
], | ||
|
||
build: { | ||
rollupOptions: { | ||
input: { | ||
index: path.resolve(__dirname, 'no-polyfills.html'), | ||
}, | ||
}, | ||
}, | ||
testConfig: { | ||
baseRoute: '/no-polyfills/', | ||
}, | ||
}) |