Skip to content

Commit

Permalink
Merge branch 'canary' into shu/4d3c
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding authored Oct 23, 2023
2 parents 907b413 + c2ba7e6 commit 28e8aa3
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 230 deletions.
33 changes: 15 additions & 18 deletions packages/next/src/build/create-compiler-aliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
} from './webpack-config'
import { WEBPACK_LAYERS } from '../lib/constants'

interface CompilerAliases {
[alias: string]: string | string[]
}

export function createWebpackAliases({
dev,
pageExtensions,
Expand Down Expand Up @@ -47,16 +51,9 @@ export function createWebpackAliases({
isNodeServer: boolean
clientResolveRewrites: string
hasRewrites: boolean
}):
| {
alias: string | false | string[]
name: string
onlyModule?: boolean | undefined
}[]
| { [index: string]: string | false | string[] }
| undefined {
const customAppAliases: { [key: string]: string[] } = {}
const customDocumentAliases: { [key: string]: string[] } = {}
}): CompilerAliases {
const customAppAliases: CompilerAliases = {}
const customDocumentAliases: CompilerAliases = {}

if (dev) {
const nextDistPath = 'next/dist/' + (isEdgeServer ? 'esm/' : '')
Expand Down Expand Up @@ -211,9 +208,9 @@ export function createWebpackAliases({
}
}

export function createServerOnlyClientOnlyAliases(isServer: boolean): {
[aliasPath: string]: string
} {
export function createServerOnlyClientOnlyAliases(
isServer: boolean
): CompilerAliases {
return isServer
? {
'server-only$': 'next/dist/compiled/server-only/empty',
Expand Down Expand Up @@ -244,7 +241,7 @@ export function createRSCAliases(
isEdgeServer: boolean
reactProductionProfiling: boolean
}
) {
): CompilerAliases {
let alias: Record<string, string> = {
react$: `next/dist/compiled/react${bundledReactChannel}`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}`,
Expand Down Expand Up @@ -309,7 +306,7 @@ export function createRSCAliases(

// Insert aliases for Next.js stubs of fetch, object-assign, and url
// Keep in sync with insert_optimized_module_aliases in import_map.rs
export function getOptimizedModuleAliases(): { [pkg: string]: string } {
export function getOptimizedModuleAliases(): CompilerAliases {
return {
unfetch: require.resolve('next/dist/build/polyfills/fetch/index.js'),
'isomorphic-unfetch': require.resolve(
Expand Down Expand Up @@ -338,7 +335,7 @@ export function getOptimizedModuleAliases(): { [pkg: string]: string } {
}

// Alias these modules to be resolved with "module" if possible.
function getBarrelOptimizationAliases(packages: string[]) {
function getBarrelOptimizationAliases(packages: string[]): CompilerAliases {
const aliases: { [pkg: string]: string } = {}
const mainFields = ['module', 'main']

Expand All @@ -361,12 +358,12 @@ function getBarrelOptimizationAliases(packages: string[]) {

return aliases
}
function getReactProfilingInProduction() {
function getReactProfilingInProduction(): CompilerAliases {
return {
'react-dom$': 'react-dom/profiling',
}
}
export function createServerComponentsNoopAliases() {
export function createServerComponentsNoopAliases(): CompilerAliases {
return {
[require.resolve('next/head')]: require.resolve(
'next/dist/client/components/noop-head'
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/client/dev/dev-build-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default function initializeBuildWatcher(
break
case HMR_ACTIONS_SENT_TO_BROWSER.BUILT:
case HMR_ACTIONS_SENT_TO_BROWSER.SYNC:
case HMR_ACTIONS_SENT_TO_BROWSER.FINISH_BUILDING:
hide()
break
}
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/server/dev/hot-reloader-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const enum HMR_ACTIONS_SENT_TO_BROWSER {
SYNC = 'sync',
BUILT = 'built',
BUILDING = 'building',
FINISH_BUILDING = 'finishBuilding',
DEV_PAGES_MANIFEST_UPDATE = 'devPagesManifestUpdate',
TURBOPACK_MESSAGE = 'turbopack-message',
SERVER_ERROR = 'serverError',
Expand All @@ -37,6 +38,10 @@ interface BuildingAction {
action: HMR_ACTIONS_SENT_TO_BROWSER.BUILDING
}

interface FinishBuildingAction {
action: HMR_ACTIONS_SENT_TO_BROWSER.FINISH_BUILDING
}

interface SyncAction {
action: HMR_ACTIONS_SENT_TO_BROWSER.SYNC
hash: string
Expand Down Expand Up @@ -95,6 +100,7 @@ export type HMR_ACTION_TYPES =
| TurbopackMessageAction
| TurbopackConnectedAction
| BuildingAction
| FinishBuildingAction
| SyncAction
| BuiltAction
| AddedPageAction
Expand Down
Loading

0 comments on commit 28e8aa3

Please sign in to comment.