Skip to content

[AssetMapper] Javascript sequence parser #58999

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
wants to merge 3 commits into from

Conversation

smnandre
Copy link
Member

Q A
Branch? 7.2 for features
Bug fix? yes
New feature? yes/
Deprecations? yes
Issues Fix #...
License MIT

Reopen of #54134 after #58944

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 :)

# Conflicts:
#	src/Symfony/Component/AssetMapper/Compiler/JavaScriptImportPathCompiler.php
@carsonbot
Copy link

Hey!

To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done?

Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review.

Cheers!

Carsonbot

@tacman
Copy link
Contributor

tacman commented Nov 26, 2024

I'm traveling for the Thanksgiving holiday, but I'll try to take a look. Thanks.

@carsonbot carsonbot closed this Nov 26, 2024
@smnandre
Copy link
Member Author

Carson is not joking with the rules... sorry :(

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants