-
Notifications
You must be signed in to change notification settings - Fork 392
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
Misleading error message when passing an invalid stylesheet #3156
Comments
This issue has been linked to a new work item: W-12040411 |
Looks related/duplicate of #1887 |
Related: #3122 |
@nolanlawson I'm looking at this bug and would love your input with your stylesheet expertise. I can see three possible approaches to fix this issue for 244:
I'm leaning towards implementing the second solution in |
@jye-sf So first off, the repro from the playground above does not seem to throw any error ( As for the more generic problem of distinguishing LWC-compiled stylesheet functions from arbitrary functions-that-return-a-string (#3122), I figured we should follow the same pattern as Also of course we would need to start with a warning first and only make it an error later, as we do with |
The repro above looked like a workaround-ed version of the issue. I was able to reproduce the issue by copying the CSS into the I think fully implementing the function uPlot(opts, data, then) { ... }
function stylesheet(token, useActualHostSelector, useNativeDirPseudoclass) { ... }
var _implicitStylesheets = [uPlot, stylesheet];
...
var _tmpl$1 = registerTemplate(tmpl$1);
tmpl$1.stylesheets = [];
if (_implicitStylesheets) {
tmpl$1.stylesheets.push.apply(tmpl$1.stylesheets, _implicitStylesheets);
}
tmpl$1.stylesheetToken = "x-chart_chart";
freezeTemplate(tmpl$1); |
I guess the question is whether this issue is urgent enough that we want a stopgap change to the error message until we can implement Personally, if the main issue with using the function name |
OK, I think I understand now. The core issue is: @import 'x/uPlot'; /* imports JS, not CSS */ I wouldn't say it's urgent, but it is annoying. I also think it would make the most sense to implement
I believe in this case |
You're right, I'm definitely overcomplicating things 😅. After a closer look at the compiler this weekend I see how we can easily pass only the stylesheet into |
Fixed by #3443 |
Description
The LWC engine throws a cryptic error when it attempts to evaluate a stylesheet that hasn't been generated by the compiler.
Steps to Reproduce
Playground: link
In this example, the
x/uPlot
module contains both a JavaScript and a StyleSheet file. Thex/uPlot
module is referenced both in thex/chart
JavaScript and StyleSheet files. The developer expected the JavaScript import resolves to theuPlot.js
and the StyleSheet import resolves to theuPlot.css
.However, the LWC module resolver doesn't work this way. Importing a module containing both a JavaScript and a StyleSheet file would always resolve the JavaScript file. That said it's not obvious because the LWC engine would attempt to evaluate the JavaScript default export as a stylesheet resulting in a cryptic error.
Expected Results
Actual Results
Browsers Affected
All
Version
Possible Solution
The LWC engine should do a brand-check of the stylesheet function before evaluating it. If the check fails, the engine should report a
TypeError
.The text was updated successfully, but these errors were encountered: