toitware / esptool.js

TypeScript port of the esptool
MIT License
108 stars 12 forks source link

Attempted import error: 'EspLoader' is not exported from '@toit/esptool.js' #15

Open paullaffitte opened 1 year ago

paullaffitte commented 1 year ago

Hello,

I'm trying to use your library in a React app but I'm facing a weird import issue at compile time only. When I run REACT_APP_API_URL=http://localhost:8000 react-app-rewired start it works, but when I run react-app-rewired build I got this error message :

> react-app-rewired build

Creating an optimized production build...
Failed to compile.

./src/serial/MicropythonSerialInterface.ts
Attempted import error: 'EspLoader' is not exported from '@toit/esptool.js'.

esptool.js version 0.12.3, typescript version 4.7.4, node version v16.18.0.

My import statement : import { EspLoader } from '@toit/esptool.js';

floitsch commented 1 year ago

Sorry for the late response.

The original author of the library is not at the company anymore, and we are lacking the skill set to debug react related issues. Sorry we can't do more at this time.

leon0399 commented 1 year ago

I've made a fork with a fix and working on eventually supporting ESP32 C3 and S3 models: https://github.com/openhaptics/esptool.ts

paullaffitte commented 11 months ago

Hello,

I found a way to make it work. I just replaced the compilerOptions.module from CommonJS to esnext. I did it several month ago though, so I don't remember exactly why I came with this solution but it has been used in production for several month now and it works. I think the reason is that we use ES modules in our project and there are some incompatibilities between CommonJS and ESM.