Akryum / vue-cli-plugin-ssr

:sparkles: Simple SSR plugin for Vue CLI
https://vue-cli-plugin-ssr.netlify.com/
MIT License
444 stars 69 forks source link

Fatal issue with deps ordering in package.json #209

Open sneko opened 4 years ago

sneko commented 4 years ago

Hi @Akryum ,

I'm using your plugin since a long time and decided to upgrade to fix lot of workarounds I put on. I'm now on the v0.6.0 but each time I try to reach a page I get:

  App running at:
  - Local:   http://localhost:8000/ (copied to clipboard)
[21:02:04] Server listening on localhost:8000
error during render url : /
Error: bundle export should be a function when using { runInNewContext: false }.
    at /Users/XXXXXXXXX/Documents/tests/aaa/node_modules/vue-server-renderer/build.dev.js:9381:17
    at new Promise (<anonymous>)
    at /Users/XXXXXXXXX/Documents/tests/aaa/node_modules/vue-server-renderer/build.dev.js:9368:14
    at Object.renderToString (/Users/XXXXXXXXX/Documents/tests/aaa/node_modules/vue-server-renderer/build.dev.js:9544:9)
    at renderApp (/Users/XXXXXXXXX/Documents/tests/aaa/node_modules/@akryum/vue-cli-plugin-ssr/lib/app.js:123:16)
    at /Users/XXXXXXXXX/Documents/tests/aaa/node_modules/@akryum/vue-cli-plugin-ssr/lib/app.js:172:33

After spending a while on this error I succeeded making working. For this I need to put in the package.json your plugin below the @vue/cli-plugin-typescript like this:

...
    "@vue/cli-plugin-typescript": "~4.4.0",
    "@akryum/vue-cli-plugin-ssr": "~0.6.0",
...

In case I put yours at the top of its object (due to alphabetical ordering done automatically), this simply breaks 😭

I always thought the package.json ordering was not mattering. But it seems it does 🤔

If you have any idea, I would really appreciate 👍

Thank you,

EDIT: note that I also tried with a project from scratch by doing

vue create aaa
vue add router
vue add @akryum/ssr

if I test it works! But then if I add:

vue add typescript

Then it breaks as described, except if I manually switch the deps order in package.json 😞

EDIT2: since for each yarn install/upgrade... it will break the "workaround", I decided to move your plugin in the "dependencies" object as follow:

{
  ...
  "dependencies": {
    "@akryum/vue-cli-plugin-ssr": "~0.6.0",
    ...
  },
  "devDependencies": {
    ...
    "@vue/cli-plugin-e2e-nightwatch": "~4.4.0",
    "@vue/cli-plugin-pwa": "~4.4.0",
    "@vue/cli-plugin-router": "~4.4.0",
    "@vue/cli-plugin-typescript": "~4.4.0",
    "@vue/cli-plugin-unit-jest": "~4.4.0",
    ...
  },
}

in this case the auto-sorting won't break the workaround.

It's for sure not a long-term solution, I really hope someone has some insights about this 👍

bgondy commented 4 years ago

Same here.

@sneko Your workaround does the job. Thanks for sharing.