Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit 43ff577

Browse files
committed
Generate source maps from TypeScript for easier debugging
1 parent c948438 commit 43ff577

File tree

7 files changed

+306
-6
lines changed

7 files changed

+306
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ tags
2020
TAGS
2121

2222
/haddock-api/resources/html/node_modules
23+
/haddock-api/resources/html/*.js.map
2324

2425
.cabal-sandbox
2526
.ghc.environment.*

haddock-api/resources/html/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
* Run `npm install` and `npm install gulp-cli -g` in this directory.
55
* Run `gulp` in this directory. This rebuilds the minified JS files.
66

7-
# Manual Testing
7+
# Development and manual testing
88

9-
Generate haddock docs for some Haskell project and replace the generated JS files:
9+
Generate Haddock docs for some Haskell project. Start an HTTP server in the Haddock docs directory.
10+
(The `file://` protocol doesn't work since it doesn't allow AJAX requests.)
11+
12+
After each change to the TypeScript sources, compile and copy the generated files (JS and sourcemaps for better debugging) to the Haddock directory:
1013

1114
```
12-
gulp && cp *.min.js path-to/generated-haddock-docs
15+
gulp && cp *.min.js path-to/generated-haddock-docs && cp *.js.map path-to/generated-haddock-docs
1316
```

haddock-api/resources/html/gulpfile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ const browserify = require('browserify');
44
const source = require('vinyl-source-stream');
55
const buffer = require('vinyl-buffer');
66
const tsify = require('tsify');
7+
const sourcemaps = require('gulp-sourcemaps');
78

89
function buildJS(targetFileName, files) {
9-
var b = browserify({ entries: files });
10+
var b = browserify({ entries: files, debug: true });
1011
return b
1112
.plugin(tsify)
1213
.bundle()
1314
.pipe(source(targetFileName))
1415
.pipe(buffer())
16+
.pipe(sourcemaps.init({loadMaps: true}))
1517
.pipe(uglify().on('error', function(e) { console.log(e); }))
18+
.pipe(sourcemaps.write('.'))
1619
.pipe(gulp.dest('.'));
1720
}
1821

haddock-api/resources/html/haddock-bundle.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)