Comments (8)
I got it to work by adding a little more configuration to webpack inside the webpack.config.d folder
config.module.rules.push(
{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre'
})
config.devtool= "source-map"
You may want to try to use "eval-source-map" or "inline-source-map" for the devtool value in non production environments.The "source-map" option in chrome may require you to reopen Chrome dev console. Sometimes when reloading the page the source maps information got lost in Chrome. That seems to be related to the size of the source map files since once I changed the code above to only include my core application I no longer lost source map information when reloading the page.
I'm using a pretty bare-bones gradle configuration for the frontend plugin using mostly default paths
kotlinFrontend {
sourceMaps = true
npm {
dependency("react", "16.5.2")
dependency("react-dom", "16.5.2")
dependency("toastr", "2.1.4")
}
webpackBundle {
bundleName = "app"
sourceMapEnabled = true
}
}
compileKotlin2Js {
kotlinOptions.moduleKind = 'umd'
kotlinOptions.sourceMap = true
kotlinOptions.sourceMapEmbedSources = "always"
}
I didn't see any changes from having sourceMapEnabled = true or omitting it
This is also working as a multiplataform project with a jvm backend, common module and frontend.
Edit:
I started having some issues occasionally with my main application files showing up blank in the browser dev tools. Turns out that adding the option kotlinOptions.sourceMapEmbedSources = "always" solves that problem. Updated the code above with it, you may need to do a clean build after that.
from kotlin-frontend-plugin.
I'm struggling to make the webpack code point to original kotlin files. When I build the code, the source mappings in the webpack bundle just point to the JS files, and NOT the original kotlin files, which makes debugging extremely difficult. Is this known? Is there some trick to making this work in Chrome?
from kotlin-frontend-plugin.
There should be *.js.map
files in build/js. I can see source maps work well in full stack example.
Check the following:
- kotlin is configured to generate source maps
compileKotlin2Js {
kotlinOptions.sourceMap = true
- source maps are enabled for frontend plugin
kotlinFrontend {
sourceMaps = true
from kotlin-frontend-plugin.
I believe that the plugin should setup compiler options as well so user shouldn't enable source maps twice
from kotlin-frontend-plugin.
This still seems to be an issue. It looks like this is caused by the combination of the kotlin to js compiler with webpack. The compiler compiles kotlin to JS and provides source maps for this. Then webpack mangles the JS into a bundle and provides source maps from the bundle to the original JS (which was the output of the Kotlin compiler). So in the browser you only get back what was the output of the kotlin compiler, not the original Kotlin source code.
from kotlin-frontend-plugin.
Nice one, this worked for me as well, thanks for sharing!
from kotlin-frontend-plugin.
Thank you. This config in webpack.config.d is missing in documentation.
from kotlin-frontend-plugin.
This helped, but did anyone manage to get karma loading the sourcemaps for the unit-tests?
from kotlin-frontend-plugin.
Related Issues (20)
- Doesn't handle npm dependencies of dependent project HOT 1
- New MPP: Add example how to run js/karma tests
- Error when using org.jetbrains.kotlin.frontend 0.0.44 with gradle 5.1.1 HOT 3
- HMR not working correctly with Kotlin >= 1.3.20 HOT 2
- webpack.config.d directory should be optional HOT 2
- Missing Gradle plugin ID inhibits usage in kotlin gradle scripts HOT 1
- Error: Cannot find module './build/WebPackHelper.js' HOT 1
- ERROR in Entry module not found: Error: Can't resolve 'new-mpp' in '/Users/clegge/Projects/kotlin-frontend-plugin/examples/new-mpp/build'
- Extension with name 'kotlin' does not exist HOT 3
- JQuery externals producing IOException with version 0.0.45 and gradle 5.2.1
- HMR stops working when using Gradle continuous build HOT 1
- Import a js module for its side effects only HOT 2
- are you not supporting the plugin anymore? HOT 6
- Support create-react-kotlin-app scripts
- Seems to be conflicting with new `kotlin("js")` plugin HOT 2
- Add a KotlinJS JAR as a NPM dependency
- missing org.jetbrains.kotlin.core....jar\bin' HOT 1
- error: Source option 6 is no longer supported. Use 7 or later. HOT 1
- [Error] NpmPackageManager$injectDependencies$1$1 overrides final method getBuildDependencies HOT 5
- build.gradle.kts with sourceSets in android project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotlin-frontend-plugin.