corneil
02/07/2020, 3:09 PMSvyatoslav Kuzmich [JB]
02/07/2020, 9:39 PM.js
file produced.
In Gradle it can be specified as
kotlinOptions {
outputFile = "${buildDir}/classes/main/yourModuleName.js"
}
or using CLI -output yourModuleName.js
argument.corneil
02/08/2020, 3:51 AMcorneil
02/08/2020, 5:01 AMBuilt at: 02/08/2020 7:00:30 AM
Asset Size Chunks Chunk Names
kfsmweb.js 48 KiB main [emitted] main
Entrypoint main = kfsmweb.js
[0] multi C:/Users/corne/workspaces/open-jumpco/kfsm-webjs/build/classes/main/webModule.js 28 bytes {main} [built]
[../../../classes/main/webModule.js] C:/Users/corne/workspaces/open-jumpco/kfsm-webjs/build/classes/main/webModule.js 11.4 KiB {main} [built]
corneil
02/08/2020, 10:44 AMIlya Goncharov [JB]
02/10/2020, 12:09 PMwebpack.config.d
and create js file with any name, and content which configure library mode for webpack (https://webpack.js.org/configuration/output/#outputlibrary)
config.output = config.output || {} // just in case where config.output is undefined
config.output.library = "libraryName" // should be valid js variable name
It forces webpack to put all your export to js variable libraryName
You can additionally set js module system (https://webpack.js.org/configuration/output/#outputlibrarytarget) if you want
You can find example here
https://github.com/ilgonmic/kotlinjs-multi-module/blob/master/app/webpack.config.d/library.jscorneil
02/15/2020, 7:52 AM(index):31 Uncaught ReferenceError: kfsmweb is notd efined
I have updated my project on github. If you can spot anything wrong: https://github.com/open-jumpco/kfsm-webjs
The JS is in https://github.com/open-jumpco/kfsm-webjs/blob/master/src/main/resources/index.htmlIlya Goncharov [JB]
02/15/2020, 8:16 AMtype=module
, which is valid only with es-modules
Try to remove this type
, and it should helpIlya Goncharov [JB]
02/15/2020, 8:20 AMlibraryTarget
you declare, that output file will be in umd
format, not es-module
. Kotlin/JS can’t produce es modules yet, and webpack can’t too.corneil
02/15/2020, 8:21 AM@JsName
before the methods.Ilya Goncharov [JB]
02/15/2020, 8:23 AMcorneil
02/15/2020, 8:23 AMIlya Goncharov [JB]
02/15/2020, 8:27 AMcorneil
02/15/2020, 8:27 AMcorneil
02/15/2020, 8:28 AM@JsName
is helping nowIlya Goncharov [JB]
02/15/2020, 8:43 AMlibrary.js
will be redundant, because this settings will be available by default
Value of library
will be name of your module, but of course you can change it (as a libraryTarget
if you want)corneil
02/15/2020, 8:43 AM