hi I have just upgraded from kotlin 1.5.0 -> 1....
# javascript
r
hi I have just upgraded from kotlin 1.5.0 -> 1.5.31 and have hit an error with webpack config in a kotlinJS module - I'm hoping someone might have seen before -
Cant resolve 'crypto' in DCE
- it looks like i should just have to add some webpack config but i am unsure how to do it. The error is in the thread.
Copy code
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
Copy code
Module not found: Error: Can't resolve 'crypto' in '/Users/robmunro/repos/personal/cuer/cuer/build/js/packages/Cuer-remote/kotlin-dce-dev'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }
i dont explicity use this
crypto
library
t
Old ktor?
r
not luck i'm afraid - just updatd to 1.6.5
t
Do you need
nodejs
target?
r
its a
browser
app only.
so i added that the
webpack.config.d/resolve_exports.js
then added the dependencies in my build.gradle.kts
webpack.config.d/resolve_exports.js
Copy code
module.exports = {
  resolve: {
    fallback: {
      assert: require.resolve('assert'),
      buffer: require.resolve('buffer'),
      console: require.resolve('console-browserify'),
      constants: require.resolve('constants-browserify'),
      crypto: require.resolve('crypto-browserify'),
      domain: require.resolve('domain-browser'),
      events: require.resolve('events'),
      http: require.resolve('stream-http'),
      https: require.resolve('https-browserify'),
      os: require.resolve('os-browserify/browser'),
      path: require.resolve('path-browserify'),
      punycode: require.resolve('punycode'),
      process: require.resolve('process/browser'),
      querystring: require.resolve('querystring-es3'),
      stream: require.resolve('stream-browserify'),
      string_decoder: require.resolve('string_decoder'),
      sys: require.resolve('util'),
      timers: require.resolve('timers-browserify'),
      tty: require.resolve('tty-browserify'),
      url: require.resolve('url'),
      util: require.resolve('util'),
      vm: require.resolve('vm-browserify'),
      zlib: require.resolve('browserify-zlib'),
    },
  },
};
build.gradle.kts
Copy code
val jsMain by getting {
    dependencies {
        implementation("org.jetbrains.kotlin-wrappers:kotlin-react:$ver_kotlin_react")
        implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom:$ver_kotlin_react")
        implementation("org.jetbrains.kotlin-wrappers:kotlin-styled:$ver_kotlin_styled")
        implementation(npm("react-youtube-lite", "1.0.1")) // todo 1.1.0
        implementation(npm("react-share", "~4.2.1")) // todo 4.4.0

        implementation("com.ccfraser.muirwik:muirwik-components:0.9.0") {
            exclude(group = "org.jetbrains.kotlin-wrappers", module = "kotlin-styled")
            exclude(group = "org.jetbrains.kotlin-wrappers", module = "kotlin-react")
            exclude(group = "org.jetbrains.kotlin-wrappers", module = "kotlin-react-dom")
        }
        //<https://github.com/CookPete/react-player>
        //implementation(npm("react-player", "2.9.0"))

        // imports related to webpack fallback issue
        implementation(npm("crypto-browserify", "~3.12.0"))
        implementation(npm("console-browserify", "~1.2.0"))
        implementation(npm("constants-browserify", "~1.0.0"))
        implementation(npm("domain-browser", "~4.22.0"))
        implementation(npm("stream-http", "~3.2.0"))
        implementation(npm("https-browserify", "~1.0.0"))
        implementation(npm("os-browserify", "~0.3.0"))
        implementation(npm("path-browserify", "~1.0.1"))
        implementation(npm("process", "~0.11.10"))
        implementation(npm("querystring-es3", "~0.2.1"))
        implementation(npm("stream-browserify", "~3.0.0"))
        implementation(npm("timers-browserify", "~2.0.12"))
        implementation(npm("tty-browserify", "~0.0.1"))
        implementation(npm("vm-browserify", "~1.1.2"))
        implementation(npm("browserify-zlib", "~0.2.0"))
    }
}
but still the same error ...
i guess another option would be to use an older webpack <5?
t
It works fine on latest versions and webpack 5
No redundant dependencies required
You need find outdated dependency to solve problem
r
ok .. lets see
looks like it was a lib called korio
thanks heaps for the help 🙂
😃 1
a
@Robert Munro how did you resolve this issue? Did you add anything your build.gradle.kts file?
r
It was a lib called
korio
removing it resolved the issue. Think it introduced an outdated dependency