-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
serve
and sass compiler not detecting changes in imported scss that previously caused an error (beta 2 regression)
#6025
Comments
This might be related to #5132 although I start without cache. |
I get this issue without an error. Any scss file imported from another fails to register a change. Have to continually go to main file and click save to force a compile and update. |
Looking over the @parcel/transformer-sass code a little bit, pieced together a few clues, but still don't have a proper solution. Here's what I've found.
async transform({ asset, options, config, resolve, logger }) {
let rawConfig = config !== null && config !== void 0 ? config : {};
let sassRender = (0, _util().promisify)(_sass().default.render.bind(_sass().default));
let css;
try {
let code = await asset.getCode();
let result = await sassRender({
...rawConfig,
file: asset.filePath,
data: rawConfig.data ? rawConfig.data + _os().EOL + code : code,
importer: [
...rawConfig.importer,
resolvePathImporter({
asset,
resolve,
includePaths: rawConfig.includePaths,
options
})
],
indentedSyntax:
typeof rawConfig.indentedSyntax === 'boolean'
? rawConfig.indentedSyntax
: asset.type === 'sass'
});
css = result.css;
for (let included of result.stats.includedFiles) {
// ⭐ only if the build passes are includedFiles added to the asset.
// ⭐ this seems to be one source of the problem?
if (included !== asset.filePath) {
asset.addIncludedFile(included);
}
}
if (result.map != null) {
let map = new (_sourceMap().default)(options.projectRoot);
map.addRawMappings(JSON.parse(result.map));
asset.setMap(map);
}
} catch (err) {
// ⭐Here, if you don't throw, you can watch the file for changes.
asset.addIncludedFile(err.file);
// Adapt the Error object for the reporter.
err.fileName = err.file;
err.loc = {
line: err.line,
column: err.column
};
// ⭐ Escape an internal error.
css = '';
// ⭐ Removes throw and uses logger.
// ⭐But `parcel build` will pass. Not good.
logger.error(err);
}
asset.type = 'css';
asset.setCode(css);
return [asset];
}
}); As you can see this isn't a solution, but I think it adds some context to the problem. |
🐛 bug report
I'm using a simple project with an
index.html
, linking astyle.scss
that imports other scss files and runningparcel serve
. When the sass compiler encounters an error in one if the imported scss files, it will output the error to the console.After fixing the error and saving the file, the compiler does not notice the change and nothing happens.
This is a regression from 2.0 beta 1, where it successfully picked up the fix and restarted compilation.
🎛 Configuration (.babelrc, package.json, cli command)
parcel serve index.html --open --no-cache
🤔 Expected Behavior
When using
serve
, an imported scss file into an other scss file, and encountering a sass compilation error, I expect it to recompile after I fix my change.😯 Current Behavior
The new change (fix) in the broken file is not detected.
🔦 Context
--no-cache
flag makes no differenceThis issue is especially noticeable when having auto save enabled in the IDE, it will save WIP code (i.e. midway typing a line) code and trigger the compilation — which usually is fine, but not if have have to restart serve every time it compiles en encounters an error.
💻 Code Sample
Full repro continue-serve-after-error-beta2-repro.zip
Both beta 1 and beta 2 included for reference.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: