marko-js / examples

55 stars 36 forks source link

Vite example not working on windows 10 #17

Open J-Hoh opened 3 years ago

J-Hoh commented 3 years ago

The current marko-vite example as-is does not work under windows environments.

First Error would be:

PS D:\DEV\marko-vite> npm run dev

> marko-vite@1.0.0 dev D:\DEV\marko-vite
> node --enable-source-maps index.js

Listening on port 3000
12:34:56 [vite] Internal server error: ENOENT: no such file or directory, open 'D:\DEV\marko-vite\D:\DEV\marko-vite\src\pages\index\template.marko'

Which can be fixed by adding root: "./" to the vite.config object. Afterwards you can run the example in dev mode πŸŽ‰


Cue the next problem:

building for production:

PS D:\DEV\marko-vite> npm run build

> marko-vite@1.0.0 build D:\DEV\marko-vite
> rimraf dist && npm run build:server && npm run build:client

> marko-vite@1.0.0 build:server D:\DEV\marko-vite
> cross-env NODE_ENV=production vite build --ssr src/index.js

vite v2.4.4 building SSR bundle for production...
βœ“ 32 modules transformed.
dist/index.js   101.14kb

> marko-vite@1.0.0 build:client D:\DEV\marko-vite
> cross-env NODE_ENV=production vite build

vite v2.4.4 building for production...
βœ“ 4 modules transformed.
[vite]: Rollup failed to resolve import "src\\pages\\index\\template.marko?marko-browser-entry" from "src\pages\index\template.marko.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:
Error: [vite]: Rollup failed to resolve import "src\\pages\\index\\template.marko?marko-browser-entry" from "src\pages\index\template.marko.html".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at onRollupWarning (D:\DEV\marko-vite\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:51765:19)
    at onwarn (D:\DEV\marko-vite\node_modules\vite\dist\node\chunks\dep-c1a9de64.js:51550:13)
    at Object.onwarn (D:\DEV\marko-vite\node_modules\rollup\dist\shared\rollup.js:20494:13)
    at ModuleLoader.handleResolveId (D:\DEV\marko-vite\node_modules\rollup\dist\shared\rollup.js:19843:26)
    at D:\DEV\marko-vite\node_modules\rollup\dist\shared\rollup.js:19790:22
    at async Promise.all (index 0)
    at async ModuleLoader.fetchStaticDependencies (D:\DEV\marko-vite\node_modules\rollup\dist\shared\rollup.js:19788:34)
    at async Promise.all (index 0)
    at async ModuleLoader.fetchModule (D:\DEV\marko-vite\node_modules\rollup\dist\shared\rollup.js:19764:9)
    at async Promise.all (index 0)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! marko-vite@1.0.0 build:client: `cross-env NODE_ENV=production vite build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the marko-vite@1.0.0 build:client script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

With this error my knowledge of vite ends. I'm terribly sorry if this is an error with vite and not any part of the marko "ecosystem".

Everything is working on a random linux distro aswell as raspbian 10; but production building is not working on windows 10. The webpack example (or rather my project build upon the webpack example) works on my machine (win10).

Package versions - Node 14 / 15 - @marko/express 1.0.0 - @marko/vite 2.0.0 - @marko/compiler 5.15.0 - marko 5.15.1 - compression 1.7.4 - express 4.17.1 - raptor-pubsub 1.0.5 - cross-env 7.0.3 - marked 2.1.3 - rimraf 3.0.2 - vite 2.4.4
asieverding commented 3 years ago

I have the same issue, please help.