sass icon indicating copy to clipboard operation
sass copied to clipboard

JS API: Add Exception.loadedUrls

Open sod opened this issue 2 years ago • 2 comments

Consider these 3 files:

# a.scss
@import './b.scss'

# b.scss
@import './c.scss'

# c.scss
.foo { color: $unknownVariable }

Bundling a.scss would roughly throw this exception:

Exception {
    message: 'Undefined variable',
    span: { url: new URL('c.scss') },
}

The bundler now knows a.scss (entry file) and c.scss (error.span.url) but b.scss isn't mentioned. So trying to fix the error in b.scss (remove the import or add the variable) woudn't trigger a rebuild.

This could be solved by returning the loadedUrls array on the exception so the bundler can watch all files that have been touched.

sod avatar Jul 04 '23 14:07 sod

I'd do a PR to e.g. modify https://github.com/webpack-contrib/sass-loader/blob/master/src/index.js#L79-L90 to grant webpack the loadedUrls in case of an error.

sod avatar Jul 04 '23 14:07 sod

We have this information in Dart and in the embedded protocol, but we don't currently expose it through the JS API and we should.

nex3 avatar Jul 05 '23 20:07 nex3