-
Notifications
You must be signed in to change notification settings - Fork 18
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
Importing into a Typescript frontend does not work correctly #1
Comments
(removed by initial quick guess ... does not seem to be an issue with your code). It is a bit puzzling that index.d.ts is not used. Maybe you can explicitly import spl.js/index.js? Maybe it is issue wit the bundler you are using? P.S.: |
I think this is a Typescript error, not a bundler error. In my opinion, Typescript uses "index.ts", "main" or "types" fields of package.json, not "browser" field or something else. Bundlers can use all. react-scripts are tools from https://create-react-app.dev/ and are used primarily for building web app (so no need to use --target browser) It use webpack under the hood to bundle the application. If you didn't have a problem with rollup, maybe your test setup didn't check the types? This deep import work:
But it is not very understandable. Maybe something like this can be clearer:
|
Hm, yes, maybe. In the rollup plugin to resolve paths you can set a So you are right: it seems to be a ts rather than webpack issue. Another workaround would be {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"spl.js": ["node_modules/spl.js/dist/index"]
}
}
} I admit this is not very elegant. But why does ts not have an option to honor 'main' vs 'browser'? microsoft/TypeScript#21423 |
🤷 |
Hi @jvail
Thanks for this beautiful work. I am trying to integrate spl.js in a typescript frontend. But I did not manage to import
the async version.
When I try a simple example:
I got these errors:
Code can be found in this repository: https://github.com/remipassmoilesel/spl.js-issue-2021-12-27
See
splPlayground.js
: https://github.com/remipassmoilesel/spl.js-issue-2021-12-27/blob/master/src/splPlayground.tsIn my opinion it is due to
spl.js
package.json structure:If I modify it like this, all works fine:
Questions
choose according to the target (node or browser)
The text was updated successfully, but these errors were encountered: