Hi everyone! Has anyone got a hack for getting con...
# javascript
g
Hi everyone! Has anyone got a hack for getting console errors to reference source map lines so that debugging runtime errors is a little easier? Right now I just get things like a giant CCE error blob and have to go hunting.
b
Make sure you use ir backend, kotlin 1.6.10 and have sourceMaps enabled
g
Ok. Will try. Stupid question but if i have:
Copy code
runTask {
                devServer =
                    devServer
                        ?.copy(
                            proxy = mutableMapOf("/api" to mutableMapOf("target" to "<http://localhost:8081>")),
                            contentBase = devServer!!.contentBase
                        )
                cssSupport.enabled = true
                sourceMaps = true
            }
this won’t put sourcemaps into my final production webpack correct?
(also thanks for responding!)
b
Don't think so. But even if it does, you can append your own task logic to remove them at the end of
jsBrowserProductionExecutable
task
g
ok. thanks again
i will update after trying
b
No worries
g
one thing though. sourcemaps are already happening because i can set debug breakpoints in the kotlin source in the browser and they work. however the error messages refer to the bundled code. i did not have sourceMaps set to true in gradle, but i had them in my webpack.config.d/config.js file
will adding the sourceMaps flag in Gradle actually change anything?
b
And that's the issue, you need to enable sourceMaps through gradle and remove that bit from webpack.config.d. Otherwise kotlin plugin has no idea that it should produce sourceMaps
g
ok
yeah that doesn’t seem to fix the issue. for example in the console i’m still getting errors that map to bundled file:
Copy code
cause: undefined

message: undefined

name: "ClassCastException"

stack: "captureStack@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:28351:26\nClassCastException_init_$Create$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:31123:17\nTHROW_CCE@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:28458:11\n_no_name_provided__899.prototype.invoke_onfaoi_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:124398:61\n_no_name_provided_$factory_831/<@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:124805:16\npromise callback*_no_name_provided__900.prototype.invoke_tt3qgg_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:124418:11\n_no_name_provided__915.prototype.invoke_v7roz3_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:125069:20\n_no_name_provided_$factory_843/<@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:125126:16\n_no_name_provided__665.prototype.invoke_xfv2uo_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:112911:12\n_no_name_provided_$factory_621/<@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:113164:9\nEventListener.handleEvent*_no_name_provided__668.prototype.invoke_9wmc9h_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:112973:40\n_no_name_provided_$factory_617/<@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:113138:9\n_no_name_provided__153.prototype.invoke_0_k$@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:58877:10\n_no_name_provided_$factory_110/<@webpack-internal:///./kotlin/slang-monorepo-customer-portal-app.js:58908:16\ninvokePassiveEffectCreate@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:23482:20\ncallCallback@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:3945:14\ninvokeGuardedCallbackDev@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:3994:16\ninvokeGuardedCallback@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:4056:31\nflushPassiveEffectsImpl@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:23569:30\nunstable_runWithPriority@webpack-internal:///../../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js:468:12\nrunWithPriority$1@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:11276:10\nflushPassiveEffects@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:23442:14\ncommitBeforeMutationEffects/<@webpack-internal:///../../node_modules/react-dom/cjs/react-dom.development.js:23319:11\nworkLoop@webpack-internal:///../../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js:417:42\nflushWork@webpack-internal:///../../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js:390:14\nperformWorkUntilDeadline@webpack-internal:///../../node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js:157:48\n"
b
How are you running your dev server?
g
gradlew jsBrowserDevelopment
@Big Chungus have you gotten errors working with sourcemaps in any example project?
b
None that I recall