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
Is your feature request related to a problem? Please describe.
Bundlers will often strip most comments even in development mode. The only exception being comments inside classes. The behavior can sometimes be changed through configuration, but most notably in the case of ESBuild, there's no way to keep the comments as it is. This makes it difficult to work with tools that use esbuild under the hood, like Vite and consequently Vitest.
This causes the compiler to not log errors when stylesheets and templates are compiled under a different version.
I've also tested OXC, which is used by Rolldown (which will replace ESBuild for Vite in the future), and could find no way to keep any kind of comments. With SWC it was possible, but not obvious and often had mixed results (most funny an instance where comments were kept in functions but not classes which is the opposite of the example above and just as broken).
Describe the solution you'd like
In the short term it would help producing comments in the form of /*!LWC compiler v123.456.789*/ or most likely, for forwards compatibility, /*!/*LWC compiler v123.456.789*/. This is due to esbuild's support for legal comments.
The latter was the solution I had to use in #4594 .
In the long term, it would be better to move away from comments (or just comments).
The text was updated successfully, but these errors were encountered:
Using the "legal comments" format seems fine to me. The whole goal here is just to have a nice console.error message in dev mode. (It's assumed that, in dev mode, no minification occurs.)
This should be a non-breaking change and can be done outside of #4617.
cardoso
changed the title
Rethink compiler version comment
Use legal format for compiler version comment
Oct 14, 2024
Is your feature request related to a problem? Please describe.
Bundlers will often strip most comments even in development mode. The only exception being comments inside classes. The behavior can sometimes be changed through configuration, but most notably in the case of ESBuild, there's no way to keep the comments as it is. This makes it difficult to work with tools that use esbuild under the hood, like Vite and consequently Vitest.
esbuild playground
Input
Output
This causes the compiler to not log errors when stylesheets and templates are compiled under a different version.
I've also tested OXC, which is used by Rolldown (which will replace ESBuild for Vite in the future), and could find no way to keep any kind of comments. With SWC it was possible, but not obvious and often had mixed results (most funny an instance where comments were kept in functions but not classes which is the opposite of the example above and just as broken).
Describe the solution you'd like
In the short term it would help producing comments in the form of
/*!LWC compiler v123.456.789*/
or most likely, for forwards compatibility,/*!/*LWC compiler v123.456.789*/
. This is due to esbuild's support for legal comments.The latter was the solution I had to use in #4594 .
In the long term, it would be better to move away from comments (or just comments).
The text was updated successfully, but these errors were encountered: