my kotlinjs `.js.map` files do not seems to work, ...
# javascript
n
my kotlinjs
.js.map
files do not seems to work, as in .. when i open the debugger in chrome the files are empty i use
moduleKind = "umd"
and require.js to load all things (because everything else seemed to be unproportional more effort) anybody else having this issue.. or have working source mappings ?
i
I suppose, that it can be related with https://youtrack.jetbrains.com/issue/KT-32319 It plans to be fixed in next eap In this issue, there is workaround for this problem
n
that fixed it, thanks
it seems to also still work with dce in the mix
do you how to minify the code more without loosing source mapping ?
i
Now source maps is inlined to final bundle You can patch webpack configuration in
webpack.config.d
Something like this
Copy code
config.devtool='source-map'
It locates source maps in separate file
n
i have zero experience using webpack, i kinda hoped to just call a script that translates js in one folder and spits it into another folder
i
Oh, sorry, I miss that you use only DCE w/o webpack Manipulation with source maps is hard, because there is relative path in it
n
i am currently experimenting with uglifyjs used via cli, i read somewhere it can read sourcemaps and generates them so far not much luck
i
If source maps are generated by compiler and/or Kotlin/JS DCE, it can be related with UglifyJS issues. Sorry, can’t help with it, because have never tried this tool chain AFAIK UglifyJS is not supported yet, you can try Terser instead
n
bash script for terser cli:
Copy code
#!/usr/bin/env bash

./gradlew runDceClient-jsKotlin
OUTPUT=build/html/js/
rm -rf $OUTPUT
mkdir $OUTPUT
FILES=build/kotlin-js-min/client-js/main/*.js
for f in $FILES
do
  if [[ "$f" == *.meta.js ]]; then continue; fi
  echo "Processing $f file..."
  terser $f --source-map "content='$f.map',url='$b.map'" -c -m -o $OUTPUT/$(basename $f)
done