Initial setup, sourcemap error
Opened this issue · 2 comments
What am I missing? I have no tests, just trying to bundle a "Hello World".
$ serverless --version
Running "serverless" from node_modules
Framework Core: 3.12.0 (local) 3.12.0 (global)
Plugin: 6.2.1
SDK: 4.3.2
$ serverless deploy
Running "serverless" from node_modules
Deploying aws-node-project to stage dev (us-east-1)
Bundling with Webpack...
ERROR in ../../../handler.js 1:0-37
Module not found: Error: Can't resolve 'source-map-support/register' in '/Users/.../Development/aws-node-project'
Did you mean 'register.js'?
BREAKING CHANGE: The request 'source-map-support/register' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
webpack compiled with 1 error
✖ Stack aws-node-project-dev failed to deploy (0s)
Environment: darwin, node 17.7.1, framework 3.12.0 (local) 3.12.0v (global), plugin 6.2.1, SDK 4.3.2
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
Webpack compilation error, see stats above
My hanlder.js
module.exports.hello = async (event) => {
return {
statusCode: 200,
body: JSON.stringify(
{
message: 'Go Serverless v3.0! Your function executed successfully!',
input: event,
},
null,
2
),
};
};
My serverless.yml
org: kfunk
app: aws-node-project
service: aws-node-project
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs14.x
functions:
hello:
handler: handler.hello
plugins:
- serverless-bundle
My package.json
{
"type": "module",
"devDependencies": {
"serverless-bundle": "^5.3.0"
},
"scripts": {
"test": "serverless-bundle test"
}
}
This issue arose when I added type: module
to our package.json in conjunction with an upgrade to node 18.
The only resolution I could find was forking serverless-bundle to add fullySpecified: false
for the .js$
loader in the webpack config.
Follow-up: After more investigation, the file that was triggering the error was an inadvertent ".js" in a TypeScript project and webpack was adding an usused source-map-support/register reference for reasons that are beyond me. Moving it to .ts resolved the issue (without needing the fullySpecified:false
) change.
For the issue above, since it's a commonjs module handler.js file in an EJS module project, it's possible the solution is simply to rename the file to handler.cjs, or convert it to an EJS file (i.e. export function hello...
)
Having same problem when using node18. Any updates on how to solve this issue?