Skip to content
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

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

Jibbarth
Copy link

Hello 👋

I wanted that one of my package to be able to define an asset as entrypoint inside importmap.php to be allow call importmap('@mypackage/entry.js') inside a template of the package.

I made a naive modification, not sure if it was the purpose of the [symfony][entrypoints] node of the package.json.

Maybe it would be fit directly inside the [symfony][importmap] node.

WDYT ?

@Jibbarth
Copy link
Author

relate to symfony/symfony#53912

@@ -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 = [];
Copy link
Member

Choose a reason for hiding this comment

The 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 ?

Copy link
Author

Choose a reason for hiding this comment

The 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 levels but I can add it inside the following condition

@smnandre
Copy link
Member

Do we allow bundle to change the public/index.php file? Or to create new webpack configs ?

I really find weird that a bundle could install things like this. And a bit dangerous.

And still wait for a use case that require to create a entrypoint .... maybe you could describe yours for the package in question ? That really could help me understand the need.

@@ -147,7 +147,7 @@ private function resolveImportMapPackages($phpPackage): array
}

$dependencies = [];

$entrypoints = $packageJson->read()['symfony']['entrypoints'] ?? [];
Copy link
Member

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

Comment on lines 164 to 167
$dependencies[$importMapName] = [
'path' => $path,
'entrypoint' => \in_array($importMapName, $entrypoints, true),
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By definition, a dependency cannot be an importmap entrypoint :)

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.

2 participants