Closed nboliver closed 5 years ago
Good news! This appears to be related to a bug in external package's webpack config, not Slate's. Closing issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Problem
When using the template script bundle feature, there are inconsistencies with how code runs compared to using a single bundle (everything in layout/theme.js).
Replication steps
An imported npm package triggers a jquery event on the window. The theme adds an event listener for this event. Using a template bundle (templates/product.js) to init the code that adds the listener results in the callback not firing. Other code from the package still works fine though (ie. the line immediately before the call to
trigger
is working as expected).However, if the
layout/theme.js
bundle is instead used to init the code that adds the listener (no differences besides the file where the object is constructed), everything works as expected.Interestingly, manually copying the package's dist into the theme src and then using that instead of the node_modules version also works without issue, so I don't think it's a listener timing issue, unless the bundler treats local imports differently from external packages somehow.
More Information
Since I was able to narrow the problem down to using a template bundle vs the global layout bundle, I'm thinking it's a quirk with the bundling system that is causing this issue.