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(nuxt): supports automatic import of stores from extend layers #2828

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from

Conversation

wzc520pyfm
Copy link

@wzc520pyfm wzc520pyfm commented Nov 9, 2024

When I install pinia in a nuxt layer and create stores folder, and then I extend this layer in another nuxt application, I find that the stores are not automatically imported.

What this PR does:

When addImportsDir, consider the nuxt layers also.

Refer:

Pinia autoImports for nuxt

Nuxt layers

Copy link

netlify bot commented Nov 9, 2024

Deploy Preview for pinia-playground canceled.

Name Link
🔨 Latest commit 3f4442f
🔍 Latest deploy log https://app.netlify.com/sites/pinia-playground/deploys/672fa0866fec6d00089bec54

Copy link

netlify bot commented Nov 9, 2024

Deploy Preview for pinia-official canceled.

Name Link
🔨 Latest commit 3f4442f
🔍 Latest deploy log https://app.netlify.com/sites/pinia-official/deploys/672fa086672e41000862bf3b

@wzc520pyfm wzc520pyfm changed the title feat(nuxt): supports automatic import of folder in extend layers feat(nuxt): supports automatic import of stores from extend layers Nov 9, 2024
@@ -101,6 +101,10 @@ const module: NuxtModule<ModuleOptions> = defineNuxtModule<ModuleOptions>({
if (options.storesDirs) {
for (const storeDir of options.storesDirs) {
addImportsDir(resolve(nuxt.options.rootDir, storeDir))

for (const layer of nuxt.options._layers) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this an internal property? 😓 Let's use a public API

Copy link

pkg-pr-new bot commented Nov 28, 2024

Open in Stackblitz

npm i https://pkg.pr.new/pinia@2828
npm i https://pkg.pr.new/@pinia/nuxt@2828
npm i https://pkg.pr.new/@pinia/testing@2828

commit: 3f4442f

@posva
Copy link
Member

posva commented Nov 28, 2024

I noticed there is also #2757, so let's use that one instead. Thanks for the PR!

@posva posva closed this Nov 28, 2024
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.34%. Comparing base (6e90153) to head (3f4442f).
Report is 22 commits behind head on v2.

Additional details and impacted files
@@           Coverage Diff           @@
##               v2    #2828   +/-   ##
=======================================
  Coverage   89.34%   89.34%           
=======================================
  Files          14       14           
  Lines        1323     1323           
  Branches      218      219    +1     
=======================================
  Hits         1182     1182           
  Misses        140      140           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants