Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changes to fix colocated template sourcemaps #1

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/colocated-broccoli-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ module.exports = class ColocatedTemplateProcessor extends Plugin {
let hasBackingClass = false;
let hasTemplate = this.inputHasFile(basePath + '.hbs');
let backingClassPath = basePath;

let ext;
if (this.inputHasFile(basePath + '.js')) {
backingClassPath += '.js';
ext = '.js';
hasBackingClass = true;
} else if (this.inputHasFile(basePath + '.ts')) {
backingClassPath += '.ts';
ext = '.ts';
hasBackingClass = true;
} else if (this.inputHasFile(basePath + '.coffee')) {
backingClassPath += '.coffee';
ext = '.coffee';
hasBackingClass = true;
} else {
backingClassPath += '.js';
ext = '.js';
hasBackingClass = false;
}

Expand Down Expand Up @@ -173,10 +177,12 @@ module.exports = class ColocatedTemplateProcessor extends Plugin {

// It's not clear to me how to format this correctly for coffeescript.
if (!backingClassPath.endsWith('.coffee')) {
let file = filePathParts.name + ext;
let jsContentsMap = jsContentsMagic.generateMap({
source: jsOutputPath,
file: jsOutputPath,
source: backingClassPath,
file,
includeContent: true,
hires: true
});

jsContents += `\n//# sourceMappingURL=${jsContentsMap.toUrl()}`;
Expand Down