Skip to content

Commit bbf9b30

Browse files
fix(open-next): use dynamic import handler for monorepo entrypoint (#341)
* fix(open-next): use dynamic import handler for monorepo entrypoint * changeset --------- Co-authored-by: Dorseuil Nicolas <nicodorseuil@yahoo.fr>
1 parent 83b0838 commit bbf9b30

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/moody-camels-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
use dynamic import handler for monorepo entrypoint

packages/open-next/src/build.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,12 @@ function addMonorepoEntrypoint(outputPath: string, packagePath: string) {
748748
const packagePosixPath = packagePath.split(path.sep).join(path.posix.sep);
749749
fs.writeFileSync(
750750
path.join(outputPath, "index.mjs"),
751-
[`export * from "./${packagePosixPath}/index.mjs";`].join(""),
751+
[
752+
`export const handler = async (event, context) => {`,
753+
` const fn = await import("./${packagePosixPath}/index.mjs");`,
754+
` return fn.handler(event, context);`,
755+
`};`,
756+
].join(""),
752757
);
753758
}
754759

0 commit comments

Comments
 (0)