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

ES-Module Plugin cant be loaded * #3097

Closed
mhsdesign opened this issue Apr 5, 2022 · 3 comments
Closed

ES-Module Plugin cant be loaded * #3097

mhsdesign opened this issue Apr 5, 2022 · 3 comments

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Apr 5, 2022

* unless brute forced via AOP in StyleAndJavascriptInclusionService

Description

Imagine you have a nice ESM Plugin and try to inject it via:

Neos.Neos.Ui.resources.javascript.'My.EsmPlugin':
  resource: 'foo/bar.js'

now we get an error about import cannot be used because the script tag doesnt tell its an esm.

the problem is, that no attributes for the script tag are allowed except defer

Neos.Neos.Ui.resources.javascript.'My.EsmPlugin':
  resource: 'foo/bar.js'
  defer: true # works
  type: 'module' # doesnt work

Steps to Reproduce

write
Neos.Neos.Ui.resources.javascript.'My.Plugin'.type: 'module'

Expected behavior

a script tag with <script type="module"> is rendered analog to the defer option

Actual behavior

the option is ignored

Affected Versions

UI: since ever

Solution

we would need to not only look out for the defer key but also for the key type

$defer = key_exists('defer', $element) && $element['defer'] ? 'defer ' : '';

also we could consider having an actual future proof attributes array which will be just rendered like in Neos.Fusion:Tag
i implemented this in https://github.com/mhsdesign/MhsDesign.ProposalNeosUiEsmPluginLoader

@mhsdesign mhsdesign changed the title ES-Module Plugin cant be loaded \* ES-Module Plugin cant be loaded * Apr 5, 2022
@mhsdesign
Copy link
Member Author

Fair enough if you ask, where did you forge an es module neos ui plugin? Via esbuild.
https://github.com/mhsdesign/esbuild-neos-ui-extensibility

@mhsdesign
Copy link
Member Author

@mhsdesign
Copy link
Member Author

I would rather suggest to use native esm dynamic imports (supported with es2020 and neos 8.2 with esbuild 🎉)

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

No branches or pull requests

1 participant