-
Notifications
You must be signed in to change notification settings - Fork 365
Support customers level template bundles #808
Support customers level template bundles #808
Conversation
…s/" template names
… use same validation as other templates (which now allow for alternate template bundles)
Hey @tshamz! Great PR! Was able to give it a test run, everything you proposed to fix is fixed and works great. This PR is good to merge. However, I found a few more holes our logic:
If you wish to expand this PR to fix those problems, that would be 💯. If you'd rather not, we can merge this and I'll create followup issues to tackle the additional changes. There have been a number of bugs associated to these snippets. They are super powerful and would really benefit from some tests to guarantee stability. Again, not needed for this PR but I can create a separate issue. |
…dapts same logic in script-tags.html to style-tags.html
I figured number 1 was gonna be a problem at the time. I think underscore templates are a nightmare to read and I had already been working for a while when I ran into this so I didn't really have the mental capacity to try and decipher what was going. I added a fix for this and copied the same logic over to the |
@tshamz awesome! I'll give this a test run and we can merge it as is. |
Gave it a test. Looks solid. Awesome contribution! Thanks @tshamz No worries about the tests. Something we can chip away at over time. |
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. |
What are you trying to accomplish with this PR?
After allowing alternate template bundles in beta.8, the liquid logic included in
script-tags.liquid
snippet to check which bundles to load and which bundles to prefetch, was updated to usetemplate
fromtemplate.name
. This creates a problem for any template that's included in thecustomers/
directory because the value that's used to create the template name in the liquid logic is taken from the chunk inside the webpack plugin. This is a problem because bundles/entry points inside thecustomers/
directory are flattened down to the same level as the other files, which produces files like this:Those file names are used to create the blocks inside of
script-tags.liquid
. This used to be ok before because if you were on acustomers/
template e.g. login.liquid,{{ template.name }}
would produce 'login', but now since switching to{{ template }}
the output has changed to 'customers/login'. The resulting output looks like this:The problem here is that
template == 'login'
will never evaluate to true, so this bundle will never get loaded. This pull requests alters thescript-tags.html
template to check if the chunk includescustomers/
in its path, and if it does, prependscustomers/
to the template check inside of the liquid logic.Additionally, after poking around a bit, I noticed that bundles for alternate templates in the
customers/
directory weren't being loaded in due to a conditional inside ofget-template-entrypoints.js
. Templates not insidecustomers/
are getting run through a newisValidTemplate
function, but thecustomers/
templates are not. As a result, any alternatecustomers/
template is not being seen as valid, and thus not being included. This pull request updatesget-template-entrypoints.js
to replace the old valid template check withisValidTemplate
that allows alternate templates to pass through.Please provide a link to the associated GitHub issue.
#806
Checklist
For contributors:
For maintainers: