Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(turbopack): add no-op resolveAbsolutePath to browser runtime #8549

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module {
w: loadWebAssembly.bind(null, sourceInfo),
u: loadWebAssemblyModule.bind(null, sourceInfo),
g: globalThis,
P: resolveAbsolutePath,
U: relativeURL,
k: refresh,
R: createResolvePathFromModule(r),
Expand All @@ -386,6 +387,14 @@ function instantiateModule(id: ModuleId, source: SourceInfo): Module {
return module;
}

/**
* no-op for browser
* @param modulePath
*/
function resolveAbsolutePath(modulePath?: string): string {
return `/ROOT/${modulePath ?? ""}`;
}

/**
* NOTE(alexkirsz) Webpack has a "module execution" interception hook that
* Next.js' React Refresh runtime hooks into to add module context to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ function stringifySourceInfo(source: SourceInfo): string {

type ExternalRequire = (id: ModuleId) => Exports | EsmNamespaceObject;
type ExternalImport = (id: ModuleId) => Promise<Exports | EsmNamespaceObject>;
type ResolveAbsolutePath = (modulePath?: string) => string;

interface TurbopackNodeBuildContext extends TurbopackBaseContext {
P: ResolveAbsolutePath;
R: ResolvePathFromModule;
x: ExternalRequire;
y: ExternalImport;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type AsyncModule = (
hasAwait: boolean
) => void;

type ResolveAbsolutePath = (modulePath?: string) => string;

interface TurbopackBaseContext {
a: AsyncModule;
e: Module["exports"];
Expand All @@ -71,6 +73,7 @@ interface TurbopackBaseContext {
w: LoadWebAssembly;
u: LoadWebAssemblyModule;
g: typeof globalThis;
P: ResolveAbsolutePath;
U: RelativeURL;
__dirname: string;
}

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading