Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importAssertions #316

Open
robertocerdasilva opened this issue Jun 24, 2022 · 8 comments
Open

Error importAssertions #316

robertocerdasilva opened this issue Jun 24, 2022 · 8 comments

Comments

@robertocerdasilva
Copy link

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
@robertocerdasilva
Copy link
Author

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

@aresn
Copy link

aresn commented Jul 4, 2022

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@c503ce6

@robertocerdasilva
Copy link
Author

@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

@robertocerdasilva
Copy link
Author

Hi @jayair good day. Is it possible to add a solution for this problem?

@jayair
Copy link
Member

jayair commented Aug 22, 2022

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.

@robertocerdasilva
Copy link
Author

Thank you @jayair, I will be pending. I'm a bit stuck with this solution.

@robertocerdasilva
Copy link
Author

@jayair Hello! is it possible to know if there is an update planned for this problem?

thank you

@robertocerdasilva
Copy link
Author

After waiting so long for this problem, I have implemented @aresn solution.

Anyway thank you very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants