-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
upgrading for v3 to v4 - onMount is not fired anymore #8953
Comments
Please provide a proper reproduction. |
I reproduce a small example to better understand what might cause this
I compile Test.svelte using this code and write it to Test.js file
Then I use rollupjs to bundle main.js and Test.js and resolve plugin to manage node_modules imports (in this case onMount)
This will produce an out.js file
putting the js file in a html file will mount the component to document.body ( text is visible) but onMount is not fired. (no message is printed on console). |
I found what was the problem: The proper way to import onMount in 4 is Not sure if this is a bug or not, or if it's a bundler problem. If it's not a bug then you should update the documentation https://svelte.dev/docs/svelte#onmount Hope this helps |
Do not import from I believe vite does this automatically for the client build and for @rollup/plugin-node-resolve there is a exportConditions option. I don't think we actually documented how to do the configuration in the migration guide which we probably should. @catapop84 let us know if |
There's a |
Thanks @gtm-nayan . using |
#8953 / #8961 --------- Co-authored-by: Simon H <[email protected]>
sveltejs#8953 / sveltejs#8961 --------- Co-authored-by: Simon H <[email protected]>
sveltejs#8953 / sveltejs#8961 --------- Co-authored-by: Simon H <[email protected]>
For those who use webpack, module.exports = {
// ...
resolve: {
extensions: ['.mjs', '.js', '.svelte'],
mainFields: ['svelte', 'browser', 'module', 'main'],
conditionNames: ['svelte', 'browser']
},
// ...
} |
Describe the bug
In v3 onMount works. upgrading to v4 onMount or any other lifecycle is not fired.
Any reason for this?
We use svelte compiler to compile the component
no error is thrown.
The component is rendered correctly
Reproduction
just upgraded from v3 to v4
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
#UPDATE: found the problem
check: #8953 (comment)
The text was updated successfully, but these errors were encountered: