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

Fix compatibility with create-react-app@4 #1529

Open
davidyuk opened this issue May 24, 2022 · 8 comments
Open

Fix compatibility with create-react-app@4 #1529

davidyuk opened this issue May 24, 2022 · 8 comments
Assignees

Comments

@davidyuk
Copy link
Member

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.

@subhod-i
Copy link
Collaborator

subhod-i commented Jun 6, 2022

formatjs/formatjs#1395

@subhod-i
Copy link
Collaborator

subhod-i commented Jun 6, 2022

@Kalovelo @martinkaintas

@subhod-i
Copy link
Collaborator

subhod-i commented Jun 9, 2022

Azure/azure-sdk-for-js#22172
Created an issue on the azure-sdk-for-js repository. Let's revisit once the issue is closed.

@davidyuk davidyuk changed the title Don't use custom version of babel-plugin-transform-default-named-imports Fix compatibility with create-react-app@4 Jul 29, 2022
@davidyuk
Copy link
Member Author

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

@marc0olo
Copy link
Contributor

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

@davidyuk
Copy link
Member Author

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

@marc0olo
Copy link
Contributor

@ifaouibadi is this a blocker / problem for the boilerplate right now?

@ifaouibadi
Copy link
Member

@marc0olo it works fine, btw after the update the boilerplate uses react-scripts@4

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

No branches or pull requests

4 participants