Getting this uninformative / unactionable error si...
# javascript
j
Getting this uninformative / unactionable error since 1.8. Also tried 1.8.20-RC2. I disabled all our webpack configuration overrides and it doesn't seem to matter. It seems to not like one of our files but since it is not telling me which one, I have nothing to go on. jsBrowserDevelopmentRun seems to work fine, jsBrowserProductionRun, jsBrowserWebpack, jsBrowserProductionWebpack all fail with this.
Copy code
16 actionable tasks: 5 executed, 11 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jsBrowserProductionWebpack'.
> Module parse failed: Unterminated regular expression (144:33)
  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>
  |       Companion_getInstance_3();
  |       var tmp1_div = 1000000.0;
  >       tmp$ret$0 = tmp0_div.if() / tmp1_div;
  |       tmp$ret$1 = new Pair(Unit_getInstance(), tmp$ret$0);
  |       tmp$ret$2 = tmp$ret$1.m4_1;
  
  Module parse failed: Unterminated regular expression (341:33)
  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>
  |       // Inline function 'kotlin.Long.div' call
  |       var tmp0_div = roundToLong(latitude * 1000000);
  >       tmp$ret$0 = tmp0_div.if() / 1000000.0;
  |       roundedLat = tmp$ret$0;
  |       var tmp$ret$1;
p
I am facing the same problem since migrating from kotlin 1.7.21 to 1.8.10 yesterday. What I discovered is that it fails only for production builds (task jsBrowserProductionWebpack). Development builds (task jsBrowserDevelopmentWebpack) work fine. To bypass this error in our builds I forced using development builds and configured webpack tasks to use options that force mangling and optimisation on, leading to a kjs file which is about the same size as in 1.7.10:
Copy code
js(IR) {
            useCommonJs()
            browser {
                webpackTask {
                    if (Configuration.shouldBeProductionVersion) {
                        mode = KotlinWebpackConfig.Mode.PRODUCTION
                        sourceMaps = false
                    }
                }
                commonWebpackConfig {
                    if (Configuration.shouldBeProductionVersion) {
                        mode = KotlinWebpackConfig.Mode.PRODUCTION
                        sourceMaps = false
                    }
                }
			}
        }
The
Configuration.shouldBeProductionVersion
flag is something that you would have to adapt to your build. In ours, it is set in a buildSrc kotlin file based on environmzent variables defined by our CI/CD pipeline.
Not sure if both
webpackTask
and
commonWebpackConfig
blocks are required but it can't hurt.
j
I tried this but it still crashes for me. I think it's related to the minification and not to source maps.