From c36d80a888a4b953fe9e7ed5a42c52e45e4b6e80 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 20 Oct 2023 21:15:30 +0800 Subject: [PATCH] Handle Rollup 4 hash change (#8875) --- packages/astro/src/assets/vite-plugin-assets.ts | 2 +- packages/astro/test/astro-css-bundling.test.js | 2 +- packages/astro/test/ssr-manifest.test.js | 2 +- packages/astro/test/ssr-split-manifest.test.js | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/assets/vite-plugin-assets.ts b/packages/astro/src/assets/vite-plugin-assets.ts index ea576fb1aa27..a4346edcea8b 100644 --- a/packages/astro/src/assets/vite-plugin-assets.ts +++ b/packages/astro/src/assets/vite-plugin-assets.ts @@ -106,7 +106,7 @@ export default function assets({ }, // In build, rewrite paths to ESM imported images in code to their final location async renderChunk(code) { - const assetUrlRE = /__ASTRO_ASSET_IMAGE__([a-z\d]{8})__(?:_(.*?)__)?/g; + const assetUrlRE = /__ASTRO_ASSET_IMAGE__([\w$]{8})__(?:_(.*?)__)?/g; let match; let s; diff --git a/packages/astro/test/astro-css-bundling.test.js b/packages/astro/test/astro-css-bundling.test.js index 2da01108fa9d..ae66ea838f30 100644 --- a/packages/astro/test/astro-css-bundling.test.js +++ b/packages/astro/test/astro-css-bundling.test.js @@ -69,7 +69,7 @@ describe('CSS Bundling', function () { it('CSS includes hashes', async () => { const [firstFound] = await fixture.readdir('/_astro'); - expect(firstFound).to.match(/[a-z]+\.[0-9a-z]{8}\.css/); + expect(firstFound).to.match(/[a-z]+\.[\w-]{8}\.css/); }); }); diff --git a/packages/astro/test/ssr-manifest.test.js b/packages/astro/test/ssr-manifest.test.js index b45d6b581d90..02feed6b3993 100644 --- a/packages/astro/test/ssr-manifest.test.js +++ b/packages/astro/test/ssr-manifest.test.js @@ -25,7 +25,7 @@ describe('astro:ssr-manifest', () => { const html = await response.text(); const $ = cheerio.load(html); - expect($('#assets').text()).to.equal('["/_astro/index.a8a337e4.css"]'); + expect($('#assets').text()).to.match(/\["\/_astro\/index.([\w-]{8})\.css"\]/); }); it('includes compressHTML', async () => { diff --git a/packages/astro/test/ssr-split-manifest.test.js b/packages/astro/test/ssr-split-manifest.test.js index 7df104e7616d..89c8e00ef898 100644 --- a/packages/astro/test/ssr-split-manifest.test.js +++ b/packages/astro/test/ssr-split-manifest.test.js @@ -45,7 +45,9 @@ describe('astro:ssr-manifest, split', () => { const html = await response.text(); const $ = cheerio.load(html); - expect($('#assets').text()).to.equal('["/_astro/index.a8a337e4.css","/prerender/index.html"]'); + expect($('#assets').text()).to.match( + /\["\/_astro\/index\.([\w-]{8})\.css","\/prerender\/index\.html"\]/ + ); }); it('should give access to entry points that exists on file system', async () => {