Skip to content

Commit

Permalink
detect internal as client, revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Sep 16, 2022
1 parent 3300831 commit c3b5750
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Expand Up @@ -1483,7 +1483,7 @@ export default async function getBaseWebpackConfig(
/next[\\/]dist[\\/]client[\\/]/,
// To let next/* api entry files passing through flight loader instead
// of the internal implementation files
/next[\\/](link|image|future[\\/]image)/,
// /next[\\/](link|image|future[\\/]image)/,
],
issuerLayer: WEBPACK_LAYERS.server,
use: {
Expand Down
8 changes: 4 additions & 4 deletions packages/next/build/webpack/loaders/utils.ts
Expand Up @@ -7,14 +7,14 @@ const imageRegex = new RegExp(`\\.(${imageExtensions.join('|')})$`)
const NEXT_API_CLIENT_RSC_REGEX = new RegExp(
`next[\\\\/]dist[\\\\/]client[\\\\/](${nextClientComponents.join('|')})\\.js$`
)
const NEXT_BUILT_IN_CLIENT_RSC_REGEX = new RegExp(
`next[\\\\/](${nextClientComponents.join('|')})\\.js$`
)
// const NEXT_BUILT_IN_CLIENT_RSC_REGEX = new RegExp(
// `next[\\\\/](${nextClientComponents.join('|')})\\.js$`
// )

// Cover resource paths like `next/*` and `next/dist/client/*`
export function isNextBuiltInClientComponent(resource: string) {
return (
NEXT_BUILT_IN_CLIENT_RSC_REGEX.test(resource) ||
// NEXT_BUILT_IN_CLIENT_RSC_REGEX.test(resource) ||
NEXT_API_CLIENT_RSC_REGEX.test(resource)
)
}
Expand Down
Expand Up @@ -247,7 +247,9 @@ export class FlightClientEntryPlugin {

// Check if request is for css file.
if ((!inClientComponentBoundary && isClientComponent) || isCSS) {
clientComponentImports.push(modRequest)
clientComponentImports.push(
isCSS ? modRequest : require.resolve(modRequest)
)
return
}

Expand Down
4 changes: 2 additions & 2 deletions packages/next/compiled/@edge-runtime/primitives/console.js
Expand Up @@ -567,8 +567,8 @@ var time = console.time.bind(console);
var timeEnd = console.timeEnd.bind(console);
var timeLog = console.timeLog.bind(console);
var trace = console.trace.bind(console);
var error = bareError; // /* @__PURE__ */ __name((...args) => bareError(format(...args)), "error");
var log = bareLog; // /* @__PURE__ */ __name((...args) => bareLog(format(...args)), "log");
var error = /* @__PURE__ */ __name((...args) => bareError(format(...args)), "error");
var log = /* @__PURE__ */ __name((...args) => bareLog(format(...args)), "log");
var konsole = {
assert: (assertion, ...args) => assert(assertion, format(...args)),
count: console.count.bind(console),
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/app-dir/app/app/dashboard/page.js
Expand Up @@ -12,6 +12,6 @@ export default function DashboardPage(props) {
)
}

// export const config = {
// runtime: 'experimental-edge',
// }
export const config = {
runtime: 'experimental-edge',
}
10 changes: 7 additions & 3 deletions test/e2e/app-dir/app/app/old-router/Router.js
@@ -1,15 +1,19 @@
import { useRouter, withRouter } from 'next/router'
import IsNull from './IsNull'
import IsNull from './is-null'
import ServerRouter from './server-router'
import ClientRouter from './client-router'

function ServerRouter({ router: withRouter }) {
function SharedRouter({ router: withRouter }) {
const router = useRouter()

return (
<>
<IsNull value={withRouter} />
<IsNull value={router} />
<ServerRouter />
<ClientRouter />
</>
)
}

export default withRouter(ServerRouter)
export default withRouter(SharedRouter)
@@ -1,7 +1,7 @@
'client'

import { useRouter, withRouter } from 'next/router'
import IsNull from './IsNull'
import IsNull from './is-null'

function ClientRouter({ router: withRouter }) {
const router = useRouter()
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/app-dir/app/app/old-router/server-router.js
@@ -0,0 +1,15 @@
import { useRouter, withRouter } from 'next/router'
import IsNull from './is-null'

function ServerRouter({ router: withRouter }) {
const router = useRouter()

return (
<>
<IsNull value={withRouter} />
<IsNull value={router} />
</>
)
}

export default withRouter(ServerRouter)
6 changes: 3 additions & 3 deletions test/e2e/app-dir/app/app/slow-page-with-loading/page.js
Expand Up @@ -11,6 +11,6 @@ export default function SlowPage(props) {
return <h1 id="slow-page-message">{props.message}</h1>
}

// export const config = {
// runtime: 'experimental-edge',
// }
export const config = {
runtime: 'experimental-edge',
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/index.test.ts
Expand Up @@ -772,7 +772,7 @@ describe('app dir', () => {
expect(notNull.length).toBe(0)

const wasNull = await browser.elementsByCss('.was-null')
expect(wasNull.length).toBe(2)
expect(wasNull.length).toBe(6)
} finally {
await browser.close()
}
Expand Down

0 comments on commit c3b5750

Please sign in to comment.