-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Default export umd + typescript #1156
Comments
It sounds to me like the issue is on TypeScript's end, by failing to handle interop. The last thing Rollup should be doing is creating bundles that normal JS consumers have to use by appending In any case, please include a repro 😀 |
The inferno creator told me that the typescript issue should've been resolved in the latest. Here is the repro: Just clone and then run |
I don't understand what this has to do with Rollup? |
Rollup is doing the export (umd header), but maybe it's not related at all? I'm just trying to figure from where the bad export comes from :). Either typescript (who tries to get the |
Rollup doesn't create It sounds like this is a TypeScript issue, but it might be something that's easiest to work around on the Inferno end. |
Thanks to confirm my thoughts. But still having the |
It's far from ideal – it means an export can only be an object or a function, and you're mucking about with the exported object. If it was a widespread issue it might be a different matter, but if it's just to paper over a bug in a specific TypeScript version (which seems like it might be the case?) then it's not worth the extra mess and maintenance. |
Should work. I tried every latest typescript version but I'll try to find an answer on their side! Thanks for taking the time to answer! |
@Rich-Harris @soyuka I've got exactly the same problem. I'm using rollup to create In the issue already referenced by @soyuka (microsoft/TypeScript#13017) @RyanCavanaugh says:
I completely understand that it doesn't make any sense to require everyone to add |
For future reference, at my company we solved the problem with a rollup plugin, see https://github.com/dcsfuerth/ngx-build-tools/blob/master/src/utils/rollup.ts#L5 We simply replace the typescript version of imports with the rollup version of imports. |
Leaving this here if somebody is gonna stumble on this thread again. From my point of view if you want to provide a structure that is consumable for your TS typings, you should simply use Going further - if you do not enforcing CJS consumers to use |
I think this problem is solved typescript side with 2.7: |
It seems it is, but as always it will take time until 2.7 propagates though. |
Hi,
Coming from infernojs/inferno#596, I thought that this issue was related to how typescript handles the default imports, but it might in fact be related to how rollup export it.
Issue summary
Transpiles to :
Which outputs:
undefined
If you log
inferno_create_element_1
(without thedefault
key), you will get the corresponding function.The same goes for
Component
:I tried to import with the following (because of the issue above):
You can now get the Component through, but the typescript compiler isn't happy about it not beeing a constructor:
Inferno exports as
umd
, and by modifying the declaration to the below, I can import everything just fine:I think that this might be an easy fix for issues who looks related to this behavior (#1155, #1081).
I'm not really familiar with rollup, and the fix might not be appropriate. WDYT?
Thanks!
The text was updated successfully, but these errors were encountered: