Remix.run Logo
Ruphin 7 days ago

Oh nice, I wasn't aware this was even possible.

Vue _does_ have some sort of build step, because components use special macros that aren't imported, and the compiler (vite) even complains when you actually import them saying it's not necessary. The build also rewrites your code to some other format that I assume is more optimized because it can do some sort of static analysis.

Are these the main reasons for Vue to use a compiler if it's not necessary? Injecting dependencies and rewriting some code to allow better performance while retaining the nice syntax?

alexisread 7 days ago | parent | next [-]

It's a combination of things.

Adding polyfills for older browser targets.

Tree shaking, that is removing code that is not used.

Bundling several files into one to save on requests.

Transpiling, that is, if you want to write code in a different language to javascript eg. Typescript then vite will compile that to javascript.

Linting ie. Reformatting your code to standardise it across developers.

Vulnerability checking, are your dependencies out of date?

Execution of build tasks eg. Preparing static assets like images.

Packaging your app for deployment eg. Zipping

Including logging and hot reload triggers during development.

Bundling environment specific changes eg. Different backend urls if deploying to test envs.

Running unit tests on rebuild to avoid regressions.

Having said all that, the bundling for me is a disadvantage as my own code changes more than 3rd party libs and they are cached. I'm less fussed with types and a lot of the tests and env stuff can be done with a single-file express server for development.

The main advantage for me is that a buildless app will still work correctly in 6 months- permacomputing considerations.

Muromec 7 days ago | parent | prev [-]

IRRC Vue will compile your templates on the fly if you don't pre-compile them, so you will be punished twice -- in performance and in bundle size for skipping the build step.

If you can eat the cost to get something in return, it's a nice trade off.