https://kotlinlang.org logo
#javascript
Title
# javascript
a

Arjan van Wieringen

09/22/2023, 3:17 PM
Okay, I am running in quite some issues with a
binaries.library
project which I want to include in a React project. I have tried it 3 ways and only 1 works and I have no clue why. My feeling is that it is related to the INSANE JS module system. I would really appreciate some input. I have made a minimal reproduceable project for the 3 situations: 1. NPM + Create React App: This one works! Including source map support. However, CRA is deprecated and NPM is slow..... (https://github.com/avwie/kotlinx/tree/npm-webpack-cra). Just run
npm run dev
. 2. NPM + Vite Create React: This one results in
"useTodoViewModel" is not exported by "../build/js/packages/architecture-demo/kotlin/architecture-demo.js", imported by "src/main.tsx"
(https://github.com/avwie/kotlinx/tree/npm-vite). Also run
npm run dev
3. PNPM + Vite Create React: This one works, but source map support isn't working. They are not resolvable and cause 404. Having source-map support is critical for development. I think it is related with how PNPM works (a central store). (https://github.com/avwie/kotlinx/tree/pnpm-vite), and run
pnpm run dev
I hope there are people who know how I can get nr.3 to work?
e

Edoardo Luppi

09/22/2023, 3:25 PM
I had issues with source maps resolution when they're under a
build/*
directory. That's why I always copy the build output to a
generated-packages
directory, and then use the workspace feature of package managers.
Linking a package via a specific protocol like
file:
should have never been invented.
🙌 1
Also, personal note, stick with npm if you can, it reduces the overall complexity in mixed projects like these. Speed is decent, not as bad as years ago.
a

Arjan van Wieringen

09/22/2023, 3:31 PM
Thanks for all the tips! I’ll try it out
3 Views