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 support for errorRecovery option in @parcel/transformer-css #8352

Merged
merged 4 commits into from Aug 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 28 additions & 1 deletion packages/transformers/css/src/CSSTransformer.js
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