Skip to content

Commit

Permalink
Merged PR 87620: Fix src map generation to for debugging source outsi…
Browse files Browse the repository at this point in the history
…de of imjs monorepo

Inline ts sources into *.js.map files.

The change is trying to solve the issue of being able to properly debug the source mapped back to Typescript when outside of the iModel.js repo since the switch to react-scripts based build.  This was previously possible because each individually webpack-ed package was doing exactly this but within the webpacked bundle that we delivered with the modules.

There are a few approaches here in order to get full TS debugging,

1. Inlining (like this PR does)
1. Resolving the "sourceFile", that the sourceMap is mapping to, from a GitHub url for that specific version.  This would effectively have the user, when resolving the source maps pull the original typescript from GitHub

   This is complicated for a number of reason, (1) how would we ensure versions are correctly mapped, (2) right now we do not publish all package versions to GitHub so internal consumers would be out of luck for the most part and (3) getting that to work would take a lot of time investment.

With the above as the only 2 approaches available right now, we're going to go with 1.  The consequences of this is it will increase our package sizes again (:() but a necessary evil in order to make the library easier to use as an outside developer.

Some analysis on the package sizes as a result of this change:

- Pre-2.0:
  - package size: 2.9 MB
  - unpacked size: 13.8 MB
- Post-2.0 w/o sourcemaps:
  - package size: 1.6 MB
  - unpacked size: 7.9 MB
- Post-2.0 w/ sourcemaps:
  - package size:  2.4 MB
  - unpacked size: 11.3 MB
  • Loading branch information
aruniverse authored and calebmshafer committed May 19, 2020
1 parent bff5cf8 commit f4de028
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@bentley/build-tools",
"comment": "Add inline sources to properly debug ts files",
"type": "none"
}
],
"packageName": "@bentley/build-tools",
"email": "[email protected]"
}
19 changes: 10 additions & 9 deletions tools/build/tsconfig-base.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
"module": "commonjs",
"stripInternal": false,
"declaration": true,
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied "any" type. */
"strictNullChecks": true, /* Enable strict null checks. */
"noImplicitThis": true, /* Raise error on "this" expressions with an implied "any" type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
"noUnusedLocals": false, /* DON'T report compilation errors on unused locals - use lint rule instead. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noFallthroughCasesInSwitch": false, /* DON'T Report errors for fallthrough cases in switch statement. It is possible to use this feature safely, and we have been doing that for years. */
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"experimentalDecorators": true,
"skipLibCheck": true,
"sourceMap": true,
"inlineSources": true,
"declarationMap": true,
"jsx": "react",
"forceConsistentCasingInFileNames": true,
Expand Down
3 changes: 2 additions & 1 deletion tools/build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"declaration": false,
"declarationMap": false,
"sourceMap": false,
"inlineSources": false,
"incremental": false,
"rootDir": "./src",
"outDir": "." // We want the files to be accessible within a directory at the root alongside the scripts directory
Expand All @@ -15,4 +16,4 @@
"lib",
"node_modules"
]
}
}

0 comments on commit f4de028

Please sign in to comment.