Skip to content

[Doc] Add resolve condition names to UX Svelte documentation #1689

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

Conversation

kasperh90
Copy link

Q A
Bug fix? no
New feature? no
Issues -
License MIT

This PR will enhance the UX Svelte documentation. As of yet, some internal functionality will not work in Svelte unless you add browser and svelte to the conditionNames. I think it is valuable to mention this in the documentaiton.

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Apr 6, 2024
@@ -51,6 +51,19 @@ Next, install a package to help Svelte:
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
Svelte components.

To make internal functions work in Svelte, such as ``onMount``, ``onDestroy``, etc,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a link to the documentation you mention?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, sure! I got this link:
https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers

Should I add it to the documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes perfect!

Copy link
Author

Choose a reason for hiding this comment

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

Great. I will do it tomorrow. 👍

@@ -51,6 +51,19 @@ Next, install a package to help Svelte:
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
Svelte components.

To make internal functions work in Svelte, such as ``onMount``, ``onDestroy``, etc,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should mention those steps are needed when you want to use svelte 4? You don't have this kind of issue in version 3?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you are right. I will mention this.


// module.exports = Encore.getWebpackConfig();
const config = Encore.getWebpackConfig();
config.resolve.conditionNames = ['browser', 'svelte'];
Copy link
Contributor

Choose a reason for hiding this comment

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

In the documentation you send, they motion also an import item. Do you think we should added to?

conditionNames: ['svelte', 'browser', 'import']

Copy link
Author

Choose a reason for hiding this comment

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

Agree. I will add it too.

@@ -51,6 +51,19 @@ Next, install a package to help Svelte:
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
Svelte components.

To make internal functions work in Svelte, such as ``onMount``, ``onDestroy``, etc,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes perfect!

@kasperh90
Copy link
Author

kasperh90 commented Apr 8, 2024

@WebMamba I think we need to consider one more thing:

When I create a new Symfony app, install the UX Svelte bundle, install all the necessary NPM dependencies and type npm run watch in the terminal, I get the following warning:

image

That's how it came to my attentien that when you use Svelte 4, you will have to do a bit more configuration where you will have to add svelte and browser to conditionNames array. The warning in the terminal provides the following link: https://github.com/sveltejs/svelte-loader#resolveconditionnames

Should I add this too?

@WebMamba
Copy link
Contributor

WebMamba commented Apr 8, 2024

Hummm I think it's fine, the error message is really good. Just specify in the doc that this config is needed for svelte 4

@kasperh90 kasperh90 requested a review from WebMamba April 8, 2024 08:27
@javiereguiluz javiereguiluz added the docs Improvements or additions to documentation label Apr 9, 2024
@javiereguiluz javiereguiluz force-pushed the doc-ux-svelte-resolve-condition-names branch from 6e1a0c4 to 400deee Compare April 9, 2024 09:56
@javiereguiluz javiereguiluz merged commit 952c341 into symfony:2.x Apr 9, 2024
1 check passed
@javiereguiluz
Copy link
Member

Kasper, thanks for this nice contribution and for your patience during the review process (thanks also to Matheo for the nice review).

Your contribution was perfectly correct, but while merging I changed the code example to show a diff block (see 22a47f4). I think that way it's easier to know what to add/remove in the config file. Thanks!

@kasperh90
Copy link
Author

@javiereguiluz you are welcome! And using the diff block is brilliant. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants