Skip to content

Commit 548f090

Browse files
yaustarSteven Yauwilleastcott
authored
[FIX] Source map is no longer offset (playcanvas#2013)
Added note in the readme about the preprocessor breaking source maps and is therefore ignored Moved copyright to the end of the built file if source map is being built Fixed ignoring the preprocessor if source map is being built Co-authored-by: Steven Yau <syau@snaphcat.com> Co-authored-by: Will Eastcott <will@playcanvas.com>
1 parent 9ea7e8e commit 548f090

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ To build the source map to allow for easier engine debugging, you can add `-- -m
149149

150150
This will output to `build/output/playcanvas.js.map`
151151

152+
Note: The preprocessor is ignored when when generating the source map as it breaks the mapping. This means that all debug and profiling code is included in the engine build when generating the source map.
153+
152154
## How to run tests
153155

154156
PlayCanvas uses of Karma for unit testing. There are three ways of running the tests:

build/build.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ var preprocess = function (dependencies) {
163163
var pp = new Preprocessor(buffer.toString());
164164
var src;
165165
// TODO: source mapped build doesn't support preprocessor yet
166-
if(this.sourceMap)
166+
if(sourceMap)
167167
src = buffer;
168168
else
169169
src = pp.process({
@@ -210,7 +210,14 @@ var insertVersions = function (filepath, callback) {
210210

211211
var content = buffer.toString();
212212

213-
content = getCopyrightNotice(ver, rev) + content;
213+
// Add the copyright notice to the end if we are creating sourcemaps
214+
// otherwise we offset the mappings
215+
if (sourceMap) {
216+
content = content + "\n" + getCopyrightNotice(ver, rev);
217+
} else {
218+
content = getCopyrightNotice(ver, rev) + content;
219+
}
220+
214221
content = replaceAll(content, "__CURRENT_SDK_VERSION__", ver);
215222
content = replaceAll(content, "__REVISION__", rev);
216223

0 commit comments

Comments
 (0)