Skip to content

Commit

Permalink
fix(planner/node.js): Build middleware failed when no node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
yuaanlin committed Oct 14, 2023
1 parent bfc2fd0 commit bf396d2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions internal/nodejs/nextjs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ func TransformServerless(image, workdir string) error {

fmt.Println("=> Copying build output from image")

err := utils.CopyFromImage(image, "/src/.next", tmpDir)
err := cp.Copy(workdir, tmpDir)
if err != nil {
return err
}

err = utils.CopyFromImage(image, "/src/.next", tmpDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -282,7 +287,7 @@ func TransformServerless(image, workdir string) error {

fmt.Println("=> Building edge middleware")

err = buildMiddleware(workdir)
err = buildMiddleware(tmpDir)
if err != nil {
return fmt.Errorf("build middleware: %w", err)
}
Expand Down Expand Up @@ -326,10 +331,11 @@ func buildMiddleware(workdir string) error {
}

res := esbuild.Build(esbuild.BuildOptions{
EntryPoints: []string{path.Join(workdir, middlewareFile)},
Bundle: true,
Platform: esbuild.PlatformNode,
Loader: map[string]esbuild.Loader{".wasm": esbuild.LoaderBinary},
EntryPoints: []string{path.Join(workdir, middlewareFile)},
Bundle: true,
Platform: esbuild.PlatformNode,
Loader: map[string]esbuild.Loader{".wasm": esbuild.LoaderBinary},
AbsWorkingDir: workdir,
})
if res.Errors != nil && len(res.Errors) > 0 {
println(res.Errors[0].Text)
Expand Down

0 comments on commit bf396d2

Please sign in to comment.