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): handle nuxt route injection for this.$route #27313

Merged

Conversation

jakubednar
Copy link
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.

Copy link

stackblitz bot commented May 22, 2024

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

Copy link
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
Contributor Author

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

@RodrigoProjects
Copy link
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
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