scaife-viewer / readhomer

in-progress flagship demo project for the Scaife Viewer ecosystem
3 stars 2 forks source link

Fix global component loading in production builds. #33

Closed rillian closed 5 years ago

rillian commented 5 years ago

Instead of maintaining an index.js which re-exports all the vue.js modules in the global-components directory, use webpack's require.context loader to iterate over all the contained files and register the components from there.

The previous method constructed component names from the __file property of the module objects, but this is only available in debug builds and so the site failed to load when deployed.

Closes #32. Based on this example from the vue.js guild.

rillian commented 5 years ago

Looks like the test deployment works.

jacobwegner commented 5 years ago

Thanks for the PR, @rillian. I'm pulling @paltman in here for a review.

@paltman, it looks like we had a regression in b393184d9a11fd0463223f19782860ef671c56e8 after my previous fix for this issue in 16f106527bef04893ecfbd94b64808f5fdd323e1.

I like @rillian's implementation better. I think the only other thing we might want to keep in mind is ensuring that each module within global-components always defines a default export, but I like the idea of dropping the explicit registry in global-components/index.js.

paltman commented 5 years ago

I'd prefer the solution in 16f106527bef04893ecfbd94b64808f5fdd323e1 so we can be explicit about what's loading at out of that directory. But also know that the latest skeleton doesn't even have the notion of global-components anymore.

rillian commented 5 years ago

Thanks for commenting. I've restored @jacobwegner's solution with the explicit index.js.

But also know that the latest skeleton doesn't even have the notion of global-components anymore.

It would still be helpful to have a master branch which is deployable.

jacobwegner commented 5 years ago

(Pulling this in so we have something working deployed to Netlify)

rillian commented 5 years ago

Thanks for merging!