[SOLVED] Development pub/sub working, code splitting not always working

I have modified my existing meteor app to use dynamic imports of blaze templates (.html, css, js) as a means of improving client startup times.

When running it in development mode, it is working fine, but if i access the dev-mode app through a local network, it does not load the dynamic modules. Is this expected?

I find it odd, as the dev-mode app is loading data through pub/sub in this same scenario.

What do you mean through the local network ? on what port your app is running onto ? Did you set the the ROOT_URL environment variable ?

my dev-mode app is running on, and is visible and runs from by visiting
and though pub/sub is working from, dynamic imports are not.

i should mention that the deployed app works fine, including dynamically loading blaze templates.

Try setting up the env variable ROOT_URL to

You should watch for the network section in your browser console (on a machine connected to your local network) to see what the import is trying to fetch. If ROOT_URL is not set, it may try to reach it on localhost instead of

the url is
“Meteor/dynamic-import/fetch” (dbl-underscores before and after Meteor)

the request fails

ROOT_URL is not set

and yes, it seems to be trying to get it from localhost.

So why does dynamic-import default to localhost, but pub/sub defaults to the original server?

because pub sub is going through a socket and is initiated by the server, not the client; import is an http request so it’s requested client side.
just set the ROOT_URL to your ip address, it should work as expected.

1 Like

Thanks for clarifying. I see a parallel between pub/sub (which I use a lot) and dynamic-import. Hopefully in the long run they will support hot module upgrading as well, which would make the parallel even more obvious.