lumino icon indicating copy to clipboard operation
lumino copied to clipboard

Add sourcemaps back to original TS

Open blink1073 opened this issue 5 years ago • 10 comments
trafficstars

When debugging in JupyterLab (with the UMD bundles introduced in #40), I am seeing the ES6 bundle, we should be able to reach back to the original TS source files:

image

blink1073 avatar May 23 '20 11:05 blink1073

I've researched this and the related issues extensively. This will require two things:

  • include the ts sources in the released @lumino packages. Can be done in one of two ways:

    1. add "inlineSources": true to the tsconfig.json of each package
    2. (my pick) include the src dir with the actual .ts sources in the release of each package
  • tweak the jlab webpack build to include the sourcemaps produced by tsc for the @lumino packages

    • change this line to something like

      include: [...sourceMapRes, '@lumino'],
      

telamonian avatar Jun 25 '20 23:06 telamonian

I agree with adding src back to the release.

blink1073 avatar Jun 26 '20 11:06 blink1073

"src" is already included in the packages (I didn't think it got removed?): https://github.com/jupyterlab/lumino/blob/master/packages/widgets/package.json#L23 https://cdn.jsdelivr.net/npm/@lumino/widgets/

Unless I missed some by mistake?

GordonSmith avatar Jun 26 '20 11:06 GordonSmith

Also if you look in the map files you should see that the bundled versions map back to the ts files in question: https://cdn.jsdelivr.net/npm/@lumino/[email protected]/dist/index.js.map

GordonSmith avatar Jun 26 '20 11:06 GordonSmith

I don't see src in node_modules:

$ ls node_modules/@lumino/coreutils/
.            ..           LICENSE      lib          package.json

blink1073 avatar Jun 26 '20 11:06 blink1073

Its there in the released package: https://cdn.jsdelivr.net/npm/@lumino/[email protected]/package.json

GordonSmith avatar Jun 26 '20 11:06 GordonSmith

...and: https://cdn.jsdelivr.net/npm/@lumino/[email protected]/src/

GordonSmith avatar Jun 26 '20 11:06 GordonSmith

Looks good yeah, my other folder had 1.4.2.

image

blink1073 avatar Jun 26 '20 11:06 blink1073

If your using WebPack to build your project and your including JS files which in turn already have a source map associated with them (like from TS) then you should be using source-map-loader.

Example here: https://github.com/GordonSmith/HPCC-Platform/blob/eclwatch-8.x/esp/src/webpack.config.js#L95-L99

GordonSmith avatar Jun 26 '20 11:06 GordonSmith

You might need to change the "devTool" for non production builds as well: https://github.com/GordonSmith/HPCC-Platform/blob/eclwatch-8.x/esp/src/webpack.config.js#L111 (not 100% sure)

GordonSmith avatar Jun 26 '20 11:06 GordonSmith