When a lambda is authored with this structure:
acme.js
acme/lib.js
and the acme.js
imports from acme/lib.js
it breaks:
{
"errorType": "Error",
"errorMessage": "require() of ES Module /var/task/acme.js from /var/runtime/index.mjs not supported.\nInstead change the require of acme.js in /var/runtime/index.mjs to a dynamic import() which is available in all CommonJS modules.",
"trace": [
"Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/acme.js from /var/runtime/index.mjs not supported.",
"Instead change the require of acme.js in /var/runtime/index.mjs to a dynamic import() which is available in all CommonJS modules.",
" at _tryRequireFile (file:///var/runtime/index.mjs:1002:37)",
" at _tryRequire (file:///var/runtime/index.mjs:1046:29)",
" at _loadUserApp (file:///var/runtime/index.mjs:1081:22)",
" at UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:27)",
" at start (file:///var/runtime/index.mjs:1282:42)"
]
}
import { hello } from './acme/lib.js'
export const handler = async (event) => {
// TODO implement
const response = {
statusCode: 200,
body: JSON.stringify(hello()),
};
return response;
};
export const hello = () => 'Hello from lib!'
{"type":"module"}