-
-
Notifications
You must be signed in to change notification settings - Fork 636
Generalize wildcard pattern replacement to work with any dot pattern, not just import.meta #13263
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
Conversation
@camc314 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Co-authored-by: camc314 <[email protected]>
Co-authored-by: camc314 <[email protected]>
Co-authored-by: camc314 <[email protected]>
Co-authored-by: camc314 <[email protected]>
define: { 'import.meta.env.*': 'undefined' }
replaces import.meta.env.n.e.s.t.e.d
as void 0
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.
@copilot this shouldn't be specific to import.meta
e.g. if i supply foo.bar.*
to be replaced with undefined
, given foo.bar.baz.que
it should be replaced with (undefined).baz.que
…mport.meta Co-authored-by: camc314 <[email protected]>
You're absolutely right! I've now generalized the wildcard functionality to work with any dot pattern, not just The implementation now supports patterns like Key changes made (commit 1d7f97d):
The fix maintains all existing behavior while extending wildcard support to any dot pattern. |
Originally, wildcard patterns like
import.meta.env.*
were restricted to only work withimport.meta
patterns. This PR generalizes the wildcard functionality to work with any dot pattern.Problem
The transformer only allowed wildcard patterns for
import.meta.*
configurations, but users need the same functionality for other patterns. For example:Solution
Generalized the wildcard pattern matching to work with any dot pattern by:
check_key
function to allow wildcards for any patternDotDefine
struct withpostfix_wildcard
fieldis_dot_define
and replacement functionsExamples
Now supports patterns like:
The same intelligent partial replacement logic applies:
import.meta.*
patternsFixes the limitation mentioned in #13262 comments.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.