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

History is undefined server-side if compiled with generate: 'ssr' #2

Closed
dschulten opened this issue Dec 23, 2017 · 2 comments
Closed

Comments

@dschulten
Copy link

The example uses on-the-fly compilation with require( 'svelte/ssr/register' );. When the build is changed to use generate: 'ssr', the history instance in the component is undefined, although server.js creates it.

Stacktrace
TypeError: Cannot read property 'location' of undefined
    at data (D:\Dokumente\ws\microfrontends\cart\dist\ssr\bundle.js:512:23)
    at Object._399‍.r.Route._render (D:\Dokumente\ws\microfrontends\cart\dist\ssr\bundle.js:555:24)
    at Object._399‍.r.App._render (D:\Dokumente\ws\microfrontends\cart\dist\ssr\bundle.js:1058:40)
    at Object._399‍.r.App.render (D:\Dokumente\ws\microfrontends\cart\dist\ssr\bundle.js:1039:17)
    at D:\Dokumente\ws\microfrontends\cart\server.js:12:26
    at Layer.handle [as handle_request] (D:\Dokumente\ws\microfrontends\cart\node_modules\express\lib\router\layer.js:95:5)
    at next (D:\Dokumente\ws\microfrontends\cart\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (D:\Dokumente\ws\microfrontends\cart\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (D:\Dokumente\ws\microfrontends\cart\node_modules\express\lib\router\layer.js:95:5)
    at D:\Dokumente\ws\microfrontends\cart\node_modules\express\lib\router\index.js:281:22

I cannot easily switch to on-the-fly compilation because of sveltejs/svelte#967.

There is no workaround ATM.

@EmilTholin
Copy link
Owner

Hi @dschulten! Thank you for reporting this. I will look into it and see if it can be fixed on Monday.

dschulten added a commit to escalon/microfrontends that referenced this issue Jan 4, 2018
dockerized cart
made svelte/store.js external so that it is not bundled with cjs but bundled with iife
@EmilTholin
Copy link
Owner

EmilTholin commented May 9, 2019

Sorry for the extremely slow feedback on this, but it was simply not possible to solve this in the previous version.

With 1.0.0 there is no longer a dependency on the history library, so the server code can be completely bundled at compile time. You can then pass down the url to the component and pass it to the url prop of the Router to force the application to that url.

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

2 participants