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

Shubham Singh

10/29/2023, 5:06 AM
Update: RESOLVED Hi friends I'm getting a
TypeError: Cannot set properties of undefined
error when trying to run the
jsBrowserDistribution
gradle task to build a distributable for my JS app in a Multiplatform project Full Stacktrace inside the thread 👇
Full StackTrace:
Copy code
Execution failed for task ':js:jsBrowserProductionWebpack'.
> [webpack-cli] Failed to load '/Users/shubh/StudioProjects/Clippy/build/js/packages/Clippy-js/webpack.config.js' config
  [webpack-cli] TypeError: Cannot set properties of undefined (setting 'historyApiFallback')
  [webpack-cli] TypeError: Cannot set properties of undefined (setting 'historyApiFallback')
      at Object.<anonymous> (/Users/shubh/StudioProjects/Clippy/build/js/packages/Clippy-js/webpack.config.js:64:37)
      at Module._compile (node:internal/modules/cjs/loader:1159:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
      at Module.load (node:internal/modules/cjs/loader:1037:32)
      at Module._load (node:internal/modules/cjs/loader:878:12)
      at Module.require (node:internal/modules/cjs/loader:1061:19)
      at require (node:internal/modules/cjs/helpers:103:18)
      at WebpackCLI.tryRequireThenImport (/Users/shubh/StudioProjects/Clippy/build/js/node_modules/webpack-cli/lib/webpack-cli.js:215:22)
      at loadConfigByPath (/Users/shubh/StudioProjects/Clippy/build/js/node_modules/webpack-cli/lib/webpack-cli.js:1337:38)
      at /Users/shubh/StudioProjects/Clippy/build/js/node_modules/webpack-cli/lib/webpack-cli.js:1391:88

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD FAILED in 12s
24 actionable tasks: 5 executed, 19 up-to-date
I have a file named
webpack.js
inside
/Clippy/js/webpack.config.d/
that contains the following line of code:
Copy code
config.devServer.historyApiFallback = true;
I need this in order for the BrowserRouter react component to work properly but the error I showed above seems to be related to this code only. Is there a way to fix it?
h

hfhbd

10/29/2023, 6:45 AM
Did you put the config file in a webpack.config.d directory located in the project directory? https://github.com/hfhbd/routing-compose/tree/main/integrationTest/browserRouterTest
s

Shubham Singh

10/29/2023, 7:28 AM
Yes @hfhbd, it's in the root of the js module (right alongside the module's
build.gradle.kts
file)
h

hfhbd

10/29/2023, 7:31 AM
Did you try the string syntax like I use in the link?
s

Shubham Singh

10/29/2023, 7:31 AM
Trying it right now...
It worked! There's no way I could've figured it out just by digging through any documentation 😂 Thanks @hfhbd 🙌
Curious why the string syntax is considered different from the other syntax I was using 🤔
h

hfhbd

10/29/2023, 7:57 AM
The first one sets the existing property while the second one adds or sets the property with this value. Maybe there is a bug in KGP that does not add a correct webpack plugin which is added in the webpack documentation, so the property is added correctly before you access it. Anyway the string syntax does work.
👍 1
s

Shubham Singh

10/29/2023, 7:57 AM
Understood, thanks again 🤝