Stun3R / strapi-sdk-js

📦 Javascript SDK for your Strapi API
https://strapi-sdk-js.netlify.app
MIT License
143 stars 28 forks source link

Change esbuild target to es2019 #179

Closed beornf closed 1 year ago

beornf commented 1 year ago

Feature request

Summary

The current target for esbuild is esnext as seen below. https://github.com/Stun3R/strapi-sdk-js/blob/1ea69139c94ca3f804fbca45f5d59306e07727c1/rollup.config.mjs#L26-L28

This uses modern features such as class properties and optional chaining operators. However these features cause webpack compile errors when importing in Nuxt 2.

Why is it needed?

To fix the following webpack compile errors:

ERROR in ./node_modules/strapi-sdk-js/dist/index.mjs

Module parse failed: Unexpected token (22:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| };
| class Strapi {
>   axios;
|   options;
|   user = null;

Suggested solution(s)

Change the esnext target to es2019 in rollup.config.mjs and tsconfig.json. New builds will be compatible with Nuxt 2 and other frameworks.

Stun3R commented 1 year ago

Thanks for the report and sorry for the inconvenience, this should be fixed in the new release v2.3.1

beornf commented 1 year ago

Excellent I've tested and that fixes the webpack errors. Not familiar with all the typescript and webpack quirks. Thanks 👍