You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a limitation of our CSS packaging strategy that I anticipate will be very difficult to resolve. Conditional CSS implies loading the CSS only when a branch is taken, but to do it synchronously you'd have to download both CSS files in advance and only apply them when their branch is taken.
Also note that Parcel's strategy for process.env replacement is kind of cheating in that it just replaces with the actual value and lets Terser do the dead code elimination, so we can't currently statically determine which CSS file needs to be used. Actually for this case it should be fine and is a bug.
Is there a practical use case for this? If you really need this functionality you can just do:
No, we actually run swc'a DCE in the transformer before we collect all of the require calls (for exactly this usecase).
Some recent swc upgrade might has broken this
馃悰 bug report
When conditionally loading css via commonjs the resulting code is invalid.
馃帥 Configuration (.babelrc, package.json, cli command)
Parcel with no
.parcelrc
馃 Expected Behavior
Code should compile without error.
馃槸 Current Behavior
The output code is invalid, which causes Terser to throw an unexpected token error (see Code Sample)
馃拋 Possible Solution
Not sure!
馃敠 Context
I'm trying to load a library that conditionally includes CSS based on a environment variable
馃捇 Code Sample
Full repro at https://github.com/ross-pfahler/parcel-2-demos/tree/require-condition using
yarn build --no-optimize
turns into:
馃實 Your Environment
The text was updated successfully, but these errors were encountered: