nano
                                
                                 nano copied to clipboard
                                
                                    nano copied to clipboard
                            
                            
                            
                        Switch to ESM only
Make nanojsx esm only and drop cjs completely.
Hey @yandeu, I tried setting up a project with SSR and "type": "module" inside package.json.
To reduce entry point size, I'd like to import every export from nano-jsx/lib/<component> instead of importing everything from nano-jsx. I changed every import from lib to esm folder for testing, but now the commonjs server files also use the esm files with require so it naturally throws [ERR_REQUIRE_ESM]: require() of ES Module server\assets\index.page.ab0d9bb1.js not supported.
I thought when pointing to nano-jsx it would maybe load from esm automatically for client, but it still loads from nano-jsx/lib/index.
Is it actually possible to already use the esm bundle in the current state of development with SSR?
It is ready.
But I believe Webpack can't bundle Node.js modules yet. So you can't use it Isomorphic. At least I failed setting it up.
To use it on the server you can use the node12 option of the ts compiler (typescript@next).
Oki, I didn't use Webpack, I used Vite with vite-plugin-ssr which is using ESBuild to compile Typescript. I gonna read the docs again and see if I can get it working.
I finally got a working example :) https://github.com/nanojsx/nano-jsx-esm-example
I finally got a working example :) https://github.com/nanojsx/nano-jsx-esm-example
Nice, thanks. I also tried but couldn't get it working.
Will you remove cjs support in the future?
In the future, I will make esm the default. But I will still ship both.
I finally got a working example :)
https://github.com/nanojsx/nano-jsx-esm-example
Is this something we may use already?
Is this something we may use already?
Yes