twilio-labs / serverless-toolkit

CLI tool to develop, debug and deploy Twilio Functions

Home Page:https://www.twilio.com/docs/labs/serverless-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updates for ESM only modules

philnash opened this issue · comments

Modules like ora@6 and wrap-ansi@8 (and upcoming chalk@5 and boxen@6) have updated to publish pure ESM packages.

The things to do to update this are listed in this gist, but we need to consider how making these upgrades could affect our build as well as dependent modules that we don't control.

Good point. I think we also need to consider whether this affects the local dev experience in some way. We heavily rely on require even though most of our code uses import statements already.

In TypeScript we consume modules using import however with our current settings that is transpiled to a require which fails to load pure ESM packages.

Update to this ticket: at least the serverless-api package is now configured in a way that it does not compile away inline await import() but it does still convert everything else to require. This should solve that problem if we change the settings in the other packages as well

I'm having a problem which may be generated by the wrap-ansi package

Installing plugin @twilio-labs/plugin-serverless... ⣟ [2/4] Fetching packages...
Installing plugin @twilio-labs/plugin-serverless... ⣯ [2/4] Fetching packages...
error wrap-ansi@9.0.0: The engine "node" is incompatible with this module. Expected version ">=18". Got "16.20.2"
error Found incompatible module.
Installing plugin @twilio-labs/plugin-serverless... ⣷ info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Installing plugin @twilio-labs/plugin-serverless... failed
    Error: yarn add @twilio-labs/plugin-serverless@v2 --non-interactive 
    --mutex=file:/home/runner/.twilio-cli/yarn.lock 
    --preferred-cache-folder=/home/runner/.twilio-cli/yarn --check-files 
    exited with code 1
Error: Process completed with exit code 1.

What can I do to solve this problem?