nodegui / svelte-nodegui

Build performant, native and cross-platform desktop applications with native Svelte + powerful CSS-like styling.🚀
https://svelte.nodegui.org/
MIT License
2.84k stars 55 forks source link

bug: app gives module not found on startup when trying to use npm package #26

Closed mrsauravsahu closed 3 years ago

mrsauravsahu commented 3 years ago

Issue

Cannot resolve phin package

Screenshot 2021-02-24 at 5 35 56 PM

Workaround

Installing phin with an npm install phin fixes this issue for now.

shirakaba commented 3 years ago

@mrsauravsahu Thanks for catching this! Aiming to fix it now.

shirakaba commented 3 years ago

I had a lot of problems before trying to find a way to bundle phin. It's something to do with a disagreement between commonjs modules (which we have one loader for) and esm modules (which are rollup's default), possibly complicated by TypeScript and default exports.

It's further complicated by the rollup config, with its declaration of internal vs. external modules.

https://github.com/nodegui/svelte-nodegui/blob/74e7f3053ed6be478cb8945606d8357816550534/rollup.config.js#L9

As I don't want this to hold up the alpha release (and I'm not confident I can fix it anyway), I've decided to just declare it as a peer dependency of @nodegui/svelte-nodegui for now, and have satisfied that peer dependency in the svelte-nodegui-starter template, which builds and runs happily.

The commit of mention: https://github.com/nodegui/svelte-nodegui/commit/a62490ee391634bef6518ef0619ddd9fa4a01897