diff --git a/package.json b/package.json index 012b8de948046d..82a6846dcc5120 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "@types/micromatch": "^4.0.6", "@types/node": "^20.10.4", "@types/picomatch": "^2.3.3", - "@types/semver": "^7.5.6", "@types/sass": "~1.43.1", + "@types/semver": "^7.5.6", "@types/stylus": "^0.48.42", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^6.14.0", @@ -118,13 +118,18 @@ "acorn-walk": { "peerDependencies": { "acorn": "*" + }, + "peerDependenciesMeta": { + "acorn": { + "optional": true + } } } }, "patchedDependencies": { "chokidar@3.5.3": "patches/chokidar@3.5.3.patch", - "sirv@2.0.3": "patches/sirv@2.0.3.patch", - "dotenv-expand@10.0.0": "patches/dotenv-expand@10.0.0.patch" + "dotenv-expand@10.0.0": "patches/dotenv-expand@10.0.0.patch", + "sirv@2.0.4": "patches/sirv@2.0.4.patch" }, "peerDependencyRules": { "allowedVersions": { diff --git a/packages/vite/LICENSE.md b/packages/vite/LICENSE.md index 15f396ecec8e2d..3964a1d86b9ebc 100644 --- a/packages/vite/LICENSE.md +++ b/packages/vite/LICENSE.md @@ -463,28 +463,6 @@ License: MIT By: Luke Edwards Repository: lukeed/polka -> The MIT License (MIT) -> -> Copyright (c) Luke Edwards (https://lukeed.com) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - --------------------------------------- ## @rollup/plugin-alias diff --git a/packages/vite/package.json b/packages/vite/package.json index 295f4832bfd5b5..8ff40d10af69df 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -118,7 +118,7 @@ "magic-string": "^0.30.5", "micromatch": "^4.0.5", "mlly": "^1.4.2", - "mrmime": "^1.0.1", + "mrmime": "^2.0.0", "okie": "^1.0.1", "open": "^8.4.2", "parse5": "^7.1.2", @@ -131,7 +131,7 @@ "resolve.exports": "^2.0.2", "rollup-plugin-dts": "^6.1.0", "rollup-plugin-license": "^3.2.0", - "sirv": "^2.0.3", + "sirv": "^2.0.4", "source-map-support": "^0.5.21", "strip-ansi": "^7.1.0", "strip-literal": "^2.0.0", diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index afc0cb8a9b8d47..9295bb9a4407dc 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -57,10 +57,6 @@ export function registerCustomMime(): void { mrmime.mimes['ico'] = 'image/x-icon' // https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#flac mrmime.mimes['flac'] = 'audio/flac' - // mrmime and mime-db is not released yet: https://github.com/jshttp/mime-db/commit/c9242a9b7d4bb25d7a0c9244adec74aeef08d8a1 - mrmime.mimes['aac'] = 'audio/aac' - // https://wiki.xiph.org/MIME_Types_and_File_Extensions#.opus_-_audio/ogg - mrmime.mimes['opus'] = 'audio/ogg' // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types mrmime.mimes['eot'] = 'application/vnd.ms-fontobject' } diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 24cebe7a1b6471..f1a202d59623b0 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -324,7 +324,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { return worker; } catch(e) { return new ${workerConstructor}( - "data:application/javascript;base64," + encodedJs, + "data:text/javascript;base64," + encodedJs, ${workerTypeOption} ); }${ @@ -340,7 +340,7 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin { : `${encodedJs} export default function WorkerWrapper(options) { return new ${workerConstructor}( - "data:application/javascript;base64," + encodedJs, + "data:text/javascript;base64," + encodedJs, ${workerTypeOption} ); } diff --git a/packages/vite/src/node/server/middlewares/static.ts b/packages/vite/src/node/server/middlewares/static.ts index dde6842aa95533..8c94e53dd0a7c3 100644 --- a/packages/vite/src/node/server/middlewares/static.ts +++ b/packages/vite/src/node/server/middlewares/static.ts @@ -40,7 +40,7 @@ const sirvOptions = ({ // these files to be TypeScript files, and for Vite to serve them with // this Content-Type. if (knownJavascriptExtensionRE.test(pathname)) { - res.setHeader('Content-Type', 'application/javascript') + res.setHeader('Content-Type', 'text/javascript') } const headers = getHeaders() if (headers) { diff --git a/packages/vite/src/node/server/send.ts b/packages/vite/src/node/server/send.ts index 033b9f317a60d3..cf64889c15dfb7 100644 --- a/packages/vite/src/node/server/send.ts +++ b/packages/vite/src/node/server/send.ts @@ -16,7 +16,7 @@ const debug = createDebugger('vite:send', { }) const alias: Record = { - js: 'application/javascript', + js: 'text/javascript', css: 'text/css', html: 'text/html', json: 'application/json', diff --git a/patches/sirv@2.0.3.patch b/patches/sirv@2.0.4.patch similarity index 99% rename from patches/sirv@2.0.3.patch rename to patches/sirv@2.0.4.patch index 0a758e89369c9c..d6cf2c64ab7751 100644 --- a/patches/sirv@2.0.3.patch +++ b/patches/sirv@2.0.4.patch @@ -70,4 +70,4 @@ index c05040fc6ec504a1828a7badd39f669981acd0ee..e9597e8b5bf24613a09565f0e13024ae + shouldServe?: (absoluteFilePath: string) => void; } - export default function(dir?: string, opts?: Options): RequestHandler; \ No newline at end of file + export default function(dir?: string, opts?: Options): RequestHandler; diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index 98ec4e39826b87..51b8c336ef96d0 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -353,9 +353,7 @@ test('?url import', async () => { const src = readFile('foo.js') expect(await page.textContent('.url')).toMatch( isBuild - ? `data:application/javascript;base64,${Buffer.from(src).toString( - 'base64', - )}` + ? `data:text/javascript;base64,${Buffer.from(src).toString('base64')}` : `/foo/bar/foo.js`, ) }) @@ -375,9 +373,7 @@ describe('unicode url', () => { const src = readFile('テスト-測試-white space.js') expect(await page.textContent('.unicode-url')).toMatch( isBuild - ? `data:application/javascript;base64,${Buffer.from(src).toString( - 'base64', - )}` + ? `data:text/javascript;base64,${Buffer.from(src).toString('base64')}` : `/foo/bar/テスト-測試-white space.js`, ) }) @@ -408,7 +404,7 @@ test('new URL("/...", import.meta.url)', async () => { test('new URL(..., import.meta.url) without extension', async () => { expect(await page.textContent('.import-meta-url-without-extension')).toMatch( - isBuild ? 'data:application/javascript' : 'nested/test.js', + isBuild ? 'data:text/javascript' : 'nested/test.js', ) expect( await page.textContent('.import-meta-url-content-without-extension'), @@ -423,7 +419,7 @@ test('new URL(`${dynamic}`, import.meta.url)', async () => { assetMatch, ) expect(await page.textContent('.dynamic-import-meta-url-js')).toMatch( - isBuild ? 'data:application/javascript;base64' : '/foo/bar/nested/test.js', + isBuild ? 'data:text/javascript;base64' : '/foo/bar/nested/test.js', ) }) diff --git a/playground/dynamic-import/__tests__/dynamic-import.spec.ts b/playground/dynamic-import/__tests__/dynamic-import.spec.ts index c8c97254a75f02..3892251bfd2e41 100644 --- a/playground/dynamic-import/__tests__/dynamic-import.spec.ts +++ b/playground/dynamic-import/__tests__/dynamic-import.spec.ts @@ -118,7 +118,7 @@ test('should load dynamic import with vars raw', async () => { test('should load dynamic import with vars url', async () => { await untilUpdated( () => page.textContent('.dynamic-import-with-vars-url'), - isBuild ? 'data:application/javascript' : '/alias/url.js', + isBuild ? 'data:text/javascript' : '/alias/url.js', true, ) }) diff --git a/playground/external/vite.config.js b/playground/external/vite.config.js index 2d470f8eea4d36..7694669f91faa7 100644 --- a/playground/external/vite.config.js +++ b/playground/external/vite.config.js @@ -12,7 +12,7 @@ const serveNpmCodeDirectlyMiddleware = async (req, res, next) => { const code = await fs.readFile( new URL(`./node_modules/${file}`, import.meta.url), ) - res.setHeader('Content-Type', 'application/javascript') + res.setHeader('Content-Type', 'text/javascript') res.end(code) return } diff --git a/playground/legacy/__tests__/legacy.spec.ts b/playground/legacy/__tests__/legacy.spec.ts index b0cc061b289d6c..cc747761588ca5 100644 --- a/playground/legacy/__tests__/legacy.spec.ts +++ b/playground/legacy/__tests__/legacy.spec.ts @@ -56,8 +56,8 @@ test('generates assets', async () => { 'index-legacy: text/html', 'chunk-async: text/html', 'chunk-async-legacy: text/html', - 'immutable-chunk: application/javascript', - 'immutable-chunk-legacy: application/javascript', + 'immutable-chunk: text/javascript', + 'immutable-chunk-legacy: text/javascript', 'polyfills-legacy: text/html', ].join('\n') : [ diff --git a/playground/lib/package.json b/playground/lib/package.json index a38060db5e43f2..5765873ebd503c 100644 --- a/playground/lib/package.json +++ b/playground/lib/package.json @@ -10,6 +10,6 @@ "preview": "vite preview" }, "devDependencies": { - "sirv": "^2.0.3" + "sirv": "^2.0.4" } } diff --git a/playground/worker/__tests__/es/es-worker.spec.ts b/playground/worker/__tests__/es/es-worker.spec.ts index 7ffd7ae6df0f20..0031c432c36b7a 100644 --- a/playground/worker/__tests__/es/es-worker.spec.ts +++ b/playground/worker/__tests__/es/es-worker.spec.ts @@ -126,7 +126,7 @@ describe.runIf(isBuild)('build', () => { ) // inlined shared worker expect(content).toMatch( - `return new SharedWorker("data:application/javascript;base64,"+`, + `return new SharedWorker("data:text/javascript;base64,"+`, ) }) diff --git a/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts b/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts index 6d9a6ee55664d6..157d9f7d47b26a 100644 --- a/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts +++ b/playground/worker/__tests__/sourcemap-hidden/sourcemap-hidden-worker.spec.ts @@ -94,7 +94,7 @@ describe.runIf(isBuild)('build', () => { expect(content).toMatch( `new Worker("/iife-sourcemap-hidden/assets/my-worker`, ) - expect(content).toMatch(`new Worker("data:application/javascript;base64`) + expect(content).toMatch(`new Worker("data:text/javascript;base64`) expect(content).toMatch( `new Worker("/iife-sourcemap-hidden/assets/possible-ts-output-worker`, ) diff --git a/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts b/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts index 0bfa3ca3b8b816..9a10908abdc1ec 100644 --- a/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts +++ b/playground/worker/__tests__/sourcemap-inline/sourcemap-inline-worker.spec.ts @@ -75,7 +75,7 @@ describe.runIf(isBuild)('build', () => { expect(content).toMatch( `new Worker("/iife-sourcemap-inline/assets/my-worker`, ) - expect(content).toMatch(`new Worker("data:application/javascript;base64`) + expect(content).toMatch(`new Worker("data:text/javascript;base64`) expect(content).toMatch( `new Worker("/iife-sourcemap-inline/assets/possible-ts-output-worker`, ) diff --git a/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts b/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts index a9be2c75611079..0dd723413e5a4c 100644 --- a/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts +++ b/playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts @@ -95,7 +95,7 @@ describe.runIf(isBuild)('build', () => { // chunk expect(content).toMatch(`new Worker("/iife-sourcemap/assets/my-worker`) - expect(content).toMatch(`new Worker("data:application/javascript;base64`) + expect(content).toMatch(`new Worker("data:text/javascript;base64`) expect(content).toMatch( `new Worker("/iife-sourcemap/assets/possible-ts-output-worker`, ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75aaf51f60fabc..1cdfd7279d691a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,7 +7,7 @@ settings: overrides: vite: workspace:* -packageExtensionsChecksum: de16c2a1a6a6350aaa9e478e59cca00e +packageExtensionsChecksum: 4e49e84b7a11dfd4895fbffb006a7015 patchedDependencies: chokidar@3.5.3: @@ -16,9 +16,9 @@ patchedDependencies: dotenv-expand@10.0.0: hash: weuqf2vlv5b5g6cikeo4slurbm path: patches/dotenv-expand@10.0.0.patch - sirv@2.0.3: - hash: z45f224eewh2pgpijxcc3aboqm - path: patches/sirv@2.0.3.patch + sirv@2.0.4: + hash: amdes53ifqfntejkflpaq5ifce + path: patches/sirv@2.0.4.patch importers: @@ -358,8 +358,8 @@ importers: specifier: ^1.4.2 version: 1.4.2 mrmime: - specifier: ^1.0.1 - version: 1.0.1 + specifier: ^2.0.0 + version: 2.0.0 okie: specifier: ^1.0.1 version: 1.0.1 @@ -397,8 +397,8 @@ importers: specifier: ^3.2.0 version: 3.2.0(rollup@4.2.0) sirv: - specifier: ^2.0.3 - version: 2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm) + specifier: ^2.0.4 + version: 2.0.4(patch_hash=amdes53ifqfntejkflpaq5ifce) source-map-support: specifier: ^0.5.21 version: 0.5.21 @@ -735,8 +735,8 @@ importers: playground/lib: devDependencies: sirv: - specifier: ^2.0.3 - version: 2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm) + specifier: ^2.0.4 + version: 2.0.4(patch_hash=amdes53ifqfntejkflpaq5ifce) playground/minify: dependencies: @@ -3442,8 +3442,8 @@ packages: dev: true optional: true - /@polka/url@1.0.0-next.21: - resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} + /@polka/url@1.0.0-next.24: + resolution: {integrity: sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==} dev: true /@rollup/plugin-alias@5.0.0(rollup@3.29.2): @@ -4404,6 +4404,9 @@ packages: engines: {node: '>=0.4.0'} peerDependencies: acorn: '*' + peerDependenciesMeta: + acorn: + optional: true dependencies: acorn: 8.11.2 @@ -7616,6 +7619,11 @@ packages: engines: {node: '>=10'} dev: true + /mrmime@2.0.0: + resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} + engines: {node: '>=10'} + dev: true + /ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} @@ -8894,12 +8902,12 @@ packages: requiresBuild: true dev: true - /sirv@2.0.3(patch_hash=z45f224eewh2pgpijxcc3aboqm): - resolution: {integrity: sha512-O9jm9BsID1P+0HOi81VpXPoDxYP374pkOLzACAoyUQ/3OUVndNpsz6wMnY2z+yOxzbllCKZrM+9QrWsv4THnyA==} + /sirv@2.0.4(patch_hash=amdes53ifqfntejkflpaq5ifce): + resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} dependencies: - '@polka/url': 1.0.0-next.21 - mrmime: 1.0.1 + '@polka/url': 1.0.0-next.24 + mrmime: 2.0.0 totalist: 3.0.0 dev: true patched: true