How do I get sourcemaps on imported npm libraries ...
# javascript
r
How do I get sourcemaps on imported npm libraries working with the kotlin/webpack dev server?
I have all the things in my webpack config (I think):
Copy code
sourceMaps = true

                webpackTask {
                    sourceMaps = true
                }

                runTask {
                    sourceMaps = true
                }
But e.g. errors from htmx still point at the minified version, and breakpoints are useless , as it ends up all being on a single line
a
Hmm, but is there source-maps inside the node_modules/htmx?
r
Ah ok, yeah maybe that's the problem. Different question then 🙂 - can I make it load the unminified version?
Copy code
@JsModule("<http://htmx.org|htmx.org>")
@JsNonModule
external object HTMX
...is how I set it up currently
a
As you see, you can expand
htmx.js
like a directory, it's possible, that the source-map is hidden under this fold
r
Sadly, nope. It just has the min under there
a
Can you also show the content of the
package.json
?
It's possible that you can set path like this:
Copy code
@JsModule("<http://htmx.org/dist/htmx.js|htmx.org/dist/htmx.js>")
@JsNonModule
external object HTMX
But it depends on the settings inside the
package.json
r
(nvm)
Here is their package.json:
Copy code
{
  "name": "<http://htmx.org|htmx.org>",
  "description": "high power tools for html",
  "keywords": [
    "AJAX",
    "HTML"
  ],
  "version": "1.9.10",
  "homepage": "<https://htmx.org/>",
  "bugs": {
    "url": "<https://github.com/bigskysoftware/htmx/issues>"
  },
  "license": "BSD 2-Clause",
  "files": [
    "LICENSE",
    "README.md",
    "dist/htmx.d.ts",
    "dist/*.js",
    "dist/ext/*.js",
    "dist/*.js.gz",
    "editors/jetbrains/htmx.web-types.json"
  ],
  "main": "dist/htmx.min.js",
  "types": "dist/htmx.d.ts",
  "unpkg": "dist/htmx.min.js",
  "web-types": "editors/jetbrains/htmx.web-types.json",
  "scripts": {
    "test": "mocha-chrome test/index.html",
    "test-types": "tsc --project ./jsconfig.json",
    "dist": "cp -r src/* dist/ && npm run-script uglify && gzip -9 -k -f dist/htmx.min.js > dist/htmx.min.js.gz && exit",
    "ws-tests": "cd ./test/ws-sse && node ./server.js",
    "www": "bash ./scripts/www.sh",
    "uglify": "uglifyjs -m eval -o dist/htmx.min.js dist/htmx.js"
  },
  "repository": {
    "type": "git",
    "url": "git+<https://github.com/bigskysoftware/htmx.git>"
  },
  "devDependencies": {
    "chai": "^4.3.7",
    "chai-dom": "^1.11.0",
    "fs-extra": "^9.1.0",
    "mocha": "^9.2.2",
    "mocha-chrome": "^2.2.0",
    "mocha-webdriver-runner": "^0.6.4",
    "mock-socket": "^9.2.1",
    "sinon": "^9.2.4",
    "typescript": "^4.9.5",
    "uglify-js": "^3.17.4",
    "ws": "^8.14.2"
  }
}
(Figured out the issue I was trying to chase. If the target is null, the beforeSwap event won't fire, and then it will crash. https://github.com/bigskysoftware/htmx/blob/master/src/htmx.js#L4643). Still would be curious to find a way to load the source in cases like this -- I'll try your suggestion above in a bit
a
I think you can try the option I described above