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
Scala.js 1.0.0 unnecessary generates imports for parent classes #4001
Comments
I want to upvote this in the hope it is given priority. ScalablyTypes is a key project in making use of existing TS ecosystem. This issue will unblock projects consuming ScalablyTyped to move to Scala.js 1.x. |
Implementation note: The reason this happens is that when we analyze, we always load the super class, even for native classes which usually do not need this information (I'm unsure whether there is a case it is needed). This is probably a good idea anyways to have a consistent However, when emitting imports, we cannot distinguish between classes that are present because they are used or because merely something declares them in their "metadata". As such we import all of them. @sjrd the refinement / linking stages could drop the |
I think we should just not generate imports for native JS classes that are not instantiated (i.e., its |
Fix #4001: Only import JS classes that are needed
Hey, thank you so much @gzm0 for being so responsive! |
As mentioned in ScalablyTyped/Converter#131 Scala.js 1.0.0 ends up including imports of superclasses unnecessarily when referencing a class. I'll copy in the example:
With Scala.js 0.6, this would only import from the module
rsocket-websocket-client
, while Scala.js 1.0.0 will also import fromrsocket-websocket-client/RSocketWebSocketClient
.This is a problem because the latter doesn't exist, so bundling won't succeed.
There are a range of reasons why Typescript definitions may end up mentioning module names which don't have a corresponding .js file at bundle-time. For this particular example the third party typings are imprecise.
It's not impossible for me to find a different encoding for re-exporting classes such that this would be safe, but it would end up quite a bit uglier.
Any chance we can revert this behaviour?
The text was updated successfully, but these errors were encountered: