Skip to content

Commit 7096a1e

Browse files
committed
bug symfony#52617 [AssetMapper] Fix resolving jsdeliver default + other exports from modules (ogizanagi)
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Fix resolving jsdeliver default + other exports from modules | Q | A | ------------- | --- | Branch? | 6.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix symfony#52616 | License | MIT Fixes resolving: ```js import i,{Headers as a}from"/npm/`@supabase`/node-fetch@2.6.14/+esm" ``` i.e both default export and other exports in a same `import`. Commits ------- 916daf0 [AssetMapper] Fix resolving jsdeliver default + other exports from modules
2 parents 1386c95 + 916daf0 commit 7096a1e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Symfony/Component/AssetMapper/ImportMap/Resolver/JsDelivrEsmResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class JsDelivrEsmResolver implements PackageResolverInterface
2828
public const URL_PATTERN_DIST = self::URL_PATTERN_DIST_CSS.'/+esm';
2929
public const URL_PATTERN_ENTRYPOINT = 'https://data.jsdelivr.com/v1/packages/npm/%s@%s/entrypoints';
3030

31-
public const IMPORT_REGEX = '#(?:import\s*(?:(?:\{[^}]*\}|\w+|\*\s*as\s+\w+)\s*\bfrom\s*)?|export\s*(?:\{[^}]*\}|\*)\s*from\s*)("/npm/((?:@[^/]+/)?[^@]+?)(?:@([^/]+))?((?:/[^/]+)*?)/\+esm")#';
31+
public const IMPORT_REGEX = '#(?:import\s*(?:\w+,)?(?:(?:\{[^}]*\}|\w+|\*\s*as\s+\w+)\s*\bfrom\s*)?|export\s*(?:\{[^}]*\}|\*)\s*from\s*)("/npm/((?:@[^/]+/)?[^@]+?)(?:@([^/]+))?((?:/[^/]+)*?)/\+esm")#';
3232

3333
private HttpClientInterface $httpClient;
3434

src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,12 @@ public function testImportRegex(string $subject, array $expectedPackages)
610610
public static function provideImportRegex(): iterable
611611
{
612612
yield 'standard import format' => [
613-
'import{Color as t}from"/npm/@kurkle/color@0.3.2/+esm";import t from"/npm/jquery@3.7.0/+esm";import e from"/npm/popper.js@1.16.1/+esm";console.log("yo");',
613+
'import{Color as t}from"/npm/@kurkle/color@0.3.2/+esm";import t from"/npm/jquery@3.7.0/+esm";import e from"/npm/popper.js@1.16.1/+esm";console.log("yo");import i,{Headers as a}from"/npm/@supabase/node-fetch@2.6.14/+esm";',
614614
[
615615
['@kurkle/color', '0.3.2'],
616616
['jquery', '3.7.0'],
617617
['popper.js', '1.16.1'],
618+
['@supabase/node-fetch', '2.6.14'],
618619
],
619620
];
620621

0 commit comments

Comments
 (0)