serverless-s3-local icon indicating copy to clipboard operation
serverless-s3-local copied to clipboard

S3-local doesn't seem to work well with nodeJS 8.10

Open DaphneKerstens opened this issue 6 years ago • 7 comments

When I try to use this plugin combined with a project in NodeJS 8.10, I get all kinds of errors like Unexpected token import When I change all 'imports' into requires, the next error appeares: Unexpected token export And so on.. As soon as I remove this plugin, all errors are gone.

Anyone able to help me with this?

DaphneKerstens avatar May 11 '18 08:05 DaphneKerstens

Hi @DaphneKerstens I think that "import" doesn't work correctly in node environment. Do you use babel or any transpiler ? If you use them, severless-s3-local doesn't work correctly. Because serverless-s3-local tries to load original javascript file.

ar90n avatar May 14 '18 13:05 ar90n

ran into the same issue today. im running node env 8.10. im using serverless-webpack with babel. and serverless-s3-local seems not to load the transpiled files by webpack, instead it uses the original files.

is there any solution?

JuHwon avatar May 30 '18 16:05 JuHwon

I just found a quick fix: when I'm adding my webpack output location like: --location ./.webpack/service/ to my start command, it will take the transpiled files.

Though this should not be mandatory I guess? How do other plugins work with that?

JuHwon avatar May 30 '18 17:05 JuHwon

@JuHwon Thanks for your great information. I think that the way you mentioned is good solution for this problem. And it inspired me. Eventually, I found a solution for this issue. This solution doesn't require extra command line options to find transpiled files. Please see the support-webpack branch. Unfortunately, this solution is not achieved with modification of itself. We have to modify serverless-webpack in itself. About this modification, please see support-serverless-s3-local brainch in my fork repository of serverless-webpack.

ar90n avatar Jun 08 '18 17:06 ar90n

@JuHwon @DaphneKerstens In fact, the above branch version works correctly. So I released them as v0.3.7. Please install them via npm.

ar90n avatar Jun 14 '18 13:06 ar90n

Still doesnt work with your updates @ar90n

devotox avatar Aug 23 '18 12:08 devotox

Hi @devotox Thank for your comment and PR. I merged the PR. Please check it.

ar90n avatar Aug 23 '18 19:08 ar90n