Skip to content

Commit 971257a

Browse files
committed
Fix turbopack config to use browser/default structure for client/server detection
1 parent ba1b14e commit 971257a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

server-actions-for-next-pages/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# server-actions-for-next-pages
22

3+
## 1.5.12
4+
5+
### Patch Changes
6+
7+
- Fix turbopack configuration to use proper browser/default structure for client/server detection
8+
- Cannot detect build context inside Turbopack loaders (this.target is undefined), must use config-level conditions
9+
- Restore browser/default loaders with correct isServer: false/true options
10+
311
## 1.5.11
412

513
### Patch Changes

server-actions-for-next-pages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "server-actions-for-next-pages",
3-
"version": "1.5.11",
3+
"version": "1.5.12",
44
"description": "Use Next.js server actions in your pages directory",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

server-actions-for-next-pages/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,30 +107,31 @@ function applyTurbopackOptions(nextConfig: NextConfig): void {
107107
const rules = (nextConfig as any).turbopack.rules;
108108

109109
const pagesDir = findPagesDir(process.cwd());
110-
111110
const basePath = (nextConfig.basePath as string) || '/';
111+
const loaderPath = require.resolve('../dist/turbopackLoader');
112112

113113
const glob = '{./src/pages,./pages/}/**/*.{ts,tsx,js,jsx}';
114-
rules[glob] ??= {};
115114
const options: RpcPluginOptions = {
116115
isServer: false,
117116
pagesDir,
118117
isAppDir: false,
119118
basePath,
120119
};
120+
121+
rules[glob] ??= {};
121122
const globbed: any = rules[glob];
122123
globbed.browser ??= {};
123124
globbed.browser.as = '*.tsx';
124125
globbed.browser.loaders ??= [];
125126
globbed.browser.loaders.push({
126-
loader: require.resolve('../dist/turbopackLoader'),
127+
loader: loaderPath,
127128
options: { ...options, isServer: false },
128129
});
129130
globbed.default ??= {};
130131
globbed.default.as = '*.tsx';
131132
globbed.default.loaders ??= [];
132133
globbed.default.loaders.push({
133-
loader: require.resolve('../dist/turbopackLoader'),
134+
loader: loaderPath,
134135
options: { ...options, isServer: true },
135136
});
136137
}

0 commit comments

Comments
 (0)