Skip to content
Merged
Changes from 1 commit
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
29 changes: 28 additions & 1 deletion packages/transformers/css/src/CSSTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default (new Transformer({
});
return conf?.contents;
},
async transform({asset, config, options}) {
async transform({asset, config, options, logger}) {
// Normalize the asset's environment so that properties that only affect JS don't cause CSS to be duplicated.
// For example, with ESModule and CommonJS targets, only a single shared CSS bundle should be produced.
let env = asset.env;
Expand All @@ -46,6 +46,7 @@ export default (new Transformer({
res = transformStyleAttribute({
code,
analyzeDependencies: true,
errorRecovery: config?.errorRecovery,
targets,
});
} else {
Expand Down Expand Up @@ -77,6 +78,7 @@ export default (new Transformer({
sourceMap: !!asset.env.sourceMap,
drafts: config?.drafts,
pseudoClasses: config?.pseudoClasses,
errorRecovery: config?.errorRecovery,
targets,
});
}
Expand All @@ -103,6 +105,31 @@ export default (new Transformer({
});
}

if (res.warnings) {
for (let warning of res.warnings) {
logger.warn({
message: warning.message,
codeFrames: [
{
filePath: asset.filePath,
codeHighlights: [
{
start: {
line: warning.loc.line,
column: warning.loc.column,
},
end: {
line: warning.loc.line,
column: warning.loc.column,
},
},
],
},
],
});
}
}

asset.setBuffer(res.code);

if (res.map != null) {
Expand Down