nanojsx / nano

🎯 SSR first, lightweight 1kB JSX library.
http://nanojsx.io
MIT License
1.46k stars 38 forks source link

Make deno type exports more module freindly #114

Closed sigmaSd closed 2 years ago

sigmaSd commented 2 years ago

The newest releases of deno changed module detection behavior, commit https://github.com/denoland/deno/commit/845d4754c6fb959d1404f5de4bba9e71667b8c89 issue https://github.com/denoland/deno/issues/14960

This pr changes exported types to be more deno module friendly.

I wrote this with guidance from @nayeemrmn

yandeu commented 2 years ago

Thanks for the suggestions.

Actually, the files inside deno_lib, should not be changed manually. They are auto-generated.

In the latest version, core.types.ts as been renamed to types.d.ts and will be imported via /// <reference path="./types.d.ts" /> in core.ts. See: https://github.com/nanojsx/nano/tree/master/src


What do you think about this aproach? Does deno read the types from the triple slash directives?

nayeemrmn commented 2 years ago

If the new types are imported from a .d.ts file instead of a type-only .ts file, there is no issue👍 When the next version is available we can update the example at https://deno.com/deploy/docs/using-jsx.

yandeu commented 2 years ago

I will publish it right away.

yandeu commented 2 years ago

Is declare global needed around export var _nano?

Edit: Found the answer: https://stackoverflow.com/a/57040462

yandeu commented 2 years ago

Done.

Works well in my example repo: https://github.com/nanojsx/nano-jsx-deno-example

sigmaSd commented 2 years ago

Thanks!

yandeu commented 2 years ago

Actually, I think using a .ts file like @sigmaSd suggested is better. I noticed that standalone .d.ts do not get copied over to the dist folder.