Skip to content

Commit

Permalink
Use this.rootContext instead of webpack internals
Browse files Browse the repository at this point in the history
Ensures the root context is read from the public API that webpack exposes. This is the first step for Turbopack support as Turbopack includes `this.rootContext` as well
  • Loading branch information
timneutkens committed Mar 15, 2024
1 parent 744242f commit 20309bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions packages/blitz-rpc/src/server/loader/client/loader-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {getResolverConfig} from "../../parsers/parse-rpc-config"
// Subset of `import type { LoaderDefinitionFunction } from 'webpack'`

export async function loader(this: Loader, input: string): Promise<string> {
const compiler = this._compiler!
const id = this.resource
const root = this._compiler!.context
const root = this.rootContext

const isSSR = compiler.name === "server"
const isSSR = this._compiler.name === "server"
if (!isSSR) {
return await transformBlitzRpcResolverClient(
input,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {posix} from "path"
// Subset of `import type { LoaderDefinitionFunction } from 'webpack'`

export async function loader(this: Loader, input: string): Promise<string> {
const compiler = this._compiler!
const id = this.resource
const root = this._compiler!.context
const root = this.rootContext

const isSSR = compiler.name === "server"
const isSSR = this._compiler.name === "server"
if (isSSR) {
return await transformBlitzRpcResolverServer(
input,
Expand Down
5 changes: 2 additions & 3 deletions packages/blitz-rpc/src/server/loader/server/loader-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import {
// Subset of `import type { LoaderDefinitionFunction } from 'webpack'`

export async function loader(this: Loader, input: string): Promise<string> {
const compiler = this._compiler!
const id = this.resource
const root = this._compiler!.context
const root = this.rootContext
const rpcFolders = this.query.includeRPCFolders ? this.query.includeRPCFolders : []

const isSSR = compiler.name === "server"
const isSSR = this._compiler.name === "server"
if (isSSR) {
this.cacheable(false)

Expand Down
2 changes: 1 addition & 1 deletion packages/blitz-rpc/src/server/loader/utils/loader-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export interface LoaderOptions {
export interface Loader {
_compiler?: {
name: string
context: string
}
rootContext: string
resource: string
cacheable: (enabled: boolean) => void
query: LoaderOptions
Expand Down

0 comments on commit 20309bc

Please sign in to comment.