I have a slightly different problem with DCE… `bro...
# javascript
s
I have a slightly different problem with DCE…
browserDevelopmentWebpack
works fine, producing a large file. When I run
browserProductionWeback
, the
processDceKotlinJs
task reports “NO-SOURCE”, and then
browserProductionWebpack
reports
SKIPPED
. My configuration is fairly vanilla… here’s the target definition:
Copy code
kotlin {
    target {
        browser {
            useCommonJs()
            dceTask {
                keep("ktor-ktor-io.\$\$importsForInline\$\$.<http://ktor-ktor-io.io.ktor.utils.io|ktor-ktor-io.io.ktor.utils.io>")
            }
            webpackTask {
                output.libraryTarget = COMMONJS
            }
        }
    }
}
Any ideas what could be causing this?
s
Whats the name of your project? When I was doing this to produce a lib via Webpack I had to add the following to my config.
Copy code
js {
        browser {
            dceTask {
                keep("ktor-ktor-io.\$\$importsForInline\$\$.<http://ktor-ktor-io.io.ktor.utils.io|ktor-ktor-io.io.ktor.utils.io>")
                keep("multiplatform-lib")
            }
            webpackTask {
                mode = Mode.PRODUCTION
                sourceMaps = false
            }
        }
    }
t
DCE will keep your lib only if you add it in keep list
☝️ 1
👍 1
s
OK I found the problem, and it appears to be a bug with the DCE plugin. This was in a subproject, and in the root project, I have something like this:
Copy code
subprojects {
  this.tasks.all {
  .. some configuration
  }
}
When I remove the
this.tasks.all
block, things work correctly (even if the block doesn’t do anything, the problem persists), so I presume there is something with the loading and configuration of the dce task at that time that causes things to not get the correct source location. This has not been the case with other plugins.
Eager configuretion - root cause of problem
d
do you think that is causing my problem too?
t
Do you have empty distribution?
d
when i use browserProductionWebpack it doesn't contain any of my methods / classes defined by keep
s
Do you have your gradle file
t
Look like invalid
keep
instruction