Skip to content

fix: preact compat #762

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

Merged
merged 1 commit into from
May 2, 2022
Merged

fix: preact compat #762

merged 1 commit into from
May 2, 2022

Conversation

Grafikart
Copy link
Contributor

With the realease of the version 10 of preact, preact compat was migrated inside preact library removing the need for preact-compat.

https://preactjs.com/guide/v10/switching-to-preact/

@weaverryan
Copy link
Member

Thanks for this @Grafikart! One test is failing, with an easy failure.

But I'm a little concerned: this would mean now that Encore only works with preact 10, correct? If so, then we need to update the devDependency for Preact to version 10 - the tests are currently using version 8. And that makes me wonder something else: if you've updated the code for preact 10, but the tests are using version 8, why aren't more significant tests failing? It makes me wonder if the preact functional test - which builds this directory https://github.com/symfony/webpack-encore/tree/master/fixtures/preact - is not "good enough". In theory, that test should be failing right now because of your patch but because the tests are still using Preact 8 right?

Cheers!

@Lyrkan
Copy link
Collaborator

Lyrkan commented May 9, 2020

if you've updated the code for preact 10, but the tests are using version 8, why aren't more significant tests failing?

I don't think we've functional tests using preact-compat (which is a compatibility layer to use "real" React libraries from your preact app), the one you linked directly uses preact. I guess we could add some but it could be a bit tricky to know they are working properly since we also have react/react-dom in our dev dependencies.

I agree that we should bump the version in our dev dependencies though: if we don't people will be asked to install v8 and then get the wrong aliases for preact-compat if they enable that feature.

@Grafikart
Copy link
Contributor Author

this would mean now that Encore only works with preact 10, correct?

You are correct. I want input on how you want to handle this situation. We could parse the user package.json (hard way) or we could add a new option within enablePreactPreset.

enablePreactPreset({preactCompat: 10})

In my opinion the build should target the currentVersion. If someone chooses to work with an older version he can setup the aliases manually.

@weaverryan
Copy link
Member

I would say that we should either:

A) Only allow version 10 (I have no idea if 8 & 9 have LTS or something like that - I'm not familiar with preact)

B) Allow 8 or 10 and check their installed version to choose which alias to add. We do something similar for Vue 3 in #746. In that, we also have an option to force v2 or v3, but I did that mostly because v2 will be around for an LTS for a long time and because Vue is such a widely-used library.

Btw, my preference would be to only support 10. But if, for some reason, many people will continue to use 8 for a long time, then we could allow both.

@Rodrigo001-dev

This comment has been minimized.

@weaverryan weaverryan changed the base branch from master to main November 18, 2020 18:19
@weaverryan weaverryan added this to the Encore 2.0 milestone Apr 22, 2022
@weaverryan
Copy link
Member

Thank you @Grafikart!

@weaverryan weaverryan merged commit b33cceb into symfony:main May 2, 2022
weaverryan added a commit that referenced this pull request May 3, 2022
This PR was merged into the main branch.

Discussion
----------

Tidying up fixes for preact

Fixes up tests for #762

Commits
-------

b74f1db tidying up fixes for preact
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.

4 participants