Skip to content

Commit ede07d0

Browse files
authored
Better source maps (#567)
* Add a new local server task * Fix sourcemap
1 parent df7615e commit ede07d0

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ build-and-upload: build
3535

3636
build-and-publish: build
3737
make publish-assets
38-
.PHONY: build-and-publish
38+
.PHONY: build-and-publish
39+
40+
local-server:
41+
yarn build
42+
node ./scripts/build-shells.js
43+
npx serve
44+
.PHONY: local-server

scripts/build-shells.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ files.forEach(file => {
2222
const libraryName = last(libraryPath.split('/')).replace('.js', '');
2323
const vendorPath = last(vendor[0].split('build'));
2424

25-
const dynamic = `
26-
window['${libraryName}Deps'] = ["${vendorPath}"]
25+
// We need this to remain a single line in order to not break source maps,
26+
// as well as put the bracket at the very end, this is so we don't change the line numbers
27+
// for the dynamic file
2728

28-
window['${libraryName}Loader'] = function() {
29-
return ${fs.readFileSync(file).toString()}
30-
}
31-
`.trim();
29+
// prettier-ignore
30+
const dynamic = `
31+
window['${libraryName}Deps'] = ["${vendorPath}"];window['${libraryName}Loader'] = function() { return ${fs.readFileSync(file).toString()}
32+
};`.trim();
3233

3334
const filename = file.replace(/\.js$/, '.dynamic.js');
3435
fs.writeFileSync(filename + '.gz', zlib.gzipSync(dynamic));

0 commit comments

Comments
 (0)