Toaster inlined twice
Closed this issue · 2 comments
I've noticed that Toaster.js module is bundled (inlined) twice during the build - in audio-processor.html and in guitartuner-core.js. I understand it's not important for this app, however it's a showcase for Polymer-based apps in general. Do you think it makes sense to move all shared modules across the bundles into a separate file?
@antonmoiseev Ah, this is because of Babel and requires, which is admittedly a pain in this case. It only creates on instance of Toaster, but you're right that the actual Toaster code will exist twice. In this instance it's probably too big a hassle to work around it, and I suspect would make the code less readable.
I'm using factor-bundle browserify plugin to move all shared dependencies into a separate common.js module. The source code of the app remains the same, however the build script indeed becomes a little bit more complicated - a new file is generated and you need to decide how to deliver it to the page. I usually simply concatenate it with main.js (guitartuner-core.js in your case) since it usually doesn't make sense to start the app without common.js. But it's flexible and up to the app.