Dynamic Import not working when running `yarn build`, but does with `yarn dev`


I have a clean Sage 10 install.
On /wp-content/themes/sage10/resources/scripts/app.js I have a dynamic import import('./test'). When I run yarn dev and check localhost:3000, the test.js module imports just fine.

However, when I run yarn build and check the site. I get the following 404 error:

Uncaught (in promise) ChunkLoadError: Loading chunk 5 failed. (error: http://mytestsite.local/5.396f8b.js)

It looks like the module’s path is defaulting to the root folder, rather than the theme’s public directory. The path should be: http://mytestsite.local/wp-content/themes/sage10/public/5.396f8b.js

Is there a bud configuration to fix this? I have only changed the proxy value in bud.config.js. Am I missing something else?

Any help would be appreciated, thanks!

I am having the same issue. Any chunks generated by yarn build have a module path of the current page URL rather than the theme directory. I tried to use setPublicPath which affects the primary js file but doesn’t do anything to the URL of the chunk.


Hey friends, I have been looking into this and am hopeful the next tagged bud release will have it sorted out. Thank you!


This topic was automatically closed after 42 days. New replies are no longer allowed.