Skip to content

Commit

Permalink
fix(server-core): support cjs async server loader entry
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jul 25, 2024
1 parent 2515b00 commit 4ad4f75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilly-rules-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/server-core': patch
---

fix(server-core): support cjs async server loader entry
fix(server-core): 支持 cjs 类型的异步 server loader entry
3 changes: 3 additions & 0 deletions packages/server/core/src/adapters/node/plugins/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export function injectTemplates(
const dynamicImport = (filePath: string) => {
try {
const module = require(filePath);
if (module.default) {
return Promise.resolve(module.default);
}
return Promise.resolve(module);
} catch (e) {
return Promise.reject(e);
Expand Down

0 comments on commit 4ad4f75

Please sign in to comment.