-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
[AssetMapper] Allow to define entrypoint in importmap.php #1026
base: 2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,7 @@ private function resolveImportMapPackages($phpPackage): array | |
} | ||
|
||
$dependencies = []; | ||
|
||
$entrypoints = $packageJson->read()['symfony']['entrypoints'] ?? []; | ||
foreach ($packageJson->read()['symfony']['importmap'] ?? [] as $importMapName => $constraintConfig) { | ||
if (\is_array($constraintConfig)) { | ||
$constraint = $constraintConfig['version'] ?? []; | ||
|
@@ -163,6 +163,7 @@ private function resolveImportMapPackages($phpPackage): array | |
|
||
$dependencies[$importMapName] = [ | ||
'path' => $path, | ||
'entrypoint' => \in_array($importMapName, $entrypoints, true), | ||
]; | ||
Comment on lines
164
to
167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By definition, a dependency cannot be an importmap entrypoint :) |
||
|
||
continue; | ||
|
@@ -239,7 +240,7 @@ private function shouldUpdateConstraint(string $existingConstraint, string $cons | |
} | ||
|
||
/** | ||
* @param array<string, array{path?: string, package?: string, version?: string}> $importMapEntries | ||
* @param array<string, array{path?: string, package?: string, version?: string, entrypoint?: bool}> $importMapEntries | ||
*/ | ||
private function updateImportMap(array $importMapEntries): void | ||
{ | ||
|
@@ -267,8 +268,14 @@ private function updateImportMap(array $importMapEntries): void | |
$this->io->writeError(sprintf('Updating package <comment>%s</> from <info>%s</> to <info>%s</>.', $name, $version, $versionConstraint)); | ||
} | ||
|
||
$arguments = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A package with version cannot be an entrypoint... so entrypoints should not be concerned here, no ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, i see what you mean. If i remember correctly, it was to avoid too many |
||
if (isset($importMapEntry['entrypoint']) && true === $importMapEntry['entrypoint']) { | ||
$arguments[] = '--entrypoint'; | ||
} | ||
|
||
if (isset($importMapEntry['path'])) { | ||
$arguments = [$name, '--path='.$importMapEntry['path']]; | ||
$arguments[] = $name; | ||
$arguments[] = '--path='.$importMapEntry['path']; | ||
$this->scriptExecutor->execute( | ||
'symfony-cmd', | ||
'importmap:require', | ||
|
@@ -283,7 +290,7 @@ private function updateImportMap(array $importMapEntries): void | |
if ($importMapEntry['package'] !== $name) { | ||
$packageName .= '='.$name; | ||
} | ||
$arguments = [$packageName]; | ||
$arguments[] = $packageName; | ||
$this->scriptExecutor->execute( | ||
'symfony-cmd', | ||
'importmap:require', | ||
|
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.
Took some time to refresh my memory and re-read all this code 😅
So .. nope : this is not related to importmap entrypoints, but to stimulus bundle + controllers.json file. Thus should not be used here :)
Should not be used here