-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(nuxt): don't add macro query to the end of id #5413
Conversation
β Deploy Preview for nuxt3-docs ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this 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' }) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
π Linked issue
Resolves vitejs/vite#3488
β Type of change
π Description
The query
lang.jsx
of id should be at the end of id, according to vitejs/vite-plugin-vue#23However
¯o=true
is added at the end so that thelang
query is not parsed expectedly in vite plugins.π Checklist