Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Pinia support #12707

Merged
merged 4 commits into from Mar 8, 2022

Conversation

yusufkandemir
Copy link
Member

@yusufkandemir yusufkandemir commented Mar 8, 2022

What kind of change does this PR introduce?

  • Feature
  • Documentation

Does this PR introduce a breaking change?

  • No

The PR fulfills these requirements:

  • It's submitted to the dev branch (or v[X] branch)
  • Any necessary documentation has been added or updated in the docs or explained in the PR's description.

Other information:

TODO:

  • SSR work
  • Docs work

To test it locally:

  1. Install the dependencies of each related package, and build them if applicable:
cd create-app
yarn

cd ../app-vite
yarn

cd ../app-webpack
yarn

cd ../ui
yarn
yarn build
  1. Create apps by running the following:
./quasar/create-app/index.js # your local path might be different

Note: Linting with TS projects doesn't work OOTB, because create-app is WIP. So, you might want to not choose the linting feature. Alternatively, you can update .eslintrc.js's parserOptions section to this:

parserOptions: {
  parser: require.resolve('@typescript-eslint/parser'),
  extraFileExtensions: [ '.vue' ]
},
  1. cd into the project you've created.

  2. Update package.json of the created projects to use the local packages:

"quasar": "file:../../quasar/ui",

"@quasar/app-vite": "file:../quasar/app-vite",

"@quasar/app-webpack": "file:../../quasar/app-webpack",
  1. Install the dependencies
yarn
  1. (Optional) Modify src/pages/Index.vue to actually use the example store:
<template>
  <q-page class="row items-center justify-evenly">
    <div>
      {{ counter }} - {{ doubleCount }}
    </div>

    <div>
      <q-btn label="Increment" @click="store.increment" />
    </div>
  </q-page>
</template>

<script lang="ts" setup>
import { useCounterStore } from 'src/store/example';
import { storeToRefs } from 'pinia';

const store = useCounterStore();
const { counter, doubleCount } = storeToRefs(store);
</script>
  1. Start the dev server:
yarn quasar dev # or just "quasar dev"

@yusufkandemir yusufkandemir changed the title feat(app-webpack): Add Pinia support feat: Add Pinia support Mar 8, 2022
@rstoenescu rstoenescu marked this pull request as ready for review March 8, 2022 19:50
@rstoenescu rstoenescu merged commit 3a45337 into quasarframework:dev Mar 8, 2022
@rstoenescu
Copy link
Member

PERFECT timing.

One thing to explore is the SSR state serialization/deserialization of the Pinia store. The equivalence of what we do for Vuex. The setup needs Quasar v2.6 in order for SSR to work (for both app-webpack and app-vite).

Wanna dig into this tomorrow or would u like me to do it?

@yusufkandemir
Copy link
Member Author

I was actually going to continue with the SSR stuff and docs, as I noted them as TODO and marked the PR as draft. But, it seems like you've needed it just in time, so I will continue with them in separate PRs. I already somewhat know what the solution will be like, so I will continue working tomorrow.

@yusufkandemir yusufkandemir deleted the feat-pinia-support branch March 8, 2022 21:41
@rstoenescu
Copy link
Member

@yusufkandemir will push something for app-vite in quasar-config-file that you'll need tomorrow (#initialVersions.pinia/vuex) --> so that templates/entry/client and server can be handled differently for each store.

store.replaceStore for Vuex and Pinia's equivalent stuff

Sorry for talking briefly. On a hurry to release all the stuff.

PS: you're amazing! keep it going

@rstoenescu
Copy link
Member

For SSR it is absolutely necessary to build the /ui package and use it. Both app-webpack and app-vite will break without it on SSR otherwise.

@rstoenescu
Copy link
Member

Just saw the draft PR. Your approach actually doesn't require my stuff. Sniffing should work better than wasting time and resources checking for Vuex and Pinia installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants