Error importAssertions
robertocerdasilva opened this issue · 8 comments
Hello good day.
I have an API that uses json files on some endpoints.
I am using NODE 16 and when starting the application on local server, the console requires me to use assert { type: 'json' }
when importing json files:
import FILE from 'file.json' assert { type: 'json' }
When executing serverless deploy
the console shows the following error:
Support for the experimental syntax 'importAssertions' isn't currently enabled
Helpme plis :( thanks
serverless.yml
plugins:
- serverless-bundle
custom:
bundle:
sourcemaps: false
linting: false
ignorePackages:
- pg-native
Hello @jayair , Is there any solution for this?
both alternatives of this article: https://www.stefanjudis.com/snippets/how-to-import-json-files-in-es-modules-node-js/
do not work in production (AWS Lambda)
Thanks
The problem is the depreciated "babel-eslint" missing "importAssertions" in its plugins list. I replaced "babel-eslint" with "@babel/eslint-parser" and modified some of the settings in order to support import assertions. I made a quick fix on my side, but don't have time to do a proper pull request for this. Take a look at this commit:
@aresn Hello, thanks for answering.
How can I apply this solution locally in detail and not wait for an update of this dependency?
This situation has me somewhat complicated when starting my APIs locally and then having to deploy by modifying the lines where JSON files are imported.
Thanks a lot
Hi @jayair good day. Is it possible to add a solution for this problem?
I haven't had a chance to look at this. If there's a PR that I can review, I'll take a look and merge it.
Thank you @jayair, I will be pending. I'm a bit stuck with this solution.
@jayair Hello! is it possible to know if there is an update planned for this problem?
thank you
After waiting so long for this problem, I have implemented @aresn solution.
Anyway thank you very much :)