JorgenVatle / meteor-vite

⚡ Replace Meteor's bundler with Vite for blazing fast build-times
MIT License
32 stars 10 forks source link

METEOR_LOCAL_DIR #116

Closed mattsouth closed 9 months ago

mattsouth commented 9 months ago

For testing purposes, it can be useful to run meteor locally, using a different local cache location. This article: https://blog.meteor.com/testing-a-meteor-app-with-cypress-bfb3d3c6ed6f suggests doing this with the METEOR_LOCAL_DIR environment variable that was introduced in meteor v1.3.3. Can this be supported by meteor-vite? If I create a skeleton vue project in meteor 2.15 and run meteor locally with this ENV variable the app fails with the following output:

me@mymachine:~/Software/meteor-vue-2.12$ METEOR_LOCAL_DIR=.meteor/test meteor
[[[[[ ~/Software/meteor-vue-2.15 ]]]]]        

=> Started proxy.                             
=> Started HMR server.                        
=> Started MongoDB.                           
I20240214-11:21:14.127(0)? ⚡   Starting Vite server...
W20240214-11:21:14.131(0)? (STDERR) ⚡  You are using an out of date version of `meteor-vite`.
W20240214-11:21:14.131(0)? (STDERR)    Please update it: $ meteor npm i meteor-vite@1.8.0
=> Started your app.

=> App running at: http://localhost:3000/
I20240214-11:21:14.377(0)?   ➜  Local:   http://localhost:5173/
I20240214-11:21:14.377(0)?   ➜  Network: use --host to expose
I20240214-11:21:14.383(0)? ⚡   Meteor-Vite ready for connections!
I20240214-11:21:14.385(0)? ⚡   Meteor-Vite ready for connections!
W20240214-11:21:15.972(0)? (STDERR) (node:1361692) UnhandledPromiseRejectionWarning: Error: Unable to read file content: ENOENT: no such file or directory, open '.meteor/local/build/programs/web.browser/packages/meteor.js'
W20240214-11:21:15.972(0)? (STDERR)     at file:///home/matt/Software/meteor-vue-2.15/node_modules/meteor-vite/dist/bin/worker.mjs:1349:13
W20240214-11:21:15.972(0)? (STDERR) (Use `node --trace-warnings ...` to show where the warning was created)
W20240214-11:21:15.973(0)? (STDERR) (node:1361692) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
W20240214-11:21:15.973(0)? (STDERR) (node:1361692) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
W20240214-11:21:15.995(0)? (STDERR) 
W20240214-11:21:15.995(0)? (STDERR)  ERROR  Unable to read file content: ENOENT: no such file or directory, open '.meteor/local/build/programs/web.browser/packages/meteor.js'
W20240214-11:21:15.996(0)? (STDERR) undefined
W20240214-11:21:15.996(0)? (STDERR) 
W20240214-11:21:15.996(0)? (STDERR) --[Error Stack]----------------------------------------------------------------------
JorgenVatle commented 9 months ago

Oh, I was not aware of this feature. I believe with the right changes to the Vite plugin config, you could probably make it work.

But that's not good enough of course. 😄 I'll do some tests and get back to you hopefully later in the evening with a patch to handle this for you automatically. 👍

JorgenVatle commented 9 months ago

This should be fixed with jorgenvatle:vite-bundler@1.12.8 and meteor-vite@1.9.1 👍

Let me know how it goes.

mattsouth commented 9 months ago

Works well for me. Much appreciated.