diff --git a/package.json b/package.json index c51c710a5cba27..c1168f1a38af87 100644 --- a/package.json +++ b/package.json @@ -25,11 +25,11 @@ "typecheck": "tsc -p scripts --noEmit && pnpm -r --parallel run typecheck", "test": "run-s test-serve test-build", "test-serve": "vitest run -c vitest.config.e2e.ts", - "test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", + "test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts --no-file-parallelism", "test-unit": "vitest run", "test-docs": "pnpm run docs-build", "debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts", - "debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts", + "debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts --no-file-parallelism", "docs": "pnpm --filter=docs run docs", "docs-build": "pnpm --filter=docs run docs-build", "docs-serve": "pnpm --filter=docs run docs-serve", @@ -40,7 +40,7 @@ "ci-docs": "run-s build docs-build" }, "devDependencies": { - "@eslint/js": "^9.8.0", + "@eslint/js": "^9.9.0", "@types/babel__core": "^7.20.5", "@types/babel__preset-env": "^7.9.7", "@types/convert-source-map": "^2.0.3", @@ -50,31 +50,31 @@ "@types/etag": "^1.8.3", "@types/less": "^3.0.6", "@types/micromatch": "^4.0.9", - "@types/node": "^20.14.14", - "@types/picomatch": "^3.0.0", + "@types/node": "^20.16.1", + "@types/picomatch": "^3.0.1", "@types/stylus": "^0.48.42", "@types/ws": "^8.5.12", "@vitejs/release-scripts": "^1.3.2", "conventional-changelog-cli": "^5.0.0", - "eslint": "^9.8.0", + "eslint": "^9.9.0", "eslint-plugin-import-x": "^3.1.0", "eslint-plugin-n": "^17.10.2", "eslint-plugin-regexp": "^2.6.0", - "execa": "^9.3.0", + "execa": "^9.3.1", "globals": "^15.9.0", - "lint-staged": "^15.2.8", + "lint-staged": "^15.2.9", "npm-run-all2": "^6.2.2", "picocolors": "^1.0.1", - "playwright-chromium": "^1.45.3", + "playwright-chromium": "^1.46.1", "prettier": "3.3.3", "rimraf": "^5.0.10", - "rollup": "^4.13.0", + "rollup": "^4.20.0", "rollup-plugin-esbuild": "^6.1.1", "simple-git-hooks": "^2.11.1", "tslib": "^2.6.3", - "tsx": "^4.16.5", + "tsx": "^4.17.0", "typescript": "^5.5.3", - "typescript-eslint": "^8.0.0", + "typescript-eslint": "^8.1.0", "vite": "workspace:*", "vitest": "^2.0.5" }, @@ -95,7 +95,7 @@ "eslint --cache --fix" ] }, - "packageManager": "pnpm@9.6.0", + "packageManager": "pnpm@9.7.1", "pnpm": { "overrides": { "vite": "workspace:*" diff --git a/playground/alias/package.json b/playground/alias/package.json index 34f83331721275..44925ec38ac19e 100644 --- a/playground/alias/package.json +++ b/playground/alias/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "aliased-module": "file:./dir/module", - "vue": "^3.4.35", - "@vue/shared": "^3.4.35" + "vue": "^3.4.38", + "@vue/shared": "^3.4.38" }, "devDependencies": { "@vitejs/test-resolve-linked": "workspace:*" diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index f6ad1ed750c7f5..588e018c4a0cca 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -500,31 +500,32 @@ test.runIf(isBuild)('manifest', async () => { } }) -describe.runIf(isBuild)('css and assets in css in build watch', () => { - test('css will not be lost and css does not contain undefined', async () => { - editFile('index.html', (code) => code.replace('Assets', 'assets'), true) - await notifyRebuildComplete(watcher) - const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo') - expect(cssFile).not.toBe('') - expect(cssFile).not.toMatch(/undefined/) - }) - - test('import module.css', async () => { - expect(await getColor('#foo')).toBe('red') - editFile('css/foo.module.css', (code) => code.replace('red', 'blue'), true) - await notifyRebuildComplete(watcher) - await page.reload() - expect(await getColor('#foo')).toBe('blue') - }) - - test('import with raw query', async () => { - expect(await page.textContent('.raw-query')).toBe('foo') - editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'), true) - await notifyRebuildComplete(watcher) - await page.reload() - expect(await page.textContent('.raw-query')).toBe('zoo') - }) -}) +// Rolldown not supported rebuild +// describe.runIf(isBuild)('css and assets in css in build watch', () => { +// test('css will not be lost and css does not contain undefined', async () => { +// editFile('index.html', (code) => code.replace('Assets', 'assets'), true) +// await notifyRebuildComplete(watcher) +// const cssFile = findAssetFile(/index-[-\w]+\.css$/, 'foo') +// expect(cssFile).not.toBe('') +// expect(cssFile).not.toMatch(/undefined/) +// }) + +// test('import module.css', async () => { +// expect(await getColor('#foo')).toBe('red') +// editFile('css/foo.module.css', (code) => code.replace('red', 'blue'), true) +// await notifyRebuildComplete(watcher) +// await page.reload() +// expect(await getColor('#foo')).toBe('blue') +// }) + +// test('import with raw query', async () => { +// expect(await page.textContent('.raw-query')).toBe('foo') +// editFile('static/foo.txt', (code) => code.replace('foo', 'zoo'), true) +// await notifyRebuildComplete(watcher) +// await page.reload() +// expect(await page.textContent('.raw-query')).toBe('zoo') +// }) +// }) test('inline style test', async () => { expect(await getBg('.inline-style')).toMatch(assetMatch) diff --git a/playground/backend-integration/__tests__/backend-integration.spec.ts b/playground/backend-integration/__tests__/backend-integration.spec.ts index 5dbfd55177d2d8..c6ac1aaf59cb91 100644 --- a/playground/backend-integration/__tests__/backend-integration.spec.ts +++ b/playground/backend-integration/__tests__/backend-integration.spec.ts @@ -1,4 +1,4 @@ -import { describe, expect, test } from 'vitest' +import { describe, expect, test, vi } from 'vitest' import { browserErrors, browserLogs, @@ -8,16 +8,13 @@ import { isServe, listAssets, page, + ports, readManifest, serverLogs, untilBrowserLogAfter, untilUpdated, } from '~utils' -const outerAssetMatch = isBuild - ? /\/dev\/assets\/logo-[-\w]{8}\.png/ - : /\/dev\/@fs\/.+?\/images\/logo\.png/ - test('should have no 404s', () => { browserLogs.forEach((msg) => { expect(msg).not.toMatch('404') @@ -26,9 +23,25 @@ test('should have no 404s', () => { describe('asset imports from js', () => { test('file outside root', async () => { - expect( - await page.textContent('.asset-reference.outside-root .asset-url'), - ).toMatch(outerAssetMatch) + // assert valid image src https://github.com/microsoft/playwright/issues/6046#issuecomment-1799585719 + await vi.waitUntil(() => + page + .locator('.asset-reference.outside-root .asset-preview') + .evaluate((el: HTMLImageElement) => el.naturalWidth > 0), + ) + + const text = await page.textContent( + '.asset-reference.outside-root .asset-url', + ) + if (isBuild) { + expect(text).toMatch(/\/dev\/assets\/logo-[-\w]{8}\.png/) + } else { + // asset url is prefixed with server.origin + expect(text).toMatch( + `http://localhost:${ports['backend-integration']}/dev/@fs/`, + ) + expect(text).toMatch(/\/dev\/@fs\/.+?\/images\/logo\.png/) + } }) }) diff --git a/playground/backend-integration/package.json b/playground/backend-integration/package.json index 4821c83d225ac9..daf8ee7b4047be 100644 --- a/playground/backend-integration/package.json +++ b/playground/backend-integration/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "sass": "^1.77.8", - "tailwindcss": "^3.4.7", + "tailwindcss": "^3.4.10", "fast-glob": "^3.3.2" } } diff --git a/playground/backend-integration/vite.config.js b/playground/backend-integration/vite.config.js index 881eac1a14688e..d4714288cb0e68 100644 --- a/playground/backend-integration/vite.config.js +++ b/playground/backend-integration/vite.config.js @@ -22,6 +22,15 @@ function BackendIntegrationExample() { entrypoints.push(['bar.css', path.resolve(__dirname, './dir/foo.css')]) return { + server: { + // same port in playground/test-utils.ts + port: 5009, + strictPort: true, + origin: 'http://localhost:5009', + }, + preview: { + port: 5009, + }, build: { manifest: true, outDir, diff --git a/playground/css-lightningcss-proxy/package.json b/playground/css-lightningcss-proxy/package.json index ad6b503221a9f6..07287d30b20ebf 100644 --- a/playground/css-lightningcss-proxy/package.json +++ b/playground/css-lightningcss-proxy/package.json @@ -9,7 +9,7 @@ "preview": "vite preview" }, "devDependencies": { - "lightningcss": "^1.25.1", + "lightningcss": "^1.26.0", "express": "^4.19.2" } } diff --git a/playground/css-lightningcss/package.json b/playground/css-lightningcss/package.json index 6844ef9ffb0959..aefbf1582d9686 100644 --- a/playground/css-lightningcss/package.json +++ b/playground/css-lightningcss/package.json @@ -9,6 +9,6 @@ "preview": "vite preview" }, "devDependencies": { - "lightningcss": "^1.25.1" + "lightningcss": "^1.26.0" } } diff --git a/playground/css/__tests__/css.spec.ts b/playground/css/__tests__/css.spec.ts index cb7af939bbd152..14894bf11e4228 100644 --- a/playground/css/__tests__/css.spec.ts +++ b/playground/css/__tests__/css.spec.ts @@ -93,6 +93,7 @@ test('sass', async () => { isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`, ) expect(await getColor(partialImport)).toBe('orchid') + expect(await getColor(await page.$('.sass-file-absolute'))).toBe('orange') editFile('sass.scss', (code) => code.replace('color: $injectedColor', 'color: red'), diff --git a/playground/css/file-absolute.scss b/playground/css/file-absolute.scss new file mode 100644 index 00000000000000..508930e3678f6e --- /dev/null +++ b/playground/css/file-absolute.scss @@ -0,0 +1,3 @@ +.sass-file-absolute { + color: orange; +} diff --git a/playground/css/index.html b/playground/css/index.html index a0e92b205e79f6..396ffc02fd3d27 100644 --- a/playground/css/index.html +++ b/playground/css/index.html @@ -41,6 +41,9 @@
@import dependency w/ no scss entrypoint: this should be lavender
++ @import "file:///xxx/absolute-path.scss" should be orange +
Less: This should be blue
diff --git a/playground/css/sass.scss b/playground/css/sass.scss index f2f9e685630597..44beb140e3fe3a 100644 --- a/playground/css/sass.scss +++ b/playground/css/sass.scss @@ -6,6 +6,7 @@ @import 'virtual-dep'; // virtual file added through importer @import '=/pkg-dep'; // package w/out sass field @import '=/weapp.wxss'; // wxss file +@import 'virtual-file-absolute'; .sass { /* injected via vite.config.js */ diff --git a/playground/css/vite.config-sass-modern-compiler.js b/playground/css/vite.config-sass-modern-compiler.js index 9759d58506f597..009da79192ec34 100644 --- a/playground/css/vite.config-sass-modern-compiler.js +++ b/playground/css/vite.config-sass-modern-compiler.js @@ -1,5 +1,6 @@ import { defineConfig } from 'vite' import baseConfig from './vite.config.js' +import configSassModern from './vite.config-sass-modern.js' export default defineConfig({ ...baseConfig, @@ -8,23 +9,7 @@ export default defineConfig({ preprocessorOptions: { ...baseConfig.css.preprocessorOptions, scss: { - api: 'modern-compiler', - additionalData: `$injectedColor: orange;`, - importers: [ - { - canonicalize(url) { - return url === 'virtual-dep' - ? new URL('custom-importer:virtual-dep') - : null - }, - load() { - return { - contents: ``, - syntax: 'scss', - } - }, - }, - ], + ...configSassModern.css.preprocessorOptions.scss, }, }, }, diff --git a/playground/css/vite.config-sass-modern.js b/playground/css/vite.config-sass-modern.js index 9f7acb3a098179..f83c2efb366f24 100644 --- a/playground/css/vite.config-sass-modern.js +++ b/playground/css/vite.config-sass-modern.js @@ -1,3 +1,5 @@ +import { pathToFileURL } from 'node:url' +import path from 'node:path' import { defineConfig } from 'vite' import baseConfig from './vite.config.js' @@ -24,6 +26,19 @@ export default defineConfig({ } }, }, + { + canonicalize(url) { + return url === 'virtual-file-absolute' + ? new URL('custom-importer:virtual-file-absolute') + : null + }, + load() { + return { + contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`, + syntax: 'scss', + } + }, + }, ], }, }, diff --git a/playground/css/vite.config.js b/playground/css/vite.config.js index 5ac9d448a2734a..e2b7411f0a2367 100644 --- a/playground/css/vite.config.js +++ b/playground/css/vite.config.js @@ -1,4 +1,5 @@ import path from 'node:path' +import { pathToFileURL } from 'node:url' import stylus from 'stylus' import { defineConfig } from 'vite' @@ -65,6 +66,13 @@ export default defineConfig({ function (url) { return url === 'virtual-dep' ? { contents: '' } : null }, + function (url) { + return url === 'virtual-file-absolute' + ? { + contents: `@import "${pathToFileURL(path.join(import.meta.dirname, 'file-absolute.scss')).href}"`, + } + : null + }, function (url) { return url.endsWith('.wxss') ? { contents: '' } : null }, diff --git a/playground/extensions/package.json b/playground/extensions/package.json index 8ddaf434e7fc00..f98380076ff2d3 100644 --- a/playground/extensions/package.json +++ b/playground/extensions/package.json @@ -10,6 +10,6 @@ "preview": "vite preview" }, "dependencies": { - "vue": "^3.4.35" + "vue": "^3.4.38" } } diff --git a/playground/external/dep-that-imports/package.json b/playground/external/dep-that-imports/package.json index 5b65e97a0a0e0b..2cdf3b57f96034 100644 --- a/playground/external/dep-that-imports/package.json +++ b/playground/external/dep-that-imports/package.json @@ -5,6 +5,6 @@ "dependencies": { "slash3": "npm:slash@^3.0.0", "slash5": "npm:slash@^5.1.0", - "vue": "^3.4.35" + "vue": "^3.4.38" } } diff --git a/playground/external/dep-that-requires/package.json b/playground/external/dep-that-requires/package.json index 5694b7f4de53c2..49628e103f48cc 100644 --- a/playground/external/dep-that-requires/package.json +++ b/playground/external/dep-that-requires/package.json @@ -5,6 +5,6 @@ "dependencies": { "slash3": "npm:slash@^3.0.0", "slash5": "npm:slash@^5.1.0", - "vue": "^3.4.35" + "vue": "^3.4.38" } } diff --git a/playground/external/package.json b/playground/external/package.json index 248bea074acf35..d5c9cad06db66f 100644 --- a/playground/external/package.json +++ b/playground/external/package.json @@ -17,7 +17,7 @@ "slash3": "npm:slash@^3.0.0", "slash5": "npm:slash@^5.1.0", "vite": "workspace:*", - "vue": "^3.4.35", + "vue": "^3.4.38", "vue32": "npm:vue@~3.2.0" } } diff --git a/playground/json/package.json b/playground/json/package.json index c68cf9d7e47f28..796b5d473ab9e6 100644 --- a/playground/json/package.json +++ b/playground/json/package.json @@ -15,6 +15,6 @@ "devDependencies": { "@vitejs/test-json-module": "file:./json-module", "express": "^4.19.2", - "vue": "^3.4.35" + "vue": "^3.4.38" } } diff --git a/playground/legacy/package.json b/playground/legacy/package.json index 6fe44613f64675..a7c5f58a0040a2 100644 --- a/playground/legacy/package.json +++ b/playground/legacy/package.json @@ -18,6 +18,6 @@ "vite": "workspace:*", "@vitejs/plugin-legacy": "workspace:*", "express": "^4.19.2", - "terser": "^5.31.3" + "terser": "^5.31.6" } } diff --git a/playground/object-hooks/package.json b/playground/object-hooks/package.json index 2d47c655bf3096..c43a7cc44c357e 100644 --- a/playground/object-hooks/package.json +++ b/playground/object-hooks/package.json @@ -10,6 +10,6 @@ "preview": "vite preview" }, "dependencies": { - "vue": "^3.4.35" + "vue": "^3.4.38" } } diff --git a/playground/optimize-deps-no-discovery/package.json b/playground/optimize-deps-no-discovery/package.json index 314484a4c855d7..ca4ca4e5c9c0f5 100644 --- a/playground/optimize-deps-no-discovery/package.json +++ b/playground/optimize-deps-no-discovery/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@vitejs/test-dep-no-discovery": "file:./dep-no-discovery", - "vue": "^3.4.35", + "vue": "^3.4.38", "vuex": "^4.1.0" } } diff --git a/playground/optimize-deps/package.json b/playground/optimize-deps/package.json index 41ce8d1e13b45b..3a155c2657ed85 100644 --- a/playground/optimize-deps/package.json +++ b/playground/optimize-deps/package.json @@ -10,7 +10,7 @@ "preview": "vite preview" }, "dependencies": { - "axios": "^1.7.3", + "axios": "^1.7.4", "clipboard": "^2.0.11", "@vitejs/longfilename-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": "file:./longfilename", "@vitejs/test-dep-alias-using-absolute-path": "file:./dep-alias-using-absolute-path", @@ -44,7 +44,7 @@ "react-dom": "^18.3.1", "@vitejs/test-resolve-linked": "workspace:0.0.0", "url": "^0.11.4", - "vue": "^3.4.35", + "vue": "^3.4.38", "vuex": "^4.1.0", "lodash": "^4.17.21", "lodash.clonedeep": "^4.5.0" diff --git a/playground/optimize-deps/vite.config.js b/playground/optimize-deps/vite.config.js index e42aa3234119e7..6fd06b7af42b75 100644 --- a/playground/optimize-deps/vite.config.js +++ b/playground/optimize-deps/vite.config.js @@ -62,8 +62,8 @@ export default defineConfig({ minify: false, rollupOptions: { onwarn(msg, warn) { - // filter `"Buffer" is not exported by "__vite-browser-external"` warning - if (msg.message.includes('Buffer')) return + // // filter `"Buffer" is not exported by "__vite-browser-external"` warning + // if (msg.message.includes('Buffer')) return warn(msg) }, }, @@ -97,19 +97,20 @@ export default defineConfig({ } }, }, - // TODO: Remove this one support for prebundling in build lands. - // It is expected that named importing in build doesn't work - // as it incurs a lot of overhead in build. - { - name: 'polyfill-named-fs-build', - apply: 'build', - enforce: 'pre', - load(id) { - if (id === '__vite-browser-external') { - return `export default {}; export function readFileSync() {}` - } - }, - }, + // Remove this one because the resolve plugin already handle '__vite-browser-external' + // // TODO: Remove this one support for prebundling in build lands. + // // It is expected that named importing in build doesn't work + // // as it incurs a lot of overhead in build. + // { + // name: 'polyfill-named-fs-build', + // apply: 'build', + // enforce: 'pre', + // load(id) { + // if (id === '__vite-browser-external') { + // return `export default {}; export function readFileSync() {}` + // } + // }, + // }, ], }) diff --git a/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts b/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts index 02f20ef837e242..41a61460807c1f 100644 --- a/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts +++ b/playground/preload/__tests__/resolve-deps/preload-resolve-deps.spec.ts @@ -21,7 +21,9 @@ describe.runIf(isBuild)('build', () => { expect(html).toMatch( /link rel="modulepreload".*?href="http.*?\/hello-[-\w]{8}\.js"/, ) - expect(html).toMatch(/link rel="modulepreload".*?href="\/preloaded.js"/) + expect(html).toMatch( + /link rel="modulepreload".*?href="http.*?\/preloaded.js"/, + ) expect(html).toMatch( /link rel="stylesheet".*?href="http.*?\/hello-[-\w]{8}\.css"/, ) diff --git a/playground/preload/package.json b/playground/preload/package.json index 3d91a5c96cb766..92ce4f30877449 100644 --- a/playground/preload/package.json +++ b/playground/preload/package.json @@ -8,17 +8,17 @@ "build": "vite build", "debug": "node --inspect-brk ../../packages/vite/bin/vite", "preview": "vite preview", - "dev:resolve-deps": "vite --config vite.config-resolve-deps.ts", - "build:resolve-deps": "vite build --config vite.config-resolve-deps.ts", - "debug:resolve-deps": "node --inspect-brk ../../packages/vite/bin/vite --config vite.config-resolve-deps.ts", - "preview:resolve-deps": "vite preview --config vite.config-resolve-deps.ts", - "dev:preload-disabled": "vite --config vite.config-preload-disabled.ts", - "build:preload-disabled": "vite build --config vite.config-preload-disabled.ts", - "debug:preload-disabled": "node --inspect-brk ../../packages/vite/bin/vite --config vite.config-preload-disabled.ts", - "preview:preload-disabled": "vite preview --config vite.config-preload-disabled.ts" + "dev:resolve-deps": "vite --config vite.config-resolve-deps.js", + "build:resolve-deps": "vite build --config vite.config-resolve-deps.js", + "debug:resolve-deps": "node --inspect-brk ../../packages/vite/bin/vite --config vite.config-resolve-deps.js", + "preview:resolve-deps": "vite preview --config vite.config-resolve-deps.js", + "dev:preload-disabled": "vite --config vite.config-preload-disabled.js", + "build:preload-disabled": "vite build --config vite.config-preload-disabled.js", + "debug:preload-disabled": "node --inspect-brk ../../packages/vite/bin/vite --config vite.config-preload-disabled.js", + "preview:preload-disabled": "vite preview --config vite.config-preload-disabled.js" }, "devDependencies": { - "terser": "^5.31.3", + "terser": "^5.31.6", "@vitejs/test-dep-a": "file:./dep-a", "@vitejs/test-dep-including-a": "file:./dep-including-a" } diff --git a/playground/ssr-webworker/package.json b/playground/ssr-webworker/package.json index bccb8e26e826ea..c66c5f156c0a7b 100644 --- a/playground/ssr-webworker/package.json +++ b/playground/ssr-webworker/package.json @@ -13,7 +13,7 @@ "@vitejs/test-worker-exports": "file:./worker-exports" }, "devDependencies": { - "miniflare": "^3.20240725.0", + "miniflare": "^3.20240806.1", "@vitejs/test-resolve-linked": "workspace:*" } } diff --git a/playground/tailwind-sourcemap/package.json b/playground/tailwind-sourcemap/package.json index b5c7d755ad1fed..d2425925e93c10 100644 --- a/playground/tailwind-sourcemap/package.json +++ b/playground/tailwind-sourcemap/package.json @@ -10,6 +10,6 @@ "preview": "vite preview" }, "dependencies": { - "tailwindcss": "^3.4.7" + "tailwindcss": "^3.4.10" } } diff --git a/playground/tailwind/package.json b/playground/tailwind/package.json index c3df2e325f0f20..a12b57a63ececd 100644 --- a/playground/tailwind/package.json +++ b/playground/tailwind/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "autoprefixer": "^10.4.20", - "tailwindcss": "^3.4.7", - "vue": "^3.4.35", - "vue-router": "^4.4.2" + "tailwindcss": "^3.4.10", + "vue": "^3.4.38", + "vue-router": "^4.4.3" }, "devDependencies": { "ts-node": "^10.9.2" diff --git a/playground/tailwind/vite.config.ts b/playground/tailwind/vite.config.ts index 86521cff913e97..37112cc15ff700 100644 --- a/playground/tailwind/vite.config.ts +++ b/playground/tailwind/vite.config.ts @@ -27,11 +27,6 @@ export default defineConfig({ // to make tests faster minify: false, }, - server: { - // This option caused issues with HMR, - // although it should not affect the build - origin: 'http://localhost:8080', - }, plugins: [ { name: 'delay view', diff --git a/playground/test-utils.ts b/playground/test-utils.ts index f46bc3c95389cf..4666820f850c28 100644 --- a/playground/test-utils.ts +++ b/playground/test-utils.ts @@ -46,6 +46,7 @@ export const ports = { 'css/postcss-plugins-different-dir': 5006, 'css/dynamic-import': 5007, 'css/lightningcss-proxy': 5008, + 'backend-integration': 5009, } export const hmrPorts = { 'optimize-missing-deps': 24680, diff --git a/playground/transform-plugin/vite.config.js b/playground/transform-plugin/vite.config.js index afa97e8ff77f83..dae98317ad1de5 100644 --- a/playground/transform-plugin/vite.config.js +++ b/playground/transform-plugin/vite.config.js @@ -7,17 +7,15 @@ let transformCount = 1 const transformPlugin = { name: 'transform', load(id) { - if (id === file && typeof this.addWatchFile === 'function') { + if (id === file) { // Ensure `index.js` is reloaded if 'plugin-dep-load.js' is changed this.addWatchFile('./plugin-dep-load.js') } }, transform(code, id) { if (id === file) { - if (typeof this.addWatchFile === 'function'){ - // Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed - this.addWatchFile('./plugin-dep.js') - } + // Ensure `index.js` is reevaluated if 'plugin-dep.js' is changed + this.addWatchFile('./plugin-dep.js') return ` // Inject TRANSFORM_COUNT diff --git a/playground/worker/__tests__/es/worker-es.spec.ts b/playground/worker/__tests__/es/worker-es.spec.ts index 27e615dfab56af..0af2cf7dda15ef 100644 --- a/playground/worker/__tests__/es/worker-es.spec.ts +++ b/playground/worker/__tests__/es/worker-es.spec.ts @@ -111,7 +111,7 @@ describe.runIf(isBuild)('build', () => { test('inlined code generation', async () => { const assetsDir = path.resolve(testDir, 'dist/es/assets') const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(34) + expect(files.length).toBe(35) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('my-worker')) diff --git a/playground/worker/__tests__/iife/worker-iife.spec.ts b/playground/worker/__tests__/iife/worker-iife.spec.ts index 5d5fa297f2161e..a2f981e694dc88 100644 --- a/playground/worker/__tests__/iife/worker-iife.spec.ts +++ b/playground/worker/__tests__/iife/worker-iife.spec.ts @@ -75,7 +75,7 @@ describe.runIf(isBuild)('build', () => { test('inlined code generation', async () => { const assetsDir = path.resolve(testDir, 'dist/iife/assets') const files = fs.readdirSync(assetsDir) - expect(files.length).toBe(22) + expect(files.length).toBe(23) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const worker = files.find((f) => f.includes('worker_entry-my-worker')) @@ -173,6 +173,12 @@ test('self reference url worker', async () => { ).toBe('pong: main\npong: nested\n') }) +test('self reference url worker in dependency', async () => { + await expectWithRetry(() => + page.textContent('.self-reference-url-worker-dep'), + ).toBe('pong: main\npong: nested\n') +}) + test.runIf(isServe)('sourcemap boundary', async () => { const response = page.waitForResponse(/my-worker.ts\?worker_file&type=module/) await page.goto(viteTestUrl) diff --git a/playground/worker/__tests__/sourcemap-hidden/worker-sourcemap-hidden.spec.ts b/playground/worker/__tests__/sourcemap-hidden/worker-sourcemap-hidden.spec.ts index 780ce34df6795a..ef50c15564ea70 100644 --- a/playground/worker/__tests__/sourcemap-hidden/worker-sourcemap-hidden.spec.ts +++ b/playground/worker/__tests__/sourcemap-hidden/worker-sourcemap-hidden.spec.ts @@ -10,7 +10,7 @@ describe.runIf(isBuild)('build', () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(44) + expect(files.length).toBe(46) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/playground/worker/__tests__/sourcemap-inline/worker-sourcemap-inline.spec.ts b/playground/worker/__tests__/sourcemap-inline/worker-sourcemap-inline.spec.ts index 10933fee2ff7ce..7f806761ae66fc 100644 --- a/playground/worker/__tests__/sourcemap-inline/worker-sourcemap-inline.spec.ts +++ b/playground/worker/__tests__/sourcemap-inline/worker-sourcemap-inline.spec.ts @@ -10,7 +10,7 @@ describe.runIf(isBuild)('build', () => { const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(22) + expect(files.length).toBe(23) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/playground/worker/__tests__/sourcemap/worker-sourcemap.spec.ts b/playground/worker/__tests__/sourcemap/worker-sourcemap.spec.ts index 47905cd3d33673..4e3dce9d817a8f 100644 --- a/playground/worker/__tests__/sourcemap/worker-sourcemap.spec.ts +++ b/playground/worker/__tests__/sourcemap/worker-sourcemap.spec.ts @@ -9,7 +9,7 @@ describe.runIf(isBuild)('build', () => { const assetsDir = path.resolve(testDir, 'dist/iife-sourcemap/assets') const files = fs.readdirSync(assetsDir) // should have 2 worker chunk - expect(files.length).toBe(44) + expect(files.length).toBe(46) const index = files.find((f) => f.includes('main-module')) const content = fs.readFileSync(path.resolve(assetsDir, index), 'utf-8') const indexSourcemap = getSourceMapUrl(content) diff --git a/playground/worker/dep-self-reference-url-worker/index.js b/playground/worker/dep-self-reference-url-worker/index.js new file mode 100644 index 00000000000000..cfb52d9fe55538 --- /dev/null +++ b/playground/worker/dep-self-reference-url-worker/index.js @@ -0,0 +1,9 @@ +export function startWorker(handler) { + const worker = new Worker(new URL('./worker.js', import.meta.url), { + type: 'module', + }) + worker.postMessage('main') + worker.addEventListener('message', (e) => { + handler(e) + }) +} diff --git a/playground/worker/dep-self-reference-url-worker/package.json b/playground/worker/dep-self-reference-url-worker/package.json new file mode 100644 index 00000000000000..4f46ee5a6d81d0 --- /dev/null +++ b/playground/worker/dep-self-reference-url-worker/package.json @@ -0,0 +1,7 @@ +{ + "name": "@vitejs/test-dep-self-reference-url-worker", + "private": true, + "version": "1.0.0", + "type": "module", + "main": "index.js" +} diff --git a/playground/worker/dep-self-reference-url-worker/worker.js b/playground/worker/dep-self-reference-url-worker/worker.js new file mode 100644 index 00000000000000..908fe9071592f7 --- /dev/null +++ b/playground/worker/dep-self-reference-url-worker/worker.js @@ -0,0 +1,14 @@ +// copy of playground/worker/self-reference-url-worker.js +self.addEventListener('message', (e) => { + if (e.data === 'main') { + const selfWorker = new Worker(new URL('./worker.js', import.meta.url), { + type: 'module', + }) + selfWorker.postMessage('nested') + selfWorker.addEventListener('message', (e) => { + self.postMessage(e.data) + }) + } + + self.postMessage(`pong: ${e.data}`) +}) diff --git a/playground/worker/index.html b/playground/worker/index.html index c1944046af6998..d6b3806b3293ae 100644 --- a/playground/worker/index.html +++ b/playground/worker/index.html @@ -164,6 +164,11 @@
++ .self-reference-url-worker-dep +
+
+
new Worker(new URL('../deeply-nested-worker.js', import.meta.url), { type: 'module' }) diff --git a/playground/worker/package.json b/playground/worker/package.json index 90d4068a580f4a..e9b2dd7876e027 100644 --- a/playground/worker/package.json +++ b/playground/worker/package.json @@ -28,6 +28,7 @@ "debug": "node --inspect-brk ../../packages/vite/bin/vite" }, "dependencies": { + "@vitejs/test-dep-self-reference-url-worker": "file:./dep-self-reference-url-worker", "@vitejs/test-dep-to-optimize": "file:./dep-to-optimize" } } diff --git a/playground/worker/vite.config-iife.js b/playground/worker/vite.config-iife.js index 3d6d0de8a170e5..7e3cb6f68aa7f7 100644 --- a/playground/worker/vite.config-iife.js +++ b/playground/worker/vite.config-iife.js @@ -51,4 +51,7 @@ export default defineConfig({ }, ], cacheDir: 'node_modules/.vite-iife', + optimizeDeps: { + exclude: ['@vitejs/test-dep-self-reference-url-worker'], + }, }) diff --git a/playground/worker/worker/main-module.js b/playground/worker/worker/main-module.js index c405adfc04815e..a59bc903800b12 100644 --- a/playground/worker/worker/main-module.js +++ b/playground/worker/worker/main-module.js @@ -1,3 +1,4 @@ +import * as depSelfReferenceUrlWorker from '@vitejs/test-dep-self-reference-url-worker' import myWorker from '../my-worker.ts?worker' import InlineWorker from '../my-worker.ts?worker&inline' import InlineSharedWorker from '../my-inline-shared-worker?sharedworker&inline' @@ -177,3 +178,8 @@ selfReferenceUrlWorker.addEventListener('message', (e) => { document.querySelector('.self-reference-url-worker').textContent += `${e.data}\n` }) + +depSelfReferenceUrlWorker.startWorker((e) => { + document.querySelector('.self-reference-url-worker-dep').textContent += + `${e.data}\n` +}) diff --git a/vitest.config.e2e.ts b/vitest.config.e2e.ts index 6291c8d47853a7..b78afbcfb2e2c8 100644 --- a/vitest.config.e2e.ts +++ b/vitest.config.e2e.ts @@ -16,26 +16,21 @@ export default defineConfig({ './playground/assets/**/*.spec.[tj]s', './playground/backend-integration/**/*.spec.[tj]s', './playground/css-codesplit/**/*.spec.[tj]s', - './playground/css-codesplit/**/*.spec.[tj]s', - './playground/css-codesplit/**/*.spec.[tj]s', './playground/css-dynamic-import/**/*.spec.[tj]s', './playground/dynamic-import/**/*.spec.[tj]s', - './playground/extensions/**/*.spec.[tj]s', './playground/external/**/*.spec.[tj]s', './playground/glob-import/**/*.spec.[tj]s', - './playground/html/**/*.spec.[tj]s', './playground/js-sourcemap/**/*.spec.[tj]s', './playground/legacy/**/*.spec.[tj]s', './playground/lib/**/*.spec.[tj]s', - './playground/multiple-entrypoints/**/*.spec.[tj]s', './playground/object-hooks/**/*.spec.[tj]s', './playground/optimize-deps/**/*.spec.[tj]s', - './playground/proxy-bypass/**/*.spec.[tj]s', - './playground/resolve/**/*.spec.[tj]s', './playground/resolve-config/**/*.spec.[tj]s', './playground/ssr-resolve/**/*.spec.[tj]s', './playground/ssr-webworker/**/*.spec.[tj]s', './playground/worker/**/*.spec.[tj]s', + // skip link vite tets at local + '**/node_modules/**', ], setupFiles: ['./playground/vitestSetup.ts'], globalSetup: ['./playground/vitestGlobalSetup.ts'],