aepp-sdk-js
aepp-sdk-js copied to clipboard
Fix compatibility with create-react-app@4
Recently I find out that api generated by autorest
can't be build in create-react-app@4 with error:
Failed to compile.
./node_modules/@aeternity/aepp-sdk/es/apis/node/node.mjs
Can't import the named export 'ServiceClient' from non EcmaScript module (only default export is available)
node.mjs contains
import * as coreClient from "@azure/core-client";
As a workaround I made a patch https://github.com/aeternity/babel-plugin-transform-default-named-imports/commit/a4a149b1473114dacc29ec939d98bfa388117e88 to babel-plugin-transform-default-named-imports that rewrites it to:
import coreClient from "@azure/core-client";
The oridinal issue probably because azure packages doesn't formatted properly to work in this case (have mjs file extension or type: module
in package.json).
Also, would be nice if babel-plugin-transform-default-named-imports
supports rewriting a namespace import to a default one (as I implemented in my patch).
I'm asking @subhod-i to investigate this and to send a PR to the babel plugin and to open an issue in one of autorest repos.
https://github.com/formatjs/formatjs/issues/1395
@Kalovelo @martinkaintas
https://github.com/Azure/azure-sdk-for-js/issues/22172 Created an issue on the azure-sdk-for-js repository. Let's revisit once the issue is closed.
let's just drop out of the box compatibility with react-scripts@4
and add a link to https://stackoverflow.com/questions/64002604/how-to-make-create-react-app-support-mjs-files-with-webpack or so to compatibility table
I think the react application is now working with latest SDK release where the circular dependency was removed.
tested https://github.com/subhod-i/aepp-boilerplate-react today. I talked to @ifaouibadi to revisit this and provide a PR to the "official" react boilerplate repo of Emmanuel once reay
the problem is not in circular dependencies (we had it before), but in imports of cjs modules from mjs in webpack@4
with default configuration. For example, because of this problem we can't import autorest in react-scripts@4
@ifaouibadi is this a blocker / problem for the boilerplate right now?
@marc0olo it works fine, btw after the update the boilerplate uses react-scripts@4