Unverified Commit dfe2825b authored by David Alexandru Ilie's avatar David Alexandru Ilie Committed by GitHub

Fix webpack client references for hash filenames

parent 0b7e96f4
...@@ -319,7 +319,7 @@ export class ClientReferenceManifestPlugin { ...@@ -319,7 +319,7 @@ export class ClientReferenceManifestPlugin {
let resource = let resource =
mod.type === 'css/mini-extract' mod.type === 'css/mini-extract'
? mod.identifier().slice(mod.identifier().lastIndexOf('!') + 1) ? mod.identifier().slice(mod.identifier().lastIndexOf('!') + 1)
: mod.resource : mod.resourceResolveData?.path || mod.resource
if (!resource) { if (!resource) {
return return
......
'use client'
import { useState } from 'react'
export default function Counter() {
const [count, setCount] = useState(0)
return (
<button id="counter" onClick={() => setCount((value) => value + 1)}>
count: {count}
</button>
)
}
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
import Counter from './counter#client'
export default function Page() {
return <Counter />
}
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig
import { nextTestSetup } from 'e2e-utils'
describe('webpack-hash-client-filename', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('renders and hydrates a Client Component whose filename contains #', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#counter').text()).toBe('count: 0')
await browser.elementByCss('#counter').click()
expect(await browser.elementByCss('#counter').text()).toBe('count: 1')
})
})
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