OpenEnergyTools / scl-lib

5 stars 4 forks source link

Debugging with source maps #43

Open danyill opened 1 year ago

danyill commented 1 year ago

I've been using scl-lib in an OpenSCD core extension.

When I set a break point and try to trace through scl-lib, it fails because the source map refers to information not included in the package. This is true for a plugin which I am testing on locally (using @web/dev-server), however it does not appear to be a problem on the built plugin (using rollup).

For example, locally I have installed the current scl-lib version (0.5.9) and am trying to debug the insertIED function:

What I see in my node_modules folder is (truncated view):

scl-lib
├── dist
│   |── tIED
│        ├── insertIED.d.ts
│        ├── insertIED.js
│        └── insertIED.js.map
├── package.json
└── README.md

If I open node_modules/@openenergytools/scl-lib/dist/tIED/insertIED.js.map, the reference is to ../../tIED/insertIED.ts

{"version":3,"file":"insertIED.js","sourceRoot":"","sources":["../../tIED/insertIED.ts"],"names":[],"mappings":"A

but these files are not included in the package...

I think this is why my browser barfs at it with the following 404:

Could not load content for http://localhost:8000/node_modules/@openenergytools/scl-lib/tIED/insertIED.ts (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE)

image

For now, I've unticked "Enable JavaScript Source Maps" to force Chrome to use only the Javascript and not look for the Typescript files.

Ideally we'd either: