Hi, I'm trying to use `useEsModules()` function fo...
# javascript
a
Hi, I'm trying to use
useEsModules()
function for my project, but I'm getting an error :
Copy code
Module parse failed: Identifier 'AboutMeSection' has already been declared (9687:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See <https://webpack.js.org/concepts#loaders>
|   return true;
| };
> function AboutMeSection(content, date, image, id, title) {
|   image = image === VOID ? false : image;
|   title = title === VOID ? null : title;
Here is my class :
Copy code
data class AboutMeSection(
	val content: String,
	val date: Int,
	val image: Boolean = false,
	val id: String,
	val title: (@Composable () -> Unit)? = null
)
And yes I confirm that it generated the function 2 times
a
Hi. It's so weird. Could you please create an issue on YouTrack and assign it on me? Also, what version of the compiler do you use?
a
Hi, I tried to create a simpler example on a blank Kotlin/JS project, and I can't have ESModules to work at all. I'm on 1.8.22 (but my prior test ^ was on 18.20). Here is my simple configuration :
Copy code
kotlin {
	js(IR) {
		browser {
			commonWebpackConfig {
				devServer?.open = false
				sourceMaps = true
			}
		}

		useEsModules()
		binaries.executable()
	}
}
When I run this, webpack never gets called and the webpack dev server is never opened. And as CORS are a thing I can't even just open the html file in the build folder to see the result.
Here is the complete logs of what I'm getting when running the task
a
Hmmm, could you share the
gradle browserDevelopmentRun --scan
? It's weird, and we would like to fix it if the propblem is inside the compiler
a
a
Seems like, the option
devServer?.open = false
, not only turn off the dev server running, but also, turn off the webpack build
a
It's doing the same thing with
devServer?.open = true
a
And even if you will change
useEsModules
to
useCommonJs
?
a
Then it works, with
useCommonJs
or none of these
a
Hmm. I will debug it tomorrow with 1.8.22. But, could you please also check it with the
1.9.0-RC
version?
a
This is exactly what I'm doing right now ! So it runs the webpack dev server but on my webpage I get this error now :
Copy code
test-js-bug.js:946 Uncaught TypeError: Cannot set properties of undefined (setting 'webpackHotUpdatetest_js_bug')
    at test-js-bug.js:946:48
    at test-js-bug.js:1416:13
    at test-js-bug.js:1428:12
    at webpackUniversalModuleDefinition (test-js-bug.js:17:25)
    at test-js-bug.js:18:3
(
test-js-bug
is the name of my project)
a
Hmmm. I will check. Could you make an issue in youtrack?
a
Yes, I'll do that tomorrow !
i
I see this issue closed but it's still reproducible on 1.9.10 and appears to be because of the composable function value.
s
Hi! Were you able to resolve it? I'm facing the same issue when trying to run the
jsBrowserDistribution
gradle task
i
No, still can't use it in our project. Been hoping documentation will come out soon explaining intent or demo it so we can configure it properly assuming that's the problem.
🆗 1
gratitude thank you 1
139 Views