Skip to content

Commit 9552623

Browse files
authored
fix: add exports and handle async storage (#7921)
1 parent c7332be commit 9552623

File tree

14 files changed

+60
-7
lines changed

14 files changed

+60
-7
lines changed

packages/runtime/plugin-runtime/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"./internal": {
3434
"types": "./dist/types/internal.d.ts",
3535
"jsnext:source": "./src/internal.ts",
36-
"default": "./dist/esm/internal.js"
36+
"default": "./dist/esm/internal.mjs"
3737
},
3838
"./package.json": "./package.json",
3939
"./types": "./types/index.d.ts",
@@ -125,6 +125,7 @@
125125
"./loadable-bundler-plugin": {
126126
"types": "./dist/types/cli/ssr/loadable-bundler-plugin.d.ts",
127127
"jsnext:source": "./src/cli/ssr/loadable-bundler-plugin.ts",
128+
"node": "./dist/cjs/cli/ssr/loadable-bundler-plugin.js",
128129
"default": "./dist/cjs/cli/ssr/loadable-bundler-plugin.mjs"
129130
},
130131
"./rsc/server": {

packages/toolkit/runtime-utils/src/universal/async_storage.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,30 @@ export const getAsyncLocalStorage = async (): Promise<Storage | null> => {
1212
console.error('You should not get async storage in browser');
1313
return null;
1414
} else {
15-
try {
16-
if (!IS_WEB_FALLBACK) {
17-
const serverStorage = await import('./async_storage.server');
15+
if (!IS_WEB_FALLBACK) {
16+
try {
17+
// First try importing with explicit file extension for Node.js environment
18+
const serverStorage = await import('./async_storage.server.js');
1819
return serverStorage.getAsyncLocalStorage();
20+
} catch (extensionError) {
21+
try {
22+
// Fallback to extensionless import for bundler environments
23+
const serverStorage = await import('./async_storage.server');
24+
return serverStorage.getAsyncLocalStorage();
25+
} catch (fallbackError) {
26+
console.error('Failed to load server async storage', {
27+
extensionError:
28+
extensionError instanceof Error
29+
? extensionError.message
30+
: extensionError,
31+
fallbackError:
32+
fallbackError instanceof Error
33+
? fallbackError.message
34+
: fallbackError,
35+
});
36+
return null;
37+
}
1938
}
20-
} catch (err) {
21-
console.error('Failed to load server async storage', err);
22-
return null;
2339
}
2440
return null;
2541
}

tests/integration/custom-file-system-entry/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ export default defineConfig({
1111
router: true,
1212
},
1313
plugins: [appTools()],
14+
performance: {
15+
buildCache: false,
16+
},
1417
});

tests/integration/deploy-csr/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ export default defineConfig({
55
router: true,
66
},
77
plugins: [AppToolsPlugin()],
8+
performance: {
9+
buildCache: false,
10+
},
811
});

tests/integration/deploy-server/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ export default defineConfig({
77
router: true,
88
},
99
plugins: [AppToolsPlugin(), bff()],
10+
performance: {
11+
buildCache: false,
12+
},
1013
});

tests/integration/i18n/app-csr/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ export default defineConfig({
2323
},
2424
}),
2525
],
26+
performance: {
27+
buildCache: false,
28+
},
2629
});

tests/integration/i18n/app-ssr/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ export default defineConfig({
2020
},
2121
}),
2222
],
23+
performance: {
24+
buildCache: false,
25+
},
2326
});

tests/integration/i18n/routes-csr/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ export default defineConfig({
1414
enabled: true,
1515
sdk: true,
1616
},
17+
performance: {
18+
buildCache: false,
19+
},
1720
}),
1821
],
1922
});

tests/integration/i18n/routes-ssr/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export default defineConfig({
1313
languages: ['zh', 'en'],
1414
fallbackLanguage: 'en',
1515
},
16+
performance: {
17+
buildCache: false,
18+
},
1619
}),
1720
],
1821
});

tests/integration/routes-match/modern.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ export default defineConfig({
1414
c: '/detail/12',
1515
},
1616
},
17+
performance: {
18+
buildCache: false,
19+
},
1720
});

0 commit comments

Comments
 (0)