Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[AssetMapper] Revert "Fix JavaScript compiler load imports from JS strings"#54012

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@nicolas-grekas
Copy link
Member

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
Issues-
LicenseMIT

This reverts commit4fe7828, reversing changes made toad1563b.

Reverts#53652 because it breaks loading app.css on a webapp skeleton.
There are two reasons for this:

  1. the string regexp generates a JIT stack overflow - this can be fixed by making the internal pattern greedy
  2. but then it still fails because app.js usesimport './styles/app.css' and this is matched by the "quoted strings" subpart of the current pattern and thus ignored by the "import" subpart.

I don't know how this would be fixed using the regexp only so I'm proposing to revert so that we can consider this before the next release.

/cc@smnandre and@weaverryan

I'm wondering what's the plan on this topic? Couldn't the CDN we use provide some API endpoint that'd prevent us from parsing any JS? Is there any effort ongoing on the topic? Alternatively, shouldn't we switch to a regexp-less parser? (a small state machine that'd be able to split apart comments, strings and code)?

…imports from JS strings (smnandre)"This reverts commit4fe7828, reversingchanges made toad1563b.
@weaverryan
Copy link
Member

Dang :/

Couldn't the CDN we use provide some API endpoint that'd prevent us from parsing any JS? Is there any effort ongoing on the topic?

I think you may be mixing this up with the other spot inJsDelivrEsmResolver where we parse the code from the CDN. Here's the issue about that -jsdelivr/jsdelivr#18538 - no public movement. But as they will ultimately give us a finite number of import synaxes, I believe that situation is solveable with regex.

Alternatively, shouldn't we switch to a regexp-less parser? (a small state machine that'd be able to split apart comments, strings and code)?

In this situation, we're dealing with userland code, which could look like anything. This was always going to be tricky to do perfectly without actually parsing the JS... my hope was to get it 99.5% correct (which I think we have). For that last 0.5%, I'm not sure. Can we make something to get to 99.999%? Or do we need to provide an "escape hatch" where the user can define special situations where over-matchingimport statements (e.g. because they are inside aconsole.log('import ...')) that should be ignored?

nicolas-grekas reacted with thumbs up emoji

@smnandre
Copy link
Member

This could fix the regexp:

https://regex101.com/r/jtTZUA/1

(not handling multi-line enquoted string ... as that does not exist in JS)

@smnandre
Copy link
Member

smnandre commentedFeb 20, 2024
edited
Loading

Alternative: i opened#54014 (should fix this bug)

@nicolas-grekas
Copy link
MemberAuthor

Closing in favor of#54014 then :)

@nicolas-grekasnicolas-grekas deleted the am-revert branchFebruary 20, 2024 18:10
fabpot added a commit that referenced this pull requestFeb 21, 2024
This PR was squashed before being merged into the 6.4 branch.Discussion----------[AssetMapper] Fix enquoted string pattern| Q             | A| ------------- | ---| Branch?       | 6.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Issues        |Fix#54012| License       | MITAlternative to#54012 (fixes the bug and avoid a revert that will reintroduce other previous bugs / missmatches)+ add a test to check things work as expected with the standard `app.js` filecc `@weaverryan` `@nicolas`-grekasCommits-------df618bd [AssetMapper] Fix enquoted string pattern
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

6.4

Development

Successfully merging this pull request may close these issues.

4 participants

@nicolas-grekas@weaverryan@smnandre@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp