twa-dev / SDK

npm package for TWA SDK
https://codesandbox.io/s/sdk-kj5961
MIT License
238 stars 21 forks source link

Unable to resolve import file #8

Closed ivaanteo closed 1 year ago

ivaanteo commented 1 year ago

Create-react-app with typescript

yarn create react-app my-app --template typescript

Upon installation of @twa-dev/sdk, this error is raised.

"ERROR in ./node_modules/@twa-dev/sdk/dist/index.js 1:0-31
Module not found: Error: Can't resolve './sdk' in '/Users/ivan/TelegramBot/TestReact/my-app/node_modules/@twa-dev/sdk/dist'
Did you mean 'sdk.js'?
BREAKING CHANGE: The request './sdk' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request."
ArthurStam commented 1 year ago

I switched to CommonJS modules in 6.9.1. Issue should be fixed. Tested on cra, cra with typescript, raw webpack project and vite.

ivaanteo commented 1 year ago

Awesome, appreciate the fix!