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

perf(vite): use compiled regexp for test #18646

Merged
merged 2 commits into from
Jan 31, 2023
Merged

perf(vite): use compiled regexp for test #18646

merged 2 commits into from
Jan 31, 2023

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

#18642 (comment)

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This uses a regexp for a single iteration of the codebase, and also protects non Vue/JS assets from being transformed

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Jan 31, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

export function runtimePathsPlugin (options: RuntimePathsOptions): Plugin {
return {
name: 'nuxt:runtime-paths-dep',
enforce: 'post',
transform (code, id) {
if (code.includes('__VITE_ASSET__') || code.includes('__VITE_PUBLIC_ASSET__')) {
const { pathname, search } = parseURL(decodeURIComponent(pathToFileURL(id).href))
Copy link
Member

Choose a reason for hiding this comment

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

Another tiny perf: While at at moment this doesn't make a different with current version of UFO, since search is a getter computer on native URL, once we migrate to URL for parsing, search is not needed unless pathname check passes. In this case, not destructuring can benefit.

@danielroe danielroe merged commit d1a79a9 into main Jan 31, 2023
@danielroe danielroe deleted the perf/re branch January 31, 2023 16:38
@danielroe danielroe mentioned this pull request Feb 1, 2023
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.

None yet

2 participants