danfma
09/27/2017, 2:18 AMkotlin-dce-js
is generating invalid code?konsoletyper
09/27/2017, 7:09 AMdanfma
09/28/2017, 7:11 PM<https://github.com/danfma/kodando-reakt>
and use to reproduce it.
Configuration of the environment:
1. Clone the repo;
1. ./gradlew clean build
(to build the project);
2. yarn install
or npm install
(to install the dependencies);
3. `yarn start`;
Scenario 1 (bundling in development mode - WORKS)
1. yarn start
(it will use webpack to bundle the project by using the generated files and dependencies without the dce, and it will start a server at the port 3000).
Scenario 2 (bundling in production mode - FAIL AT RUNTIME)
1. yarn build
(it will use the webpack to bundle the project and it will copy the generated files to the path samples/counter-application/www/js
.danfma
09/28/2017, 7:15 PMmin
directory, you will see that the generated code ignores the projects in the repository, and create them as almost empty files. So, at runtime, we will get an access to an undefined object (package).konsoletyper
10/02/2017, 9:05 AMplugins
section completely and still get minified output. Any suggestions what's wrong?konsoletyper
10/02/2017, 9:48 AMcompileTestKotlin2Js {
kotlinOptions.metaInfo = true
kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}-test.js"
kotlinOptions.sourceMap = true
kotlinOptions.sourceMapEmbedSources = "always"
kotlinOptions.moduleKind = 'commonjs'
}
So, single output dir used for both main and tests source sets. That caused DCE to overwrite min
directory when running :samples:counter-application:runDceTestKotlinJs
. It can be fixed by changing output directory for tests, i.e "$project.buildDir.path/js-test/${project.name}-test.js"danfma
10/02/2017, 12:48 PMdanfma
10/03/2017, 11:13 AM