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

Error recovery from Sass errors #7374

Open
razvanandreib opened this issue Nov 28, 2021 · 13 comments
Open

Error recovery from Sass errors #7374

razvanandreib opened this issue Nov 28, 2021 · 13 comments

Comments

@razvanandreib
Copy link

razvanandreib commented Nov 28, 2021

πŸ› bug report

As I start typing in the scss file , I immediately get this error and it happens everytime:

🚨 Build failed.

@parcel/transformer-sass: expected "{".
β•·
289 β”‚ .
β”‚  ^

And parcel stops to function, i need to close it and npm start all over again.

πŸŽ› Configuration (.babelrc, package.json, cli command)

{
  "name": "ime-cadastru",
  "version": "1.0.0",
  "source": "./src/pages/cadastru.html",
  "description": "",
  "scripts": {
    "start": "parcel ./src/index.html",
    "build": "parcel build"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@parcel/transformer-sass": "^2.0.1",
    "parcel": "^2.0.1",
    "sass": "^1.43.4",
    "sharp": "^0.29.3"
  }
}

πŸ”¦ Context

I try to write css in the scss files and immediatly after i start typing i get this error.

πŸ’» Code Sample

🌍 Your Environment

Software Version(s)
Parcel "@parcel/transformer-sass": "^2.0.1",
"parcel": "^2.0.1",
"sass": "^1.43.4",
"sharp": "^0.29.3"          |

| Node v17.1.0 |
| npm/Yarn 8.1.2 |
| Operating System Windows 10 |

@bensanlau
Copy link

+1. I'm also running into same issue. It happens when I'm watching and make a syntax mistake. After rectifying it + save, the bundler does not automatically bundle. I had to close and re-watch.
Strangely, I find that saving another file in your project somehow triggers the build.
But working on the same file that had the mistake does not trigger anything.

@folknor
Copy link

folknor commented Dec 14, 2021

This is probably a duplicate of #6685 or one of the 10+ linked issues from that ticket, like #5660.

@mischnic
Copy link
Member

Can someone post a reproduction with instructions on how to trigger this bug?

@razvanandreib
Copy link
Author

Sure. will come back with a screenshot.

@bensanlau
Copy link

Hey @mischnic,

It's my first time logging a bug, but I'll try to be concise:

Set up

  1. I create a new project following the webapp starterkit, including adding an index.html inside the src folder.
  2. Instead of calling styles.css, I'm using SCSS and changed the extension. This installs the transformer-sass plugin.
  3. In styles.scss, I @import another .scss file (let's call it header.scss).

Reproducing bug:

  1. If I'm to make a syntax error in header.scss, parcel encounters an error.
  2. After fixing that error and save, parcel does not re-build even when watching. I'll have to ^C close and re-run the npx script.
  3. I discovered saving the entry point file (styles.scss) will trigger the re-build.

I also discovered this set up works with normal .css files. It's Sass (maybe transformer-sass?) that is the problem.

I'm not sure if it's similar to what @razvanandreib is facing. If it's not, I can create a new issue.

@razvanandreib
Copy link
Author

razvanandreib commented Dec 16, 2021

I attached a screenshot with the bug. Immediately after I select an element in the scss file this error appear as in the screenshot
error
u

@Goodosky
Copy link

Goodosky commented Dec 29, 2021

I have exactly the same problem as @bensanlau.

The issue also occurs with pug files.

In my example:
image
When I make a mistake in a file in "partials" directory, parcel encounters the error (like on @razvanandreib's screenshot) and I have to re-run the script or save not-imported/not-included* file (e.g. index.pug or bootstrap.scss).

*not-imported by @import in scss and not-included by include,extends in pug.

My script: parcel pug/*.pug

@mischnic
Copy link
Member

mischnic commented Dec 30, 2021

@bensanlau Thanks! I can reproduce that.

This might also be happening for Elm: #6124

@mischnic
Copy link
Member

Actually, the problem seems to be that Sass, Elm and Pug all throw an error on a parser error and don't return the list of additionally included files (header.scss). So Parcel doesn't know that these other files also need to be watched.

for (let included of result.stats.includedFiles) {
if (included !== asset.filePath) {
asset.invalidateOnFileChange(included);
}
}

@mischnic
Copy link
Member

mischnic commented Jan 4, 2022

sass/sass#2950 (comment)

@mischnic mischnic changed the title Build Failed transformer-sass expected { Error recovery from Sass errors Apr 25, 2022
@hrynevychroman
Copy link

Any updates here how to fix it? i don't want to relaunch dev every time i slowly typed {} 😁

@albinbrengesjo
Copy link

Also experience this problem. Any updates?

@sjors-bootmine
Copy link

Watching with interest for this bugfix. Thanks for the efforts fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants