Unverified Commit e22988e5 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: switch chunk/asset hashes from hex to base40 encoding (#91137)

### What?

Switch Turbopack's hash encoding for chunk and asset output filenames
from hexadecimal (base16) to base40, using the alphabet \`0-9 a-z _ - ~
.\`. Version hashes (used for HMR update comparison, not filenames) use
base64 instead.

### Why?

Base40 encodes the same number of bits in fewer characters than hex,
producing shorter output filenames. All 40 characters are RFC 3986
unreserved (URL-safe) and safe on case-insensitive filesystems (macOS
HFS+/APFS, Windows NTFS).

Hash truncation lengths are reduced proportionally to maintain
equivalent collision resistance:

| Context | Before (hex) | After (base40) | Entropy |
|---|---|---|---|
| Content hash in chunk filenames | 16 chars | 13 chars | ~69 bits |
| Content hash in asset filenames | 8 chars | 13 chars | ~69 bits |
| Ident disambiguator hash | 8 chars | 7 chars | ~37 bits |
| Long-path prefix hash | 5 chars | 4 chars | ~21 bits |

### How?

**New encoding module** (\`turbo-tasks-hash/src/base40.rs\`):
- Defines the base40 alphabet and length constants (\`BASE40_LEN_64 =
13\`, \`BASE40_LEN_128 = 25\`)
- Implements a generic \`encode_base40_fixed<N>\` helper to avoid
duplication
- Public API: \`encode_base40(u64) -> String\` and
\`encode_base40_128(u128) -> String\`

**New base64 encoding** (\`turbo-tasks-hash/src/base64.rs\`):
- \`encode_base64(u64) -> String\` — 11-char base64 (no padding) for
version hashes
- Version hashes don't appear in URLs or filenames, so base64 is safe
and shorter

**New \`HashAlgorithm\` variants** (\`turbo-tasks-hash/src/lib.rs\`):
- \`Xxh3Hash64Base40\` and \`Xxh3Hash128Base40\` added alongside
existing hex variants
- Existing hex variants kept for internal manifests and identifiers

**\`ContentHashing\` moved to \`turbopack-core\`**:
- Moved from \`turbopack-browser\` to
\`turbopack-core/src/chunk/mod.rs\` so both \`BrowserChunkingContext\`
and \`NodeJsChunkingContext\` can use it

**Separate chunk vs asset content hashing**:
- \`BrowserChunkingContext\`: \`content_hashing\` renamed to
\`chunk_content_hashing\` (optional), new \`asset_content_hashing:
ContentHashing\` field (non-optional, defaults to 13 chars)
- \`NodeJsChunkingContext\`: new \`asset_content_hashing:
ContentHashing\` field (non-optional, defaults to 13 chars)
- Builder methods: \`use_content_hashing()\` renamed to
\`chunk_content_hashing()\`, new \`asset_content_hashing()\`

**Version hashes switched to base64**:
- \`turbopack-nodejs/src/ecmascript/node/version.rs\`
- \`turbopack-dev-server/src/html.rs\`
- \`turbopack-browser/src/ecmascript/version.rs\`,
\`merged/version.rs\`, \`list/version.rs\`

**Other callers updated** (15 files across turbopack and next-core):
- All chunk/asset content hashing switched from \`Xxh3Hash128Hex\` →
\`Xxh3Hash128Base40\`
- \`ContentHashing::Direct { length }\` reduced from 16 → 13
- Asset path truncations use full 13-char base40 hash (matching chunk
filenames)

**Exception — \`wasm_edge_var_name\`** (\`turbopack-wasm/src/lib.rs\`):
- Kept as \`Xxh3Hash128Hex\` because the hash is used as part of a
JavaScript variable name (\`wasm_{hash}\`), and base40 characters \`-\`,
\`~\`, \`.\` are not valid JS identifier characters.

**Scope — NOT changed:**
- Webpack configuration (unchanged)
- Internal manifests (\`routes_hashes_manifest\`,
\`project_asset_hashes_manifest\`)
- Internal identifiers (font naming, external module hashing, data URI
sources, debug IDs)
- SRI hashes (SHA-based Base64, different purpose)

---------
Co-authored-by: 's avatarVercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: 's avatarClaude <noreply@anthropic.com>
parent fb0686d8
...@@ -11,13 +11,13 @@ use turbopack::module_options::{ ...@@ -11,13 +11,13 @@ use turbopack::module_options::{
side_effect_free_packages_glob, side_effect_free_packages_glob,
}; };
use turbopack_browser::{ use turbopack_browser::{
BrowserChunkingContext, ContentHashing, CurrentChunkMethod, BrowserChunkingContext, CurrentChunkMethod, react_refresh::assert_can_resolve_react_refresh,
react_refresh::assert_can_resolve_react_refresh,
}; };
use turbopack_core::{ use turbopack_core::{
chunk::{ chunk::{
AssetSuffix, ChunkingConfig, ChunkingContext, MangleType, MinifyType, SourceMapSourceType, AssetSuffix, ChunkingConfig, ChunkingContext, ContentHashing, MangleType, MinifyType,
SourceMapsType, UnusedReferences, UrlBehavior, chunk_id_strategy::ModuleIdStrategy, SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior,
chunk_id_strategy::ModuleIdStrategy,
}, },
compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences}, compile_time_info::{CompileTimeDefines, CompileTimeInfo, FreeVarReference, FreeVarReferences},
environment::{BrowserEnvironment, Environment, ExecutionEnvironment}, environment::{BrowserEnvironment, Environment, ExecutionEnvironment},
...@@ -530,7 +530,7 @@ pub async fn get_client_chunking_context( ...@@ -530,7 +530,7 @@ pub async fn get_client_chunking_context(
..Default::default() ..Default::default()
}, },
) )
.use_content_hashing(ContentHashing::Direct { length: 16 }) .chunk_content_hashing(ContentHashing::Direct { length: 13 })
.module_merging(*scope_hoisting.await?); .module_merging(*scope_hoisting.await?);
} }
......
...@@ -30,9 +30,13 @@ export const expectedWhenTrailingSlashTrue = [ ...@@ -30,9 +30,13 @@ export const expectedWhenTrailingSlashTrue = [
// Turbopack and plain next.js have different hash output for the file name // Turbopack and plain next.js have different hash output for the file name
// Turbopack will output favicon in the _next/static/media folder // Turbopack will output favicon in the _next/static/media folder
...(process.env.IS_TURBOPACK_TEST ...(process.env.IS_TURBOPACK_TEST
? [expect.stringMatching(/_next\/static\/media\/favicon\.[0-9a-f]+\.ico/)] ? [
expect.stringMatching(
/_next\/static\/media\/favicon\.[0-9a-z_.~-]+\.ico/
),
]
: []), : []),
expect.stringMatching(/_next\/static\/media\/test\.[0-9a-f]+\.png/), expect.stringMatching(/_next\/static\/media\/test\.[0-9a-z_.~-]+\.png/),
expect.stringMatching(/_next\/static\/[A-Za-z0-9_-]+\/_buildManifest.js/), expect.stringMatching(/_next\/static\/[A-Za-z0-9_-]+\/_buildManifest.js/),
...(process.env.IS_TURBOPACK_TEST ...(process.env.IS_TURBOPACK_TEST
? [ ? [
...@@ -109,9 +113,13 @@ const expectedWhenTrailingSlashFalse = [ ...@@ -109,9 +113,13 @@ const expectedWhenTrailingSlashFalse = [
'__next._tree.txt', '__next._tree.txt',
// Turbopack will output favicon in the _next/static/media folder // Turbopack will output favicon in the _next/static/media folder
...(process.env.IS_TURBOPACK_TEST ...(process.env.IS_TURBOPACK_TEST
? [expect.stringMatching(/_next\/static\/media\/favicon\.[0-9a-f]+\.ico/)] ? [
expect.stringMatching(
/_next\/static\/media\/favicon\.[0-9a-z_.~-]+\.ico/
),
]
: []), : []),
expect.stringMatching(/_next\/static\/media\/test\.[0-9a-f]+\.png/), expect.stringMatching(/_next\/static\/media\/test\.[0-9a-z_.~-]+\.png/),
expect.stringMatching(/_next\/static\/[A-Za-z0-9_-]+\/_buildManifest.js/), expect.stringMatching(/_next\/static\/[A-Za-z0-9_-]+\/_buildManifest.js/),
...(process.env.IS_TURBOPACK_TEST ...(process.env.IS_TURBOPACK_TEST
? [ ? [
......
...@@ -451,7 +451,7 @@ describe('app dir - basic', () => { ...@@ -451,7 +451,7 @@ describe('app dir - basic', () => {
const html = await next.render('/dashboard/index') const html = await next.render('/dashboard/index')
expect(html).toMatch( expect(html).toMatch(
process.env.IS_TURBOPACK_TEST process.env.IS_TURBOPACK_TEST
? /<script src="\/_next\/static\/chunks\/([\w-]*polyfill-nomodule|[0-9a-f]+)\.js(\?[^"]+)?" noModule="">/ ? /<script src="\/_next\/static\/chunks\/([\w-]*polyfill-nomodule|[0-9a-z_.~-]+)\.js(\?[^"]+)?" noModule="">/
: /<script src="\/_next\/static\/chunks\/polyfills(-\w+)?\.js(\?[^"]+)?" noModule="">/ : /<script src="\/_next\/static\/chunks\/polyfills(-\w+)?\.js(\?[^"]+)?" noModule="">/
) )
}) })
......
...@@ -77,7 +77,9 @@ describe('next-image-proxy', () => { ...@@ -77,7 +77,9 @@ describe('next-image-proxy', () => {
}) })
const local = await browser.elementByCss('#app-page').getAttribute('src') const local = await browser.elementByCss('#app-page').getAttribute('src')
expect(local.replace(/test\.[0-9a-f]{8,}\.png/g, 'test.HASH.png')).toEqual( expect(
local.replace(/test\.[0-9a-z_.~-]{4,}\.png/g, 'test.HASH.png')
).toEqual(
`/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.HASH.png&w=828&q=90${next.getAssetQuery(true)}` `/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Ftest.HASH.png&w=828&q=90${next.getAssetQuery(true)}`
) )
......
...@@ -291,5 +291,5 @@ describe('app dir - next-image', () => { ...@@ -291,5 +291,5 @@ describe('app dir - next-image', () => {
}) })
function stripTestHash(text: string) { function stripTestHash(text: string) {
return text.replace(/test\.[0-9a-f]{8,}\.(png|jpe?g)/g, 'test.HASH.$1') return text.replace(/test\.[0-9a-z_.~-]{4,}\.(png|jpe?g)/g, 'test.HASH.$1')
} }
...@@ -72,7 +72,7 @@ describe('node-worker-threads', () => { ...@@ -72,7 +72,7 @@ describe('node-worker-threads', () => {
const url = new URL(data.pngInfo.url, 'http://localhost') const url = new URL(data.pngInfo.url, 'http://localhost')
expect(url.pathname).toMatch( expect(url.pathname).toMatch(
/\/_next\/static.*\/test-image\.[a-f0-9]+\.png/ /\/_next\/static.*\/test-image\.[0-9a-z_.~-]+\.png/
) )
if (!isNextDev) { if (!isNextDev) {
expect(next.assetToken).toMatch(/.+/) expect(next.assetToken).toMatch(/.+/)
......
...@@ -15,7 +15,7 @@ describe('webpack-loader-module-type', () => { ...@@ -15,7 +15,7 @@ describe('webpack-loader-module-type', () => {
const $ = await next.render$('/') const $ = await next.render$('/')
const src = $('#svg-url').text() const src = $('#svg-url').text()
// asset/resource should emit the file and return URL path // asset/resource should emit the file and return URL path
expect(src).toMatch(/\/_next\/static\/media\/test\.[a-f0-9]+\.svg$/) expect(src).toMatch(/\/_next\/static\/media\/test\.[0-9a-z_.~-]+\.svg$/)
}) })
itTurbopackOnly( itTurbopackOnly(
......
...@@ -70,19 +70,19 @@ describe('Edge Compiler can import asset assets', () => { ...@@ -70,19 +70,19 @@ describe('Edge Compiler can import asset assets', () => {
expect(orderedAssets).toMatchObject([ expect(orderedAssets).toMatchObject([
{ {
name: expect.stringMatching( name: expect.stringMatching(
/server\/edge\/assets\/text-file\.[0-9a-f]{8}\.txt$/ /server\/edge\/assets\/text-file\.[0-9a-z_.~-]+\.txt$/
), ),
filePath: expect.stringMatching(/^server\/edge\/assets\/text-file/), filePath: expect.stringMatching(/^server\/edge\/assets\/text-file/),
}, },
{ {
name: expect.stringMatching( name: expect.stringMatching(
/^server\/edge\/assets\/vercel\.[0-9a-f]{8}\.png$/ /^server\/edge\/assets\/vercel\.[0-9a-z_.~-]+\.png$/
), ),
filePath: expect.stringMatching(/^server\/edge\/assets\/vercel/), filePath: expect.stringMatching(/^server\/edge\/assets\/vercel/),
}, },
{ {
name: expect.stringMatching( name: expect.stringMatching(
/^server\/edge\/assets\/world\.[0-9a-f]{8}\.json/ /^server\/edge\/assets\/world\.[0-9a-z_.~-]+\.json/
), ),
filePath: expect.stringMatching(/^server\/edge\/assets\/world/), filePath: expect.stringMatching(/^server\/edge\/assets\/world/),
}, },
......
...@@ -43,7 +43,7 @@ import { join } from 'path' ...@@ -43,7 +43,7 @@ import { join } from 'path'
} }
const expectedServer = const expectedServer =
/Hello <!-- -->42<!-- -->\+<!-- -->42<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png/ /Hello <!-- -->42<!-- -->\+<!-- -->42<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-z_.~-]+\.png<!-- -->\+<!-- -->\/_next\/static\/media\/vercel\.[0-9a-z_.~-]+\.png/
const expectedClient = new RegExp( const expectedClient = new RegExp(
expectedServer.source.replace(/<!-- -->/g, '') expectedServer.source.replace(/<!-- -->/g, '')
) )
...@@ -69,7 +69,7 @@ import { join } from 'path' ...@@ -69,7 +69,7 @@ import { join } from 'path'
expect( expect(
await browser.elementByCss('#static-image').getAttribute('src') await browser.elementByCss('#static-image').getAttribute('src')
).toMatch( ).toMatch(
/^\/_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fvercel\.[0-9a-f]{8}\.png&/ /^\/_next\/image\?url=%2F_next%2Fstatic%2Fmedia%2Fvercel\.[0-9a-z_.~-]+\.png&/
) )
) )
}) })
...@@ -84,7 +84,7 @@ import { join } from 'path' ...@@ -84,7 +84,7 @@ import { join } from 'path'
.elementByCss('#static-css') .elementByCss('#static-css')
.getComputedCss('background-image') .getComputedCss('background-image')
).toMatch( ).toMatch(
/^url\("http(s)?:\/\/.+\/_next\/static\/media\/vercel\.[0-9a-f]{8}\.png(?:\?.*)?"\)$/ /^url\("http(s)?:\/\/.+\/_next\/static\/media\/vercel\.[0-9a-z_.~-]+\.png(?:\?.*)?"\)$/
) )
) )
}) })
......
...@@ -200,5 +200,5 @@ describe(`Handle new URL asset references`, () => { ...@@ -200,5 +200,5 @@ describe(`Handle new URL asset references`, () => {
}) })
function stripVercelPngHash(text: string) { function stripVercelPngHash(text: string) {
return text.replace(/vercel\.[0-9a-f]{8,}\.png/g, 'vercel.HASH.png') return text.replace(/vercel\.[0-9a-z_.~-]{4,}\.png/g, 'vercel.HASH.png')
} }
...@@ -564,8 +564,8 @@ module.exports = { ...@@ -564,8 +564,8 @@ module.exports = {
expect(cssContent).toMatchInlineSnapshot(` expect(cssContent).toMatchInlineSnapshot(`
[ [
"/_next/static/chunks/HASH.css: "/_next/static/chunks/HASH.css:
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg),url(../media/dark2.3ca0d560.svg)} .red-text{color:red;background-image:url(../media/dark.0bi3upmbca6o8.svg),url(../media/dark2.0bi3upmbca6o8.svg)}
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder} .blue-text{color:orange;background-image:url(../media/light.0-fs_bhu4mhnn.svg);font-weight:bolder}
.blue-text{color:#00f}", .blue-text{color:#00f}",
] ]
`) `)
...@@ -573,8 +573,8 @@ module.exports = { ...@@ -573,8 +573,8 @@ module.exports = {
expect(cssContent).toMatchInlineSnapshot(` expect(cssContent).toMatchInlineSnapshot(`
[ [
"/_next/static/chunks/HASH.css: "/_next/static/chunks/HASH.css:
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg),url(../media/dark2.3ca0d560.svg)} .red-text{color:red;background-image:url(../media/dark.0bi3upmbca6o8.svg),url(../media/dark2.0bi3upmbca6o8.svg)}
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder} .blue-text{color:orange;background-image:url(../media/light.0-fs_bhu4mhnn.svg);font-weight:bolder}
.blue-text{color:#00f}", .blue-text{color:#00f}",
] ]
`) `)
...@@ -640,8 +640,8 @@ describe('CSS URL via `file-loader` and asset prefix (1)', () => { ...@@ -640,8 +640,8 @@ describe('CSS URL via `file-loader` and asset prefix (1)', () => {
expect(cssContent).toMatchInlineSnapshot(` expect(cssContent).toMatchInlineSnapshot(`
[ [
"/_next/static/chunks/HASH.css: "/_next/static/chunks/HASH.css:
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg) url(../media/dark2.3ca0d560.svg)} .red-text{color:red;background-image:url(../media/dark.0bi3upmbca6o8.svg) url(../media/dark2.0bi3upmbca6o8.svg)}
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder} .blue-text{color:orange;background-image:url(../media/light.0-fs_bhu4mhnn.svg);font-weight:bolder}
.blue-text{color:#00f}", .blue-text{color:#00f}",
] ]
`) `)
...@@ -692,8 +692,8 @@ describe('CSS URL via `file-loader` and asset prefix (2)', () => { ...@@ -692,8 +692,8 @@ describe('CSS URL via `file-loader` and asset prefix (2)', () => {
expect(cssContent).toMatchInlineSnapshot(` expect(cssContent).toMatchInlineSnapshot(`
[ [
"/_next/static/chunks/HASH.css: "/_next/static/chunks/HASH.css:
.red-text{color:red;background-image:url(../media/dark.3ca0d560.svg) url(../media/dark2.3ca0d560.svg)} .red-text{color:red;background-image:url(../media/dark.0bi3upmbca6o8.svg) url(../media/dark2.0bi3upmbca6o8.svg)}
.blue-text{color:orange;background-image:url(../media/light.c5f50e38.svg);font-weight:bolder} .blue-text{color:orange;background-image:url(../media/light.0-fs_bhu4mhnn.svg);font-weight:bolder}
.blue-text{color:#00f}", .blue-text{color:#00f}",
] ]
`) `)
...@@ -721,7 +721,7 @@ async function getStylesheetContents($, appPort, items) { ...@@ -721,7 +721,7 @@ async function getStylesheetContents($, appPort, items) {
const pathname = new URL(href, `http://localhost:${appPort}`).pathname const pathname = new URL(href, `http://localhost:${appPort}`).pathname
const text = await res.text() const text = await res.text()
results.push( results.push(
`${pathname.replace(/[0-9a-f]{8,}/g, 'HASH')}:\n${text `${pathname.replace(/\/([0-9a-z_.~-]{7,})\.(css|js)\b/g, '/HASH.$2')}:\n${text
.replace(/\/\*.*?\*\/\n?/g, '') .replace(/\/\*.*?\*\/\n?/g, '')
.replace(/(\?dpl=[^)"']+)/g, '') .replace(/(\?dpl=[^)"']+)/g, '')
.trim()}` .trim()}`
......
...@@ -1521,7 +1521,7 @@ export function runTests(ctx: RunTestsCtx) { ...@@ -1521,7 +1521,7 @@ export function runTests(ctx: RunTestsCtx) {
if (!ctx.isDev) { if (!ctx.isDev) {
const filename = fs const filename = fs
.readdirSync(join(ctx.appDir, '.next/static/media')) .readdirSync(join(ctx.appDir, '.next/static/media'))
.find((f) => /^test\.[0-9a-f]+\.jpg$/.test(f)) .find((f) => /^test\.[0-9a-z_.~-]+\.jpg$/.test(f))
expect(filename).toBeString() expect(filename).toBeString()
const query: Record<string, string> = { const query: Record<string, string> = {
url: `/_next/static/media/${filename}`, url: `/_next/static/media/${filename}`,
......
...@@ -75,7 +75,7 @@ function runTests(mode: 'dev' | 'server') { ...@@ -75,7 +75,7 @@ function runTests(mode: 'dev' | 'server') {
) )
expect( expect(
(await browser.elementById('static-image').getAttribute('src')).replace( (await browser.elementById('static-image').getAttribute('src')).replace(
/test\.[a-z0-9]+\.jpg/, /test\.[0-9a-z_.~-]+\.jpg/,
'test.HASH.jpg' 'test.HASH.jpg'
) )
).toMatch('/_next/static/media/test.HASH.jpg' + assetDpl) ).toMatch('/_next/static/media/test.HASH.jpg' + assetDpl)
......
...@@ -1863,5 +1863,5 @@ describe('Image Component Default Tests', () => { ...@@ -1863,5 +1863,5 @@ describe('Image Component Default Tests', () => {
}) })
function stripTestHash(text: string) { function stripTestHash(text: string) {
return text.replace(/test\.[0-9a-f]{8,}\.(png|jpe?g)/g, 'test.HASH.$1') return text.replace(/test\.[0-9a-z_.~-]{4,}\.(png|jpe?g)/g, 'test.HASH.$1')
} }
...@@ -78,5 +78,5 @@ describe('Image Component basePath + trailingSlash Tests', () => { ...@@ -78,5 +78,5 @@ describe('Image Component basePath + trailingSlash Tests', () => {
}) })
function stripTestHash(text: string) { function stripTestHash(text: string) {
return text.replace(/test\.[0-9a-f]{8,}\.(png|jpe?g)/g, 'test.HASH.$1') return text.replace(/test\.[0-9a-z_.~-]{4,}\.(png|jpe?g)/g, 'test.HASH.$1')
} }
...@@ -1818,5 +1818,5 @@ describe('Image Component Default Tests', () => { ...@@ -1818,5 +1818,5 @@ describe('Image Component Default Tests', () => {
}) })
function stripTestHash(text: string) { function stripTestHash(text: string) {
return text.replace(/test\.[0-9a-f]{8,}\.(png|jpe?g)/g, 'test.HASH.$1') return text.replace(/test\.[0-9a-z_.~-]{4,}\.(png|jpe?g)/g, 'test.HASH.$1')
} }
/// URL-safe, filesystem-safe alphabet for hash encoding: `0-9 a-z _ - ~ .`
///
/// All 40 characters are RFC 3986 unreserved characters and are safe on
/// case-insensitive filesystems (macOS HFS+/APFS, Windows NTFS).
const BASE40_CHARS: &[u8; 40] = b"0123456789abcdefghijklmnopqrstuvwxyz_-~.";
const BASE: u128 = BASE40_CHARS.len() as u128;
/// Computes the number of base-N digits needed to represent all values of
/// `bits` width: the smallest `n` such that `base^n > 2^bits - 1`.
const fn digits_for_bits(base: u128, bits: u32) -> usize {
let mut power: u128 = 1;
let mut n: usize = 0;
// We need base^n > u{bits}::MAX, i.e. base^n > 2^bits - 1.
// Since 2^128 doesn't fit in u128, we compare by checking if
// power has "overflowed past" the bit width. For bits == 128,
// we need base^n >= 2^128 which means power must overflow to 0
// (or we track via a flag). For bits < 128, we compare directly.
loop {
// Check if power > 2^bits - 1 (i.e. power can represent all values)
if bits < 128 && power > ((1u128 << bits) - 1) {
break;
}
let (new_power, overflowed) = power.overflowing_mul(base);
n += 1;
if overflowed {
// power * base >= 2^128 > 2^bits - 1 for any bits <= 128
break;
}
power = new_power;
}
n
}
/// Number of base40 characters needed to represent a 64-bit value without
/// information loss.
pub const BASE40_LEN_64: usize = digits_for_bits(BASE, 64);
/// Number of base40 characters needed to represent a 128-bit value without
/// information loss.
pub const BASE40_LEN_128: usize = digits_for_bits(BASE, 128);
// Verify our const computation matches the expected values.
const _: () = assert!(BASE40_LEN_64 == 13);
const _: () = assert!(BASE40_LEN_128 == 25);
/// Encodes a value into a fixed-width base40 string by repeatedly dividing by
/// 40.
fn encode_base40_fixed<const N: usize>(mut n: u128) -> String {
let mut buf = [b'0'; N];
for i in (0..N).rev() {
buf[i] = BASE40_CHARS[(n % 40) as usize];
n /= 40;
}
// SAFETY: BASE40_CHARS only contains ASCII bytes.
unsafe { String::from_utf8_unchecked(buf.to_vec()) }
}
/// Encodes a 64-bit unsigned integer into a fixed-width 13-character base40
/// string.
pub fn encode_base40(n: u64) -> String {
encode_base40_fixed::<BASE40_LEN_64>(n as u128)
}
/// Encodes a 128-bit unsigned integer into a fixed-width 25-character base40
/// string.
pub fn encode_base40_128(n: u128) -> String {
encode_base40_fixed::<BASE40_LEN_128>(n)
}
/// Encodes a 64-bit unsigned integer into a base64 string (11 chars, no
/// padding).
///
/// This encoding is used for version identifiers that don't appear in URLs or
/// filenames (e.g. HMR update hashes).
pub fn encode_base64(n: u64) -> String {
data_encoding::BASE64_NOPAD.encode(&n.to_be_bytes())
}
//! Hashing and encoding functions for turbopack. //! Hashing and encoding functions for turbopack.
//! //!
//! An example use of this module is hashing a file's content for cache //! An example use of this module is hashing a file's content for cache
//! invalidation, and encoding the hash to an hexadecimal string for use in a //! invalidation, and encoding the hash to a base40 or hexadecimal string for
//! file name. //! use in a file name.
mod base40;
mod base64;
mod deterministic_hash; mod deterministic_hash;
mod hex; mod hex;
mod sha; mod sha;
...@@ -18,6 +20,10 @@ pub enum HashAlgorithm { ...@@ -18,6 +20,10 @@ pub enum HashAlgorithm {
#[default] #[default]
Xxh3Hash64Hex, Xxh3Hash64Hex,
Xxh3Hash128Hex, Xxh3Hash128Hex,
/// xxh3 64-bit hash encoded as a 13-character base40 string (0-9 a-z _ - ~ .)
Xxh3Hash64Base40,
/// xxh3 128-bit hash encoded as a 25-character base40 string (0-9 a-z _ - ~ .)
Xxh3Hash128Base40,
/// Used for https://nextjs.org/docs/app/guides/content-security-policy#enabling-sri /// Used for https://nextjs.org/docs/app/guides/content-security-policy#enabling-sri
Sha256Base64, Sha256Base64,
/// Used for https://nextjs.org/docs/app/guides/content-security-policy#enabling-sri /// Used for https://nextjs.org/docs/app/guides/content-security-policy#enabling-sri
...@@ -38,6 +44,16 @@ pub fn deterministic_hash<T: DeterministicHash>(input: T, algorithm: HashAlgorit ...@@ -38,6 +44,16 @@ pub fn deterministic_hash<T: DeterministicHash>(input: T, algorithm: HashAlgorit
input.deterministic_hash(&mut hasher); input.deterministic_hash(&mut hasher);
encode_hex_128(hasher.finish()) encode_hex_128(hasher.finish())
} }
HashAlgorithm::Xxh3Hash64Base40 => {
let mut hasher = Xxh3Hash64Hasher::new();
input.deterministic_hash(&mut hasher);
encode_base40(hasher.finish())
}
HashAlgorithm::Xxh3Hash128Base40 => {
let mut hasher = Xxh3Hash128Hasher::new();
input.deterministic_hash(&mut hasher);
encode_base40_128(hasher.finish())
}
HashAlgorithm::Sha256Base64 => { HashAlgorithm::Sha256Base64 => {
let mut hasher = ShaHasher::new_sha256(); let mut hasher = ShaHasher::new_sha256();
input.deterministic_hash(&mut hasher); input.deterministic_hash(&mut hasher);
...@@ -57,6 +73,8 @@ pub fn deterministic_hash<T: DeterministicHash>(input: T, algorithm: HashAlgorit ...@@ -57,6 +73,8 @@ pub fn deterministic_hash<T: DeterministicHash>(input: T, algorithm: HashAlgorit
} }
pub use crate::{ pub use crate::{
base40::{BASE40_LEN_64, BASE40_LEN_128, encode_base40, encode_base40_128},
base64::encode_base64,
deterministic_hash::{DeterministicHash, DeterministicHasher}, deterministic_hash::{DeterministicHash, DeterministicHasher},
hex::{encode_hex, encode_hex_128}, hex::{encode_hex, encode_hex_128},
sha::ShaHasher, sha::ShaHasher,
......
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use bincode::{Decode, Encode};
use tracing::Instrument; use tracing::Instrument;
use turbo_rcstr::{RcStr, rcstr}; use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{ use turbo_tasks::{FxIndexMap, ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc};
FxIndexMap, NonLocalValue, ResolvedVc, TaskInput, TryJoinIterExt, Upcast, ValueToString, Vc,
trace::TraceRawVcs,
};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{DeterministicHash, HashAlgorithm}; use turbo_tasks_hash::HashAlgorithm;
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule,
ChunkingConfig, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAsset, ChunkingConfig, ChunkingConfigs, ChunkingContext, ContentHashing, EntryChunkGroupResult,
EvaluatableAssets, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences, EvaluatableAsset, EvaluatableAssets, MinifyType, SourceMapSourceType, SourceMapsType,
UrlBehavior, UnusedReferences, UrlBehavior,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
chunk_id_strategy::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
...@@ -53,31 +49,6 @@ pub enum CurrentChunkMethod { ...@@ -53,31 +49,6 @@ pub enum CurrentChunkMethod {
pub const CURRENT_CHUNK_METHOD_DOCUMENT_CURRENT_SCRIPT_EXPR: &str = pub const CURRENT_CHUNK_METHOD_DOCUMENT_CURRENT_SCRIPT_EXPR: &str =
"typeof document === \"object\" ? document.currentScript : undefined"; "typeof document === \"object\" ? document.currentScript : undefined";
#[derive(
Debug,
TaskInput,
Clone,
Copy,
PartialEq,
Eq,
Hash,
TraceRawVcs,
DeterministicHash,
NonLocalValue,
Encode,
Decode,
)]
pub enum ContentHashing {
/// Direct content hashing: Embeds the chunk content hash directly into the referencing chunk.
/// Benefit: No hash manifest needed.
/// Downside: Causes cascading hash invalidation.
Direct {
/// The length of the content hash in hex chars. Anything lower than 8 is not recommended
/// due to the high risk of collisions.
length: u8,
},
}
pub struct BrowserChunkingContextBuilder { pub struct BrowserChunkingContextBuilder {
chunking_context: BrowserChunkingContext, chunking_context: BrowserChunkingContext,
} }
...@@ -226,8 +197,13 @@ impl BrowserChunkingContextBuilder { ...@@ -226,8 +197,13 @@ impl BrowserChunkingContextBuilder {
self self
} }
pub fn use_content_hashing(mut self, content_hashing: ContentHashing) -> Self { pub fn chunk_content_hashing(mut self, content_hashing: ContentHashing) -> Self {
self.chunking_context.content_hashing = Some(content_hashing); self.chunking_context.chunk_content_hashing = Some(content_hashing);
self
}
pub fn asset_content_hashing(mut self, content_hashing: ContentHashing) -> Self {
self.chunking_context.asset_content_hashing = content_hashing;
self self
} }
...@@ -314,8 +290,10 @@ pub struct BrowserChunkingContext { ...@@ -314,8 +290,10 @@ pub struct BrowserChunkingContext {
runtime_type: RuntimeType, runtime_type: RuntimeType,
/// Whether to minify resulting chunks /// Whether to minify resulting chunks
minify_type: MinifyType, minify_type: MinifyType,
/// Whether content hashing is enabled. /// Whether content hashing is enabled for chunk filenames.
content_hashing: Option<ContentHashing>, chunk_content_hashing: Option<ContentHashing>,
/// Content hashing for asset filenames.
asset_content_hashing: ContentHashing,
/// Whether to generate source maps /// Whether to generate source maps
source_maps_type: SourceMapsType, source_maps_type: SourceMapsType,
/// Method to use when figuring out the current chunk src /// Method to use when figuring out the current chunk src
...@@ -377,7 +355,8 @@ impl BrowserChunkingContext { ...@@ -377,7 +355,8 @@ impl BrowserChunkingContext {
environment, environment,
runtime_type, runtime_type,
minify_type: MinifyType::NoMinify, minify_type: MinifyType::NoMinify,
content_hashing: None, chunk_content_hashing: None,
asset_content_hashing: ContentHashing::Direct { length: 13 },
source_maps_type: SourceMapsType::Full, source_maps_type: SourceMapsType::Full,
current_chunk_method: CurrentChunkMethod::StringLiteral, current_chunk_method: CurrentChunkMethod::StringLiteral,
manifest_chunks: false, manifest_chunks: false,
...@@ -496,7 +475,7 @@ impl BrowserChunkingContext { ...@@ -496,7 +475,7 @@ impl BrowserChunkingContext {
ChunkPathInfo { ChunkPathInfo {
root_path: self.root_path.clone(), root_path: self.root_path.clone(),
chunk_root_path: self.chunk_root_path.clone(), chunk_root_path: self.chunk_root_path.clone(),
content_hashing: self.content_hashing, chunk_content_hashing: self.chunk_content_hashing,
} }
.cell() .cell()
} }
...@@ -563,10 +542,10 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -563,10 +542,10 @@ impl ChunkingContext for BrowserChunkingContext {
); );
let ChunkPathInfo { let ChunkPathInfo {
chunk_root_path, chunk_root_path,
content_hashing, chunk_content_hashing,
root_path, root_path,
} = &*self.chunk_path_info().await?; } = &*self.chunk_path_info().await?;
let name = match *content_hashing { let name = match *chunk_content_hashing {
None => { None => {
ident ident
.output_name(root_path.clone(), prefix, extension) .output_name(root_path.clone(), prefix, extension)
...@@ -579,7 +558,7 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -579,7 +558,7 @@ impl ChunkingContext for BrowserChunkingContext {
}; };
let hash = asset let hash = asset
.content() .content()
.content_hash(HashAlgorithm::Xxh3Hash128Hex) .content_hash(HashAlgorithm::Xxh3Hash128Base40)
.await?; .await?;
let hash = hash.as_ref().context( let hash = hash.as_ref().context(
"chunk_path requires an asset with file content when content hashing is \ "chunk_path requires an asset with file content when content hashing is \
...@@ -653,16 +632,14 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -653,16 +632,14 @@ impl ChunkingContext for BrowserChunkingContext {
let source_path = original_asset_ident.path().await?; let source_path = original_asset_ident.path().await?;
let basename = source_path.file_name(); let basename = source_path.file_name();
let content_hash = content_hash.await?; let content_hash = content_hash.await?;
let ContentHashing::Direct { length } = self.asset_content_hashing;
let short_hash = &content_hash[..length as usize];
let asset_path = match source_path.extension_ref() { let asset_path = match source_path.extension_ref() {
Some(ext) => format!( Some(ext) => format!(
"{basename}.{content_hash}.{ext}", "{basename}.{short_hash}.{ext}",
basename = &basename[..basename.len() - ext.len() - 1], basename = &basename[..basename.len() - ext.len() - 1],
content_hash = &content_hash[..8]
),
None => format!(
"{basename}.{content_hash}",
content_hash = &content_hash[..8]
), ),
None => format!("{basename}.{short_hash}"),
}; };
let asset_root_path = tag let asset_root_path = tag
...@@ -976,5 +953,5 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -976,5 +953,5 @@ impl ChunkingContext for BrowserChunkingContext {
struct ChunkPathInfo { struct ChunkPathInfo {
root_path: FileSystemPath, root_path: FileSystemPath,
chunk_root_path: FileSystemPath, chunk_root_path: FileSystemPath,
content_hashing: Option<ContentHashing>, chunk_content_hashing: Option<ContentHashing>,
} }
use anyhow::Result; use anyhow::Result;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ResolvedVc, TraitRef, TryJoinIterExt, Vc}; use turbo_tasks::{FxIndexMap, ResolvedVc, TraitRef, TryJoinIterExt, Vc};
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_base64};
use turbopack_core::version::{Version, VersionedContentMerger}; use turbopack_core::version::{Version, VersionedContentMerger};
type VersionTraitRef = TraitRef<Box<dyn Version>>; type VersionTraitRef = TraitRef<Box<dyn Version>>;
...@@ -62,7 +62,7 @@ impl Version for EcmascriptDevChunkListVersion { ...@@ -62,7 +62,7 @@ impl Version for EcmascriptDevChunkListVersion {
hasher.write_value(id); hasher.write_value(id);
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hash = encode_base64(hash);
Ok(Vc::cell(hex_hash.into())) Ok(Vc::cell(hash.into()))
} }
} }
use anyhow::Result; use anyhow::Result;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{ReadRef, TryJoinIterExt, Vc}; use turbo_tasks::{ReadRef, TryJoinIterExt, Vc};
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_base64};
use turbopack_core::version::Version; use turbopack_core::version::Version;
use super::super::version::EcmascriptBrowserChunkVersion; use super::super::version::EcmascriptBrowserChunkVersion;
...@@ -35,7 +35,7 @@ impl Version for EcmascriptBrowserMergedChunkVersion { ...@@ -35,7 +35,7 @@ impl Version for EcmascriptBrowserMergedChunkVersion {
hasher.write_value(id); hasher.write_value(id);
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hash = encode_base64(hash);
Ok(Vc::cell(hex_hash.into())) Ok(Vc::cell(hash.into()))
} }
} }
...@@ -2,7 +2,7 @@ use anyhow::Result; ...@@ -2,7 +2,7 @@ use anyhow::Result;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, Vc, turbobail}; use turbo_tasks::{FxIndexMap, Vc, turbobail};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_base64};
use turbopack_core::{chunk::ModuleId, version::Version}; use turbopack_core::{chunk::ModuleId, version::Version};
use turbopack_ecmascript::chunk::EcmascriptChunkContent; use turbopack_ecmascript::chunk::EcmascriptChunkContent;
...@@ -58,7 +58,7 @@ impl Version for EcmascriptBrowserChunkVersion { ...@@ -58,7 +58,7 @@ impl Version for EcmascriptBrowserChunkVersion {
hasher.write_value(hash); hasher.write_value(hash);
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hash = encode_base64(hash);
Vc::cell(hex_hash.into()) Vc::cell(hash.into())
} }
} }
...@@ -8,5 +8,5 @@ pub mod ecmascript; ...@@ -8,5 +8,5 @@ pub mod ecmascript;
pub mod react_refresh; pub mod react_refresh;
pub use chunking_context::{ pub use chunking_context::{
BrowserChunkingContext, BrowserChunkingContextBuilder, ContentHashing, CurrentChunkMethod, BrowserChunkingContext, BrowserChunkingContextBuilder, CurrentChunkMethod,
}; };
...@@ -16,13 +16,13 @@ use turbo_tasks_backend::{ ...@@ -16,13 +16,13 @@ use turbo_tasks_backend::{
use turbo_tasks_fs::FileSystem; use turbo_tasks_fs::FileSystem;
use turbo_unix_path::join_path; use turbo_unix_path::join_path;
use turbopack::global_module_ids::get_global_module_id_strategy; use turbopack::global_module_ids::get_global_module_id_strategy;
use turbopack_browser::{BrowserChunkingContext, ContentHashing, CurrentChunkMethod}; use turbopack_browser::{BrowserChunkingContext, CurrentChunkMethod};
use turbopack_cli_utils::issue::{ConsoleUi, LogOptions}; use turbopack_cli_utils::issue::{ConsoleUi, LogOptions};
use turbopack_core::{ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
ChunkingConfig, ChunkingContext, ChunkingContextExt, EvaluatableAsset, MangleType, ChunkingConfig, ChunkingContext, ChunkingContextExt, ContentHashing, EvaluatableAsset,
MinifyType, SourceMapsType, availability_info::AvailabilityInfo, MangleType, MinifyType, SourceMapsType, availability_info::AvailabilityInfo,
}, },
environment::{BrowserEnvironment, Environment, ExecutionEnvironment, NodeJsEnvironment}, environment::{BrowserEnvironment, Environment, ExecutionEnvironment, NodeJsEnvironment},
ident::AssetIdent, ident::AssetIdent,
...@@ -375,7 +375,8 @@ async fn build_internal( ...@@ -375,7 +375,8 @@ async fn build_internal(
..Default::default() ..Default::default()
}, },
) )
.use_content_hashing(ContentHashing::Direct { length: 16 }) .chunk_content_hashing(ContentHashing::Direct { length: 13 })
.asset_content_hashing(ContentHashing::Direct { length: 13 })
.nested_async_availability(true) .nested_async_availability(true)
.module_merging(scope_hoist); .module_merging(scope_hoist);
} }
......
...@@ -46,6 +46,31 @@ use crate::{ ...@@ -46,6 +46,31 @@ use crate::{
output::{OutputAssets, OutputAssetsReference}, output::{OutputAssets, OutputAssetsReference},
}; };
#[derive(
Debug,
TaskInput,
Clone,
Copy,
PartialEq,
Eq,
Hash,
TraceRawVcs,
DeterministicHash,
NonLocalValue,
Encode,
Decode,
)]
pub enum ContentHashing {
/// Direct content hashing: Embeds the chunk content hash directly into the referencing chunk.
/// Benefit: No hash manifest needed.
/// Downside: Causes cascading hash invalidation.
Direct {
/// The length of the content hash in base40 chars. Anything lower than 7 is not
/// recommended due to the high risk of collisions.
length: u8,
},
}
/// A module id, which can be a number or string /// A module id, which can be a number or string
#[turbo_tasks::value(shared, operation)] #[turbo_tasks::value(shared, operation)]
#[derive(Debug, Clone, Hash, Ord, PartialOrd, DeterministicHash, Serialize, ValueToString)] #[derive(Debug, Clone, Hash, Ord, PartialOrd, DeterministicHash, Serialize, ValueToString)]
......
...@@ -9,7 +9,7 @@ use turbo_tasks::{ ...@@ -9,7 +9,7 @@ use turbo_tasks::{
NonLocalValue, ReadRef, ResolvedVc, TaskInput, ValueToString, Vc, trace::TraceRawVcs, turbofmt, NonLocalValue, ReadRef, ResolvedVc, TaskInput, ValueToString, Vc, trace::TraceRawVcs, turbofmt,
}; };
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher, encode_hex, hash_xxh3_hash64}; use turbo_tasks_hash::{DeterministicHash, Xxh3Hash64Hasher, encode_base40, hash_xxh3_hash64};
use crate::resolve::ModulePart; use crate::resolve::ModulePart;
...@@ -335,8 +335,9 @@ impl AssetIdent { ...@@ -335,8 +335,9 @@ impl AssetIdent {
} }
if has_hash { if has_hash {
let hash = encode_hex(hasher.finish()); let hash = encode_base40(hasher.finish());
let truncated_hash = &hash[..8]; // 7 base40 chars ≈ 37 bits of collision resistance
let truncated_hash = &hash[..7];
write!(name, "_{truncated_hash}")?; write!(name, "_{truncated_hash}")?;
} }
...@@ -357,8 +358,9 @@ impl AssetIdent { ...@@ -357,8 +358,9 @@ impl AssetIdent {
} }
} }
if i > 0 { if i > 0 {
let hash = encode_hex(hash_xxh3_hash64(&name.as_bytes()[..i])); let hash = encode_base40(hash_xxh3_hash64(&name.as_bytes()[..i]));
let truncated_hash = &hash[..5]; // 4 base40 chars ≈ 21 bits — just a short disambiguator prefix
let truncated_hash = &hash[..4];
name = format!("{}_{}", truncated_hash, &name[i..]); name = format!("{}_{}", truncated_hash, &name[i..]);
} }
// We need to make sure that `.json` and `.json.js` doesn't end up with the same // We need to make sure that `.json` and `.json.js` doesn't end up with the same
......
...@@ -226,7 +226,7 @@ impl FileHashVersion { ...@@ -226,7 +226,7 @@ impl FileHashVersion {
match asset_content { match asset_content {
AssetContent::File(file_vc) => { AssetContent::File(file_vc) => {
let hash = file_vc let hash = file_vc
.content_hash(HashAlgorithm::Xxh3Hash128Hex) .content_hash(HashAlgorithm::Xxh3Hash128Base40)
.owned() .owned()
.await? .await?
.context("file not found")?; .context("file not found")?;
......
...@@ -6,7 +6,7 @@ use turbo_tasks::{ ...@@ -6,7 +6,7 @@ use turbo_tasks::{
NonLocalValue, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, Vc, trace::TraceRawVcs, NonLocalValue, ReadRef, ResolvedVc, TaskInput, TryJoinIterExt, Vc, trace::TraceRawVcs,
}; };
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_base64};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
chunk::{ chunk::{
...@@ -289,7 +289,7 @@ impl Version for DevHtmlAssetVersion { ...@@ -289,7 +289,7 @@ impl Version for DevHtmlAssetVersion {
hasher.write_ref(body); hasher.write_ref(body);
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hash = encode_base64(hash);
Vc::cell(hex_hash.into()) Vc::cell(hash.into())
} }
} }
...@@ -7,8 +7,9 @@ use turbopack_core::{ ...@@ -7,8 +7,9 @@ use turbopack_core::{
asset::Asset, asset::Asset,
chunk::{ chunk::{
AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule, AssetSuffix, Chunk, ChunkGroupResult, ChunkItem, ChunkType, ChunkableModule,
ChunkingConfig, ChunkingConfigs, ChunkingContext, EntryChunkGroupResult, EvaluatableAsset, ChunkingConfig, ChunkingConfigs, ChunkingContext, ContentHashing, EntryChunkGroupResult,
MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences, UrlBehavior, EvaluatableAsset, MinifyType, SourceMapSourceType, SourceMapsType, UnusedReferences,
UrlBehavior,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
chunk_group::{MakeChunkGroupResult, make_chunk_group}, chunk_group::{MakeChunkGroupResult, make_chunk_group},
chunk_id_strategy::ModuleIdStrategy, chunk_id_strategy::ModuleIdStrategy,
...@@ -156,6 +157,11 @@ impl NodeJsChunkingContextBuilder { ...@@ -156,6 +157,11 @@ impl NodeJsChunkingContextBuilder {
self self
} }
pub fn asset_content_hashing(mut self, content_hashing: ContentHashing) -> Self {
self.chunking_context.asset_content_hashing = content_hashing;
self
}
/// Builds the chunking context. /// Builds the chunking context.
pub fn build(self) -> Vc<NodeJsChunkingContext> { pub fn build(self) -> Vc<NodeJsChunkingContext> {
NodeJsChunkingContext::cell(self.chunking_context) NodeJsChunkingContext::cell(self.chunking_context)
...@@ -226,6 +232,8 @@ pub struct NodeJsChunkingContext { ...@@ -226,6 +232,8 @@ pub struct NodeJsChunkingContext {
debug_ids: bool, debug_ids: bool,
/// Global variable names to forward to workers (e.g. NEXT_DEPLOYMENT_ID) /// Global variable names to forward to workers (e.g. NEXT_DEPLOYMENT_ID)
worker_forwarded_globals: Vec<RcStr>, worker_forwarded_globals: Vec<RcStr>,
/// Content hashing for asset filenames.
asset_content_hashing: ContentHashing,
} }
impl NodeJsChunkingContext { impl NodeJsChunkingContext {
...@@ -270,6 +278,7 @@ impl NodeJsChunkingContext { ...@@ -270,6 +278,7 @@ impl NodeJsChunkingContext {
chunking_configs: Default::default(), chunking_configs: Default::default(),
debug_ids: false, debug_ids: false,
worker_forwarded_globals: vec![], worker_forwarded_globals: vec![],
asset_content_hashing: ContentHashing::Direct { length: 13 },
}, },
} }
} }
...@@ -461,16 +470,14 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -461,16 +470,14 @@ impl ChunkingContext for NodeJsChunkingContext {
let source_path = original_asset_ident.path().await?; let source_path = original_asset_ident.path().await?;
let basename = source_path.file_name(); let basename = source_path.file_name();
let content_hash = content_hash.await?; let content_hash = content_hash.await?;
let ContentHashing::Direct { length } = self.asset_content_hashing;
let short_hash = &content_hash[..length as usize];
let asset_path = match source_path.extension_ref() { let asset_path = match source_path.extension_ref() {
Some(ext) => format!( Some(ext) => format!(
"{basename}.{content_hash}.{ext}", "{basename}.{short_hash}.{ext}",
basename = &basename[..basename.len() - ext.len() - 1], basename = &basename[..basename.len() - ext.len() - 1],
content_hash = &content_hash[..8]
),
None => format!(
"{basename}.{content_hash}",
content_hash = &content_hash[..8]
), ),
None => format!("{basename}.{short_hash}"),
}; };
let asset_root_path = tag let asset_root_path = tag
......
...@@ -2,7 +2,7 @@ use anyhow::Result; ...@@ -2,7 +2,7 @@ use anyhow::Result;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ReadRef, Vc, turbobail}; use turbo_tasks::{FxIndexMap, ReadRef, Vc, turbobail};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_hex}; use turbo_tasks_hash::{Xxh3Hash64Hasher, encode_base64};
use turbopack_core::{ use turbopack_core::{
chunk::{MinifyType, ModuleId}, chunk::{MinifyType, ModuleId},
version::Version, version::Version,
...@@ -74,7 +74,7 @@ impl Version for EcmascriptBuildNodeChunkVersion { ...@@ -74,7 +74,7 @@ impl Version for EcmascriptBuildNodeChunkVersion {
hasher.write_value(hash); hasher.write_value(hash);
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hash = encode_base64(hash);
Vc::cell(hex_hash.into()) Vc::cell(hash.into())
} }
} }
...@@ -41,7 +41,7 @@ impl OutputAsset for StaticOutputAsset { ...@@ -41,7 +41,7 @@ impl OutputAsset for StaticOutputAsset {
async fn path(&self) -> Result<Vc<FileSystemPath>> { async fn path(&self) -> Result<Vc<FileSystemPath>> {
let content = self.source.content(); let content = self.source.content();
let content_hash = content let content_hash = content
.content_hash(HashAlgorithm::Xxh3Hash128Hex) .content_hash(HashAlgorithm::Xxh3Hash128Base40)
.owned() .owned()
.await? .await?
.context( .context(
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0tuk_tests_snapshot_basic-tree-shake_dynamic-import_input_index_0q~hmwn.js",
{"otherChunks":["output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_10~7x1o.js","output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_index_0q0x2fi.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_index_9775ceed.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_index_0q0x2fi.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
async function main() { async function main() {
...@@ -9,4 +9,4 @@ main(); ...@@ -9,4 +9,4 @@ main();
}), }),
]); ]);
//# sourceMappingURL=bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_index_9775ceed.js.map //# sourceMappingURL=0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_index_0q0x2fi.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_a280e616.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_0r_so._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -182,4 +182,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo ...@@ -182,4 +182,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo
}), }),
]); ]);
//# sourceMappingURL=bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_a280e616.js.map //# sourceMappingURL=0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_0r_so._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_ee638b2a.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_10~7x1o.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript, async loader)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => { __turbopack_context__.v((parentImport) => {
return Promise.all([ return Promise.all([
"output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_a280e616.js" "output/0wxz_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_0r_so._.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => { ].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript)"); return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/lib.js [test] (ecmascript)");
}); });
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_dynamic-import_input_index_7dac1ace.js",
{"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_lib_ee638b2a.js","output/bf321_tests_snapshot_basic-tree-shake_dynamic-import_input_index_9775ceed.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/dynamic-import/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_6eee2cc7._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0j2ccd1._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -94,4 +94,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$ ...@@ -94,4 +94,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_6eee2cc7._.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0j2ccd1._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_tree-shaking_dce_input_index_ae3d8f84.js", "output/0tuk_tests_snapshot_basic-tree-shake_export-named_input_index_0zf_w72.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_tree-shaking_dce_input_index_969f085a.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/tree-shaking/dce/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_0j2ccd1._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_export-named_input_index_28364f2a.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-named_input_6eee2cc7._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-named/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_c8f48bdf._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_0yk~6hr._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -189,4 +189,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$ ...@@ -189,4 +189,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_c8f48bdf._.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_0yk~6hr._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_index_a65f39c8.js", "output/0tuk_tests_snapshot_basic-tree-shake_export-namespace_input_index_0fhdicw.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_import-meta_esm-multiple_input_7a6228e8._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/import-meta/esm-multiple/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_0yk~6hr._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_export-namespace_input_index_2b1fc03b.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_export-namespace_input_c8f48bdf._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/export-namespace/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_cfaa8b2b._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_0zr2xyk._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -77,4 +77,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$ ...@@ -77,4 +77,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_cfaa8b2b._.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_0zr2xyk._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0tuk_tests_snapshot_basic-tree-shake_import-named-all_input_index_0u6ztcj.js",
{"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_0zr2xyk._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_import-named-all_input_index_919866a5.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-named-all_input_cfaa8b2b._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named-all/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_bd92935b._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_0wmtce2._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -77,4 +77,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$ ...@@ -77,4 +77,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_bd92935b._.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_0wmtce2._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_use-strict_input_index_07a7ebb3.js", "output/0tuk_tests_snapshot_basic-tree-shake_import-named_input_index_0hj7_ki.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_use-strict_input_index_4e0d67f8.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/use-strict/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-named_input_0wmtce2._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-named/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_bba52bc8._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_0w9jkvh._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -173,4 +173,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$ ...@@ -173,4 +173,4 @@ console.log(__TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_bba52bc8._.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_0w9jkvh._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0tuk_tests_snapshot_basic-tree-shake_import-namespace_input_index_0_g50nn.js",
{"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_0w9jkvh._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_import-namespace_input_index_a6f015be.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic-tree-shake_import-namespace_input_bba52bc8._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-namespace/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0tuk_tests_snapshot_basic-tree-shake_import-side-effect_input_index_05zmix2.js",
{"otherChunks":["output/0wxz_tests_snapshot_basic-tree-shake_import-side-effect_input_12e1m28._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_import-side-effect_input_f683dccc._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_import-side-effect_input_12e1m28._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -53,4 +53,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo ...@@ -53,4 +53,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo
}), }),
]); ]);
//# sourceMappingURL=bf321_tests_snapshot_basic-tree-shake_import-side-effect_input_f683dccc._.js.map //# sourceMappingURL=0wxz_tests_snapshot_basic-tree-shake_import-side-effect_input_12e1m28._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_import-side-effect_input_index_e7475abd.js",
{"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_import-side-effect_input_f683dccc._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/import-side-effect/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0tuk_tests_snapshot_basic-tree-shake_require-side-effect_input_index_0v7fuxm.js",
{"otherChunks":["output/0wxz_tests_snapshot_basic-tree-shake_require-side-effect_input_08~4tz.._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_require-side-effect_input_341cf5f1._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_require-side-effect_input_08~4tz.._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/lib.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -186,4 +186,4 @@ const { cat } = __turbopack_context__.r("[project]/turbopack/crates/turbopack-te ...@@ -186,4 +186,4 @@ const { cat } = __turbopack_context__.r("[project]/turbopack/crates/turbopack-te
}), }),
]); ]);
//# sourceMappingURL=bf321_tests_snapshot_basic-tree-shake_require-side-effect_input_341cf5f1._.js.map //# sourceMappingURL=0wxz_tests_snapshot_basic-tree-shake_require-side-effect_input_08~4tz.._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_require-side-effect_input_index_702672b9.js", "output/0tuk_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_0dmw76_.js",
{"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_require-side-effect_input_341cf5f1._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/require-side-effect/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/0wxz_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_04b4ex6.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/bf321_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_18e65124.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0wxz_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_04b4ex6.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript) <internal part 0>", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -182,4 +182,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo ...@@ -182,4 +182,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo
}), }),
]); ]);
//# sourceMappingURL=bf321_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_18e65124.js.map //# sourceMappingURL=0wxz_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_04b4ex6.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ad3e4_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_210ac8fd.js",
{"otherChunks":["output/bf321_tests_snapshot_basic-tree-shake_tree-shake-test-1_input_index_18e65124.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic-tree-shake/tree-shake-test-1/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_c0ebb290.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_0x5tpia.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript, async loader)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript, async loader)", ((__turbopack_context__) => {
__turbopack_context__.v((parentImport) => { __turbopack_context__.v((parentImport) => {
return Promise.all([ return Promise.all([
"output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js" "output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0xyt5ha._.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => { ].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)"); return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)");
}); });
......
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/0v.~_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_03rd2w8.js",
{"otherChunks":["output/0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_0x5tpia.js","output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0~ga2.4._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_index_da1eef81.js",
{"otherChunks":["output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_import_c0ebb290.js","output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0xyt5ha._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)", ((__turbopack_context__) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/import.js [test] (ecmascript)", ((__turbopack_context__) => {
"use strict"; "use strict";
...@@ -25,4 +25,4 @@ function foo(value) { ...@@ -25,4 +25,4 @@ function foo(value) {
}), }),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_c52390c2._.js.map //# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0xyt5ha._.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js", (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push(["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0~ga2.4._.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk/input/shared.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
// shared package // shared package
...@@ -29,4 +29,4 @@ function bar(value) { ...@@ -29,4 +29,4 @@ function bar(value) {
}), }),
]); ]);
//# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_df8dd76f._.js.map //# sourceMappingURL=turbopack_crates_turbopack-tests_tests_snapshot_basic_async_chunk_input_0~ga2.4._.js.map
\ No newline at end of file \ No newline at end of file
...@@ -25,4 +25,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo ...@@ -25,4 +25,4 @@ var __TURBOPACK__imported__module__$5b$project$5d2f$turbopack$2f$crates$2f$turbo
}), }),
]; ];
//# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_22f8582a._.js.map //# sourceMappingURL=0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_060ckam._.js.map
\ No newline at end of file \ No newline at end of file
...@@ -31,7 +31,7 @@ __turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapsh ...@@ -31,7 +31,7 @@ __turbopack_context__.A("[project]/turbopack/crates/turbopack-tests/tests/snapsh
__turbopack_context__.v((parentImport) => { __turbopack_context__.v((parentImport) => {
return Promise.all([ return Promise.all([
"output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_22f8582a._.js" "output/0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_060ckam._.js"
].map((chunk) => __turbopack_context__.l(chunk))).then(() => { ].map((chunk) => __turbopack_context__.l(chunk))).then(() => {
return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/import.js [test] (ecmascript)"); return parentImport("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/import.js [test] (ecmascript)");
}); });
...@@ -39,4 +39,4 @@ __turbopack_context__.v((parentImport) => { ...@@ -39,4 +39,4 @@ __turbopack_context__.v((parentImport) => {
}), }),
]; ];
//# sourceMappingURL=aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_4eca5628._.js.map //# sourceMappingURL=0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_0ofnzqb._.js.map
\ No newline at end of file \ No newline at end of file
var R=require("./[turbopack]_runtime.js")("output/index.entry.js") var R=require("./[turbopack]_runtime.js")("output/index.entry.js")
R.c("output/aaf3a_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_4eca5628._.js") R.c("output/0teu_crates_turbopack-tests_tests_snapshot_basic_async_chunk_build_input_0ofnzqb._.js")
R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/index.js [test] (ecmascript)") R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/index.js [test] (ecmascript)")
module.exports=R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/index.js [test] (ecmascript)").exports module.exports=R.m("[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/async_chunk_build/input/index.js [test] (ecmascript)").exports
\ No newline at end of file
(globalThis["myApp"] || (globalThis["myApp"] = [])).push([
"output/0fw._turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_0bkyka9.js",
{"otherChunks":["output/0ko._turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_09-oxbf.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunk_loading_global/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["myApp"] || (globalThis["myApp"] = [])).push(["output/780ce_turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_39dc8779.js", (globalThis["myApp"] || (globalThis["myApp"] = [])).push(["output/0ko._turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_09-oxbf.js",
"[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunk_loading_global/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => { "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunk_loading_global/input/index.js [test] (ecmascript)", ((__turbopack_context__, module, exports) => {
console.log('ChunkingLoadingGlobal test'); console.log('ChunkingLoadingGlobal test');
}), }),
]); ]);
//# sourceMappingURL=780ce_turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_39dc8779.js.map //# sourceMappingURL=0ko._turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_09-oxbf.js.map
\ No newline at end of file \ No newline at end of file
(globalThis["myApp"] || (globalThis["myApp"] = [])).push([
"output/5c1d0_turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_8d88737d.js",
{"otherChunks":["output/780ce_turbopack-tests_tests_snapshot_basic_chunk_loading_global_input_index_39dc8779.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunk_loading_global/input/index.js [test] (ecmascript)"]}
]);
// Dummy runtime
\ No newline at end of file
(globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([ (globalThis["TURBOPACK"] || (globalThis["TURBOPACK"] = [])).push([
"output/ba425_crates_turbopack-tests_tests_snapshot_basic_shebang_input_index_1ec6f047.js", "output/0v.~_crates_turbopack-tests_tests_snapshot_basic_chunked_input_index_0xga7l~.js",
{"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_shebang_input_07d95226._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/shebang/input/index.js [test] (ecmascript)"]} {"otherChunks":["output/turbopack_crates_turbopack-tests_tests_snapshot_basic_chunked_input_12omlz0._.js"],"runtimeModuleIds":["[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/chunked/input/index.js [test] (ecmascript)"]}
]); ]);
// Dummy runtime // Dummy runtime
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment