segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.33k stars 131 forks source link

Should unresolved imports be errors? #110

Open dominicbarnes opened 9 years ago

dominicbarnes commented 9 years ago

While using duo-myth, I was halted because unresolved imports were throwing errors.

@import "suitcss/base";

Gets me:

Error: Failed to find suitcss/base

I'm going to propose that the default behavior of duo-myth skip imports processing. (since duo handles that on it's own of course) However, it seems like the default behavior for myth should perhaps be to warn, rather than throw an error.

Thoughts?

ianstormtaylor commented 9 years ago

That sounds reasonable to me I think, although differs from Myth's other broken cases where we error like for color() functions, but seems like Myth should be run after all of the Duo pieces have already been imported?

dominicbarnes commented 9 years ago

Currently, duo plugins operate on each individual file, before the entire build is collated. In duojs/duo#346, the discussion has been started about how to specify a plugin to run on the build as a whole instead. (but that hasn't been agreed upon yet)

ianstormtaylor commented 9 years ago

Gotcha, makes sense!

Will the Myth stuff work in the case you're using it for if the variables are included in a separate Duo file then? Seems more stuff might break in that case without applying it to the full build

ianstormtaylor commented 9 years ago

Btw for the warning stuff, I think you make a lot of sense still regardless of Duo, we might want to start warning for everything and be non-breaking like CSS is natively. Does that sound right? I can't really think of a case where you'd depend on the errors, since CSS itself can be misformed and just fine?

dominicbarnes commented 9 years ago

Yeah, variables won't work anymore once myth is no longer handling the imports. That's the big problem I'm wanting to address with duojs/duo#346.

And yeah, I couldn't agree more about warning about these types of things. CSS doesn't throw an error, but it doesn't warn either. (but the warning comes from the builder, not the CSS itself so I think it's still consistent!)

dominicbarnes commented 9 years ago

Since myth aims to be consistent with CSS, (even if it's "future" syntax) I think using warnings here is far more appropriate.

We could add a "strict mode" for myth, that way someone wanting to fail on these types of conditions can still do it. Thoughts?

ianstormtaylor commented 9 years ago

Strict mode sounds really smart! I'm +1 to making them all warnings

On Sat, Nov 15, 2014 at 6:53 PM, Dominic Barnes notifications@github.com wrote:

Since myth aims to be consistent with CSS, (even if it's "future" syntax) I think using warnings here is far more appropriate.

We could add a "strict mode" for myth, that way someone wanting to fail on these types of conditions can still do it. Thoughts?

— Reply to this email directly or view it on GitHub https://github.com/segmentio/myth/issues/110#issuecomment-63201965.