Skip to content

feat(nuxt): handle nuxt route injection for this.$route#27313

Merged
danielroe merged 9 commits intonuxt:mainfrom
jakubednar:fix-issue-with-this-route-in-options-api
May 24, 2024
Merged

feat(nuxt): handle nuxt route injection for this.$route#27313
danielroe merged 9 commits intonuxt:mainfrom
jakubednar:fix-issue-with-this-route-in-options-api

Conversation

@jakubednar
Copy link
Copy Markdown
Contributor

@jakubednar jakubednar commented May 22, 2024

🔗 Linked issue

Resolves #27272, following up on #21585

📚 Description

Added support for this.$route in script in options API to ensure that within each suspense fork we have different route objects.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Copy Markdown
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

This looks great - thank you! ❤️

My only worry is that this might have a false positive - e.g. replacing this.$route in a blog post about vue-router. Maybe we could use strip-literal to handle this?

See example here:

const strippedCode = stripLiteral(code)
for (const match of strippedCode.matchAll(COMPOSABLE_RE_GLOBAL)) {
s.overwrite(match.index!, match.index! + match[0].length, `${match[1]} false && /*@__PURE__*/ ${match[2]}`)
}

@jakubednar
Copy link
Copy Markdown
Contributor Author

Should I use stripLiteral for both $route and this.$route or just this.$route ?

@RodrigoProjects
Copy link
Copy Markdown
Contributor

Should I use stripLiteral for both $route and this.$route or just this.$route ?

You lose nothing by doing it first thing after the Magic String creation so why not? Makes sense to me!

@jakubednar
Copy link
Copy Markdown
Contributor Author

Should I use stripLiteral for both $route and this.$route or just this.$route ?

You lose nothing by doing it first thing after the Magic String creation so why not? Makes sense to me!

I thought the same, so I implemented it for both cases 🙌

@danielroe danielroe changed the title feat: add support for this.route to wait for changes when changing url feat(nuxt): handle nuxt route injection for this.$route May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] Using this.$route inside a computed triggers reactivity while we are changing pages

3 participants