diff --git a/packages/astro/src/manifest/serialized.ts b/packages/astro/src/manifest/serialized.ts index 54ce467d68bd..44f0dc51209d 100644 --- a/packages/astro/src/manifest/serialized.ts +++ b/packages/astro/src/manifest/serialized.ts @@ -38,6 +38,13 @@ export function serializedManifestPlugin({ name: SERIALIZED_MANIFEST_ID, enforce: 'pre', + augmentChunkHash(information) { + // We only augment the hash of this entrypoint + if (information.name === 'prerender') { + return Date.now().toString(); + } + }, + resolveId(id) { if (id === SERIALIZED_MANIFEST_ID) { return SERIALIZED_MANIFEST_RESOLVED_ID; diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index 29ccaafec29a..82eb724d97ef 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -1208,174 +1208,173 @@ describe('[SSG] i18n routing', () => { }); }); - describe('current locale', () => { - describe('with [prefix-other-locales]', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - - before(async () => { - fixture = await loadFixture({ - root: './fixtures/i18n-routing/', - }); - await fixture.build(); - }); + describe('with [prefix-other-locales]', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; - it('should return the default locale', async () => { - let html = await fixture.readFile('/current-locale/index.html'); - assert.equal(html.includes('Current Locale: es'), true); + before(async () => { + fixture = await loadFixture({ + root: './fixtures/i18n-routing/', }); + await fixture.build(); + }); - it('should return the default locale when rendering a route with spread operator', async () => { - const html = await fixture.readFile('/blog/es/index.html'); - assert.equal(html.includes('Current Locale: es'), true); - }); + it('should return the default locale', async () => { + let html = await fixture.readFile('/current-locale/index.html'); + assert.equal(html.includes('Current Locale: es'), true); + }); - it('should return the default locale of the current URL', async () => { - const html = await fixture.readFile('/pt/start/index.html'); - assert.equal(html.includes('Current Locale: pt'), true); - }); + it('should return the default locale when rendering a route with spread operator', async () => { + const html = await fixture.readFile('/blog/es/index.html'); + assert.equal(html.includes('Current Locale: es'), true); + }); - it('should return the default locale when a route is dynamic', async () => { - const html = await fixture.readFile('/dynamic/lorem/index.html'); - assert.equal(html.includes('Current Locale: es'), true); - }); + it('should return the default locale of the current URL', async () => { + const html = await fixture.readFile('/pt/start/index.html'); + assert.equal(html.includes('Current Locale: pt'), true); + }); - it('should returns the correct locale when requesting a locale via path', async () => { - const html = await fixture.readFile('/spanish/index.html'); - assert.equal(html.includes('Current Locale: es'), true); - }); + it('should return the default locale when a route is dynamic', async () => { + const html = await fixture.readFile('/dynamic/lorem/index.html'); + assert.equal(html.includes('Current Locale: es'), true); }); - describe('with [pathname-prefix-always]', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + it('should returns the correct locale when requesting a locale via path', async () => { + const html = await fixture.readFile('/spanish/index.html'); + assert.equal(html.includes('Current Locale: es'), true); + }); + }); - before(async () => { - fixture = await loadFixture({ - root: './fixtures/i18n-routing-prefix-always/', - }); - await fixture.build(); - }); + describe('with [pathname-prefix-always]', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; - it('should return the locale of the current URL (en)', async () => { - const html = await fixture.readFile('/en/start/index.html'); - assert.equal(html.includes('Current Locale: en'), true); + before(async () => { + fixture = await loadFixture({ + root: './fixtures/i18n-routing-prefix-always/', }); + await fixture.build(); + }); - it('should return the locale of the current URL (pt)', async () => { - const html = await fixture.readFile('/pt/start/index.html'); - assert.equal(html.includes('Current Locale: pt'), true); - }); + it('should return the locale of the current URL (en)', async () => { + const html = await fixture.readFile('/en/start/index.html'); + assert.equal(html.includes('Current Locale: en'), true); }); - describe('when `build.format` is `file`, locales array contains objects, and locale indexes use getStaticPaths', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + it('should return the locale of the current URL (pt)', async () => { + const html = await fixture.readFile('/pt/start/index.html'); + assert.equal(html.includes('Current Locale: pt'), true); + }); + }); - before(async () => { - fixture = await loadFixture({ - root: './fixtures/i18n-locale-index-format-file/', - i18n: { - defaultLocale: 'en-us', - locales: [ - { - path: 'en-us', - codes: ['en-US'], - }, - { - path: 'es-mx', - codes: ['es-MX'], - }, - { - path: 'fr-fr', - codes: ['fr-FR'], - }, - ], - routing: { - prefixDefaultLocale: true, - redirectToDefaultLocale: false, - }, - }, - }); - await fixture.build(); - }); + describe('with dynamic paths', async () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + let devServer; - it('should return the locale code of the current URL (en-US)', async () => { - const html = await fixture.readFile('/en-us.html'); - assert.equal(html.includes('currentLocale: en-US'), true); + before(async () => { + fixture = await loadFixture({ + root: './fixtures/i18n-routing/', }); + devServer = await fixture.startDevServer(); + }); - it('should return the locale code of the current URL (es-MX)', async () => { - const html = await fixture.readFile('/es-mx.html'); - assert.equal(html.includes('currentLocale: es-MX'), true); - }); + afterEach(async () => { + devServer.stop(); + }); - it('should return the locale code of the current URL (fr-FR)', async () => { - const html = await fixture.readFile('/fr-fr.html'); - assert.equal(html.includes('currentLocale: fr-FR'), true); - }); + it('should return the correct current locale', async () => { + let html = await fixture.fetch('/en').then((r) => r.text()); + assert.match(html, /en/); + html = await fixture.fetch('/ru').then((r) => r.text()); + assert.match(html, /ru/); }); + }); +}); - describe('when `build.format` is `file`, locales array contains strings, and locale indexes use getStaticPaths', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; +describe('[SSG] i18n routing when `build.format` is `file`, locales array contains objects, and locale indexes use getStaticPaths', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; - before(async () => { - fixture = await loadFixture({ - root: './fixtures/i18n-locale-index-format-file/', - i18n: { - defaultLocale: 'en-us', - locales: ['en-us', 'es-mx', 'fr-fr'], - routing: { - prefixDefaultLocale: true, - redirectToDefaultLocale: false, - }, + before(async () => { + fixture = await loadFixture({ + root: './fixtures/i18n-locale-index-format-file/', + i18n: { + defaultLocale: 'en-us', + locales: [ + { + path: 'en-us', + codes: ['en-US'], }, - }); - await fixture.build(); - }); + { + path: 'es-mx', + codes: ['es-MX'], + }, + { + path: 'fr-fr', + codes: ['fr-FR'], + }, + ], + routing: { + prefixDefaultLocale: true, + redirectToDefaultLocale: false, + }, + }, + }); + await fixture.build(); + }); - it('should return the locale of the current URL (en-us)', async () => { - const html = await fixture.readFile('/en-us.html'); - assert.equal(html.includes('currentLocale: en-us'), true); - }); + it('should return the locale code of the current URL (en-US)', async () => { + const html = await fixture.readFile('/en-us.html'); + assert.equal(html.includes('currentLocale: en-US'), true); + }); - it('should return the locale of the current URL (es-mx)', async () => { - const html = await fixture.readFile('/es-mx.html'); - assert.equal(html.includes('currentLocale: es-mx'), true); - }); + it('should return the locale code of the current URL (es-MX)', async () => { + const html = await fixture.readFile('/es-mx.html'); + assert.equal(html.includes('currentLocale: es-MX'), true); + }); - it('should return the locale of the current URL (fr-fr)', async () => { - const html = await fixture.readFile('/fr-fr.html'); - assert.equal(html.includes('currentLocale: fr-fr'), true); - }); - }); + it('should return the locale code of the current URL (fr-FR)', async () => { + const html = await fixture.readFile('/fr-fr.html'); + assert.equal(html.includes('currentLocale: fr-FR'), true); + }); +}); - describe('with dynamic paths', async () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let devServer; +describe('[SSG] i18n routing when `build.format` is `file`, locales array contains strings, and locale indexes use getStaticPaths', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; - before(async () => { - fixture = await loadFixture({ - root: './fixtures/i18n-routing/', - }); - devServer = await fixture.startDevServer(); - }); + before(async () => { + fixture = await loadFixture({ + root: './fixtures/i18n-locale-index-format-file/', + i18n: { + defaultLocale: 'en-us', + locales: ['en-us', 'es-mx', 'fr-fr'], + routing: { + prefixDefaultLocale: true, + redirectToDefaultLocale: false, + }, + }, + }); + await fixture.build(); + }); - afterEach(async () => { - devServer.stop(); - }); + it('should return the locale of the current URL (en-us)', async () => { + const html = await fixture.readFile('/en-us.html'); + assert.equal(html.includes('currentLocale: en-us'), true); + }); - it('should return the correct current locale', async () => { - let html = await fixture.fetch('/en').then((r) => r.text()); - assert.match(html, /en/); - html = await fixture.fetch('/ru').then((r) => r.text()); - assert.match(html, /ru/); - }); - }); + it('should return the locale of the current URL (es-mx)', async () => { + const html = await fixture.readFile('/es-mx.html'); + assert.equal(html.includes('currentLocale: es-mx'), true); + }); + + it('should return the locale of the current URL (fr-fr)', async () => { + const html = await fixture.readFile('/fr-fr.html'); + assert.equal(html.includes('currentLocale: fr-fr'), true); }); }); + describe('[SSR] i18n routing', () => { let app;