Moritz Hofmeister
11/04/2024, 2:49 PMjsBrowserDevelopmentRun
everything works fine (probably because of some webpack dev server magic) but when running our ./gradlew clean stage
task I face dependency resolution issues in my Index.mjs
(Index.kt source file) with import { createRoot as createRoot } from 'react-dom/client';
The resulting error is Uncaught TypeError: Failed to resolve module specifier "react-dom/client". Relative references must start with either "/", "./", or "../".
When I check in the build folder what’s inside kotlin-react-dom
there’s no client
file present that would contain createRoot
. Maybe this is an issue due to react-dom being exported with commonJS?
Basically, in the ModeratorInterface.kt
the entry point is specified as /admin/js/CampusQR-moderatorFrontend.mjs
for production and /moderatorFrontend.js
in local development mode.
Btw I also saw that in the react-lazy-components
example project (https://github.com/turansky/seskar/tree/master/tests/react-lazy-components/app) the build output does not contain createRoot. @turansky
You can check out the migration branch here: https://github.com/studoverse/campus-qr/tree/moritz/per-file-compilationturansky
11/04/2024, 3:50 PMcreateRoot
is hereturansky
11/04/2024, 3:50 PMMoritz Hofmeister
11/04/2024, 3:50 PMMoritz Hofmeister
11/04/2024, 3:52 PMcreateRoot
works in dev mode. It’s just that in production it’s not part of the bundle anymore apparently.Moritz Hofmeister
11/04/2024, 4:12 PMturansky
11/04/2024, 4:18 PMturansky
11/04/2024, 9:07 PMMoritz Hofmeister
11/04/2024, 9:10 PMMoritz Hofmeister
11/04/2024, 9:12 PMThemeProvider
with the following import in one of the wrapper files
import { default as default_0 } from '@mui/material/styles/ThemeProvider';
Moritz Hofmeister
11/04/2024, 9:16 PMturansky
11/04/2024, 9:17 PMturansky
11/04/2024, 9:23 PMturansky
11/04/2024, 9:24 PMturansky
11/05/2024, 11:11 AMMoritz Hofmeister
11/05/2024, 12:24 PMturansky
11/05/2024, 12:43 PMMoritz Hofmeister
11/05/2024, 6:29 PMcreateRoot
not existing) with the seskar project for you:
1. Open the seskar project.
2. Run gradle clean to be sure you are starting from scratch.
3. Run jsBrowserProductionWebpack
for the react-lazy-components
project.
4. Inside build/compileSync/js/main/productionExecutable/kotlin/kotlin-react-dom
you will only see ReactHTML.mjs
.
When running the equivalent dev task jsBrowserDevelopmentWebpack
everything is here.
The issue seems to be that files that are actually used in the application are stripped from the resulting build.Moritz Hofmeister
11/05/2024, 6:44 PMKotlin 2.1.0-RC
and got the following error when running jsBrowserProductionWebpack
or jsBrowserDevelopmentWebpack
for the react-lazy-components
project in seskar.turansky
11/05/2024, 6:45 PMbuild/compileSync/js/main/productionExecutable/kotlin/kotlin-react-dom
you will only see ReactHTML.mjs
.
It's expected 😉
createRoot
- external declarationturansky
11/05/2024, 6:47 PMI also wanted to check out if something changed withYou can use SeskarKotlin 2.1.0-RC
3.50.1
We use it in our tests.Moritz Hofmeister
11/05/2024, 8:03 PMMoritz Hofmeister
11/05/2024, 8:07 PMEvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
I got this error in Kotlin 2.0.21. This went away after upgrading from Kotlin 2.0.21 to Kotlin 2.1.0-RC.