Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): don't add macro query to the end of id #5413

Merged
merged 2 commits into from
Jun 12, 2022

Conversation

dotoleeoak
Copy link
Contributor

πŸ”— Linked issue

Resolves vitejs/vite#3488

❓ 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

The query lang.jsx of id should be at the end of id, according to vitejs/vite-plugin-vue#23
However &macro=true is added at the end so that the lang query is not parsed expectedly in vite plugins.

πŸ“ Checklist

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

@netlify
Copy link

netlify bot commented Jun 11, 2022

βœ… Deploy Preview for nuxt3-docs ready!

Name Link
πŸ”¨ Latest commit 4f4addc
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/62a65e97010eed000947ea8f
😎 Deploy Preview https://deploy-preview-5413--nuxt3-docs.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

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.

As a workaround, this seems good to me, but also see https://github.com/vitejs/vite/issues/8473#issuecomment-1152880131.

@@ -46,7 +46,8 @@ export const TransformMacroPlugin = createUnplugin((options: TransformMacroPlugi
// with workaround for vue-loader bug: https://github.com/vuejs/vue-loader/pull/1911
const scriptImport = findStaticImports(code).find(i => parseQuery(i.specifier.replace('?macro=true', '')).type === 'script')
if (scriptImport) {
const specifier = withQuery(scriptImport.specifier.replace('?macro=true', ''), { macro: 'true' })
Copy link
Member

Choose a reason for hiding this comment

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

withQuery doesn't changes the order by default if we didn't first remove ?macro=true. /cc @danielroe Was there any reason you used replaced initially?

image

Copy link
Member

Choose a reason for hiding this comment

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

Ah, very good point. It was to work around another vite issue, where any existing query was not respected. (So id that vite produced was something like ?macro=true?lang=test.jsx.)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for explaining. Does the issue exists anymore?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see I was wrong - it was a vue-loader bug: vuejs/vue-loader#1911 which still exists with an open PR to fix it. I'll need to check that this PR doesn't introduce a regression with webpack.

@pi0 pi0 merged commit 95b38e2 into nuxt:main Jun 12, 2022
@pi0 pi0 mentioned this pull request Jun 12, 2022
@dotoleeoak dotoleeoak deleted the fix/script-tsx-in-pages branch June 13, 2022 03:57
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants