Skip to content

Commit

Permalink
Merge branch 'canary' into add/redirect-new-router
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Sep 20, 2022
2 parents 1da73c0 + 0fb3284 commit 47e1d6d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 2 deletions.
Expand Up @@ -41,9 +41,16 @@ export default async function transformSource(this: any): Promise<string> {
`

const buildInfo = getModuleBuildInfo(this._module)
const resolve = this.getResolve()

// Resolve to absolute resource url for flight manifest to collect and use to determine client components
const resolvedRequests = await Promise.all(
requests.map(async (r) => await resolve(this.rootContext, r))
)

buildInfo.rsc = {
type: RSC_MODULE_TYPES.client,
requests,
requests: resolvedRequests,
}

return code
Expand Down
Expand Up @@ -112,7 +112,7 @@ export class FlightManifestPlugin {
if (mod.resource === '' && mod.buildInfo.rsc) {
const { requests = [] } = mod.buildInfo.rsc
requests.forEach((r: string) => {
clientRequestsSet.add(require.resolve(r))
clientRequestsSet.add(r)
})
}
}
Expand Down
37 changes: 37 additions & 0 deletions test/e2e/app-dir/app-alias.test.ts
@@ -0,0 +1,37 @@
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'
import path from 'path'

describe('app-dir alias handling', () => {
if ((global as any).isNextDeploy) {
it('should skip next deploy for now', () => {})
return
}

if (process.env.NEXT_TEST_REACT_VERSION === '^17') {
it('should skip for react v17', () => {})
return
}

let next: NextInstance

beforeAll(async () => {
next = await createNext({
files: new FileRef(path.join(__dirname, 'app-alias')),
dependencies: {
react: 'experimental',
'react-dom': 'experimental',
typescript: 'latest',
'@types/react': 'latest',
'@types/node': 'latest',
},
})
})
afterAll(() => next.destroy())

it('should handle typescript paths alias correctly', async () => {
const html = await renderViaHTTP(next.url, '/button')
expect(html).toContain('<button>click</button>')
})
})
5 changes: 5 additions & 0 deletions test/e2e/app-dir/app-alias/app/button/page.tsx
@@ -0,0 +1,5 @@
import Button from '@/ui/button'

export default function page() {
return <Button>click</Button>
}
8 changes: 8 additions & 0 deletions test/e2e/app-dir/app-alias/next.config.js
@@ -0,0 +1,8 @@
module.exports = {
experimental: {
appDir: true,
serverComponents: true,
legacyBrowsers: false,
browsersListForSwc: true,
},
}
24 changes: 24 additions & 0 deletions test/e2e/app-dir/app-alias/tsconfig.json
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"baseUrl": ".",
"paths": {
"@/ui/*": ["ui/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
3 changes: 3 additions & 0 deletions test/e2e/app-dir/app-alias/ui/button.tsx
@@ -0,0 +1,3 @@
export default function Button(props: any) {
return <button {...props} />
}

0 comments on commit 47e1d6d

Please sign in to comment.