-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
fix: asset new URL(,import.meta.url)
match
#18194
fix: asset new URL(,import.meta.url)
match
#18194
Conversation
Run & review this pull request in StackBlitz Codeflow. |
expect( | ||
await transform('new URL(`./foo/${dir}.js`, import.meta.url)'), | ||
).toMatchInlineSnapshot( | ||
`"new URL((import.meta.glob("./foo/**/*.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}.js\`], import.meta.url)"`, |
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.
Before this PR, this was ./foo/**.js
.
expect( | ||
await transform('new URL(`./foo/${dir}${file}.js`, import.meta.url)'), | ||
).toMatchInlineSnapshot( | ||
`"new URL((import.meta.glob("./foo/**/*.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}\${file}.js\`], import.meta.url)"`, |
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.
Before this PR, this was ./foo/****.js
.
'new URL(`./foo/${dir}${dir2}/index.js`, import.meta.url)', | ||
), | ||
).toMatchInlineSnapshot( | ||
`"new URL((import.meta.glob("./foo/**/index.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}\${dir2}/index.js\`], import.meta.url)"`, |
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.
Before this PR, this was ./foo/****/index.js
.
new URL(,import.meta.url
matchnew URL(,import.meta.url)
match
Is it intended for |
I made it match with nested files as I thought that was the intention of the original code. But I'm fine with making it only matching non-nested files. |
I'm not sure about the history, but matching only non-nested makes more sense to me as I assume that aligns closer with dynamic import var and also it's less likely to break existing usages. |
I've updated to use |
The test was failing because of a different reason (It was not caused by the |
Description
Glob generated from
new URL(, import.meta.url)
was wrong.For example,
new URL(`./foo/${foo}.js`)
was tranformed into./foo/**.js
and this glob does not match./foo/bar/baz.js
and only matches JS files in foo directory.These are the examples of how some glob matches:
https://stackblitz.com/edit/node-b5czun?file=index.js