-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AssetMapper] Improve import statements extraction #54134
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR introduce a tiny JS parser responsible to split the code into distinct parts: * default (code) * comments * enclosed strings By parsing step by step, only analysing what's necessary in parallel of the preg_replace_callback, it may ease the Compiler choice to keep or not an import statement. This also allow us to use a lighter regexp, avoiding any JIT trouble. It was just a game/test at first, but as it seem to work really well, let's open the discussion :)
Friendly ping @weaverryan @nicolas-grekas ? It makes the import collection a lot "safer" to me... but there may be downsides i don"t see |
I like that but I'm wondering if we shouldn't put this on-hold (aka close for now) until we have a real need for that? Maybe the current regexp is good enough? |
@nicolas-grekas : works for me, it's there if we need it later :) |
smnandre
added a commit
to smnandre/symfony
that referenced
this pull request
Nov 26, 2024
Reopen of symfony#54134 after symfony#58944
smnandre
added a commit
to smnandre/symfony
that referenced
this pull request
Nov 27, 2024
Third attempt after symfony#54134 and symfony#58999.. this is the good one. I initially started this PR to learn / try things, but it really behaves well.. and _may_ stop (or help stopping) what seems to be a never-ending suite of special cases. Open to any feedback
smnandre
added a commit
to smnandre/symfony
that referenced
this pull request
Jan 19, 2025
Third attempt after symfony#54134 and symfony#58999.. this is the good one. I initially started this PR to learn / try things, but it really behaves well.. and _may_ stop (or help stopping) what seems to be a never-ending suite of special cases. Open to any feedback
fabpot
added a commit
that referenced
this pull request
Jan 25, 2025
…nandre) This PR was squashed before being merged into the 7.3 branch. Discussion ---------- [AssetMapper] Detect import with a sequence parser | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #58928 and #58944 (maybe) | License | MIT Third attempt after #54134 and #58999.. this is the good one 👍 I initially started this PR to learn / try things, but it really behaves well.. and _may_ stop (or help stopping) what seems to be a never-ending suite of special cases. Open to any feedback Commits ------- 720c387 [AssetMapper] Detect import with a sequence parser
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduce a tiny JS parser responsible to split the code into distinct parts:
By parsing step by step, only analysing what's necessary in parallel of the preg_replace_callback, it may ease the Compiler choice to keep or not an import statement.
This also allow us to use a lighter regexp, avoiding any JIT trouble.
It was just a game/test at first, but as it seem to work really well, let's open the discussion :)
(poke @nicolas-grekas @weaverryan)