Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG] Using esbuild to generate an ESM .mjs bundle #295

Open
Assignees
copilot-swe-agent
@Mystogab

Description

@Mystogab

when trying to run this library as an ESM, for instance using esbuild to generate a.mjs file. It fails tu run on AWS lambda with this error:

2025-11-10T21:22:36.250ZundefinedERRORUncaughtException{"errorType":"Error","errorMessage":"Dynamic require of \"querystring\" is not supported","stack":["Error: Dynamic require of \"querystring\" is not supported","    at file:///var/task/api.mjs:1:388","    at <anonymous> (/var/node_modules/lambda-api/lib/request.js:8:12)","    at file:///var/task/api.mjs:1:499","    at <anonymous> (/var/node_modules/lambda-api/index.js:8:17)","    at file:///var/task/api.mjs:1:499","    at <anonymous> (/var/apps/api/shells/input/api-gateway-shell.ts:3:23)","    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)","    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:647:26)","    at async _tryAwaitImport (file:///var/runtime/index.mjs:1098:16)","    at async _tryRequire (file:///var/runtime/index.mjs:1156:86)"]}

By adding this

banner:{js:"import { createRequire } from 'module'; const require = createRequire(import.meta.url);",},

to your esbuild build configuration, or manually adding that line at the top of the output bundled file it works on AWS Lambda using ESM and an MJS entrypoint file.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp