Skip to content

Commit

Permalink
Fixed source maps
Browse files Browse the repository at this point in the history
  • Loading branch information
candunaj committed Apr 26, 2023
1 parent 7417410 commit 5c11de9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ember-scoped-css/src/addon-hbs-rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export default function rollupCssColocation() {
return rewriteHbs(hbs, classes, tags, postfix);
});

return rewrittenHbsJs;
return {
code: rewrittenHbsJs,
// this rollup plugin changes only the template string, so the code structure is the same
map: null,
};
}
}
},
Expand Down
14 changes: 12 additions & 2 deletions ember-scoped-css/src/addon-js-unplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ export default createUnplugin(() => {
css = result.css;
code = recast.print(result.ast).code;
this.getModuleInfo(jsPath).meta.gjsCss = result.css;

// TODO: generate changed source map. Implementation depends on implemented rollup plugin for style tag
}
}

if (!css) {
return code;
return {
code,
map: null,
};
}

// add css import for js and gjs files
Expand All @@ -44,12 +49,17 @@ export default createUnplugin(() => {
// rewrite hbs in js in case it is gjs file (for gjs files hbs is already in js file)
// for js components "@embroider/addon-dev/template-colocation-plugin", will add hbs to js later. So there is hbs plugin to rewrite hbs

return replaceHbsInJs(code, (hbs) => {
const rewrittenCode = replaceHbsInJs(code, (hbs) => {
const { classes, tags } = getClassesTagsFromCss(css);
const postfix = getPostfix(cssPath);
const rewritten = rewriteHbs(hbs, classes, tags, postfix);
return rewritten;
});

return {
code: rewrittenCode,
map: null,
};
},
};
});

0 comments on commit 5c11de9

Please sign in to comment.