slate icon indicating copy to clipboard operation
slate copied to clipboard

files processed with get-chunk-name truncation fail to upload

Open mtshane opened this issue 7 years ago • 11 comments

Problem

@shopify/slate-tools/tools/webpack/get-chunk-name.js handles filenames that are too long and truncates them with a tilde ~, but the upload fails to push the file stating that it contains invalid characters

Replication steps

yarn deploy a project that creates a long vendor@ chunk and truncates the filename during build.

More Information

Changing to the following (hyphen) resolved the issue for us. We also reduced the name slice to 220 chars, as we still hit an ENAMETOOLONG error even with the original length.

if (name.length > 256) { name = ${name.slice(0, 220)}-${hashFilename(name)}; }

mtshane avatar Dec 04 '18 18:12 mtshane

I anticipated this... was hoping developers wouldn't encounter it. Thanks for resurfacing it!

t-kelly avatar Dec 05 '18 15:12 t-kelly

Is there any danger of using the above implementation to make the name shorter?

ghost avatar Dec 20 '18 01:12 ghost

@george-dotdev right now, I'm using the file name to determine what pages the chunk/bundle should be loaded on with script-tags.html and style-tags.html. If we change the naming convention, we'll need to change these files as well.

t-kelly avatar Dec 20 '18 20:12 t-kelly

The names in my theme look like this:

  template.register (783 KiB)
      [email protected]
      [email protected]@[email protected]@[email protected]@[email protected]@[email protected]
      template.register.js

Why are all the other templates listed underneath the template register? Is that the expected behaviour?

ghost avatar Jan 03 '19 07:01 ghost

@t-kelly thoughts on moving these into something like theme.globals.* and include on all pages? It's a quick solution that would simplify bundles and fix this issue...

dotdev-brendon avatar Jan 03 '19 10:01 dotdev-brendon

@b0123498765 theme.globals.* is the equivalent of layout.theme.js (assuming you're using the layouts/theme.liquid for your theme.

t-kelly avatar Jan 03 '19 14:01 t-kelly

@t-kelly what about the other bundles as some of these seem to include all templates?

E.g. [email protected]@[email protected]@[email protected]@[email protected]@[email protected]

dotdev-brendon avatar Jan 04 '19 05:01 dotdev-brendon

@b0123498765 that is the result of importing a dependency in each of the template entry point files in src/scripts/templates/*. e.g. adding import $ from 'jquery' in each template entry will result in jquery being thrown into a shared chunk named like what you mention above.

Just to confirm, I totally agree the naming convention could be reworked to be shorter -- could be done with a simple mapping object..

t-kelly avatar Jan 04 '19 15:01 t-kelly

@t-kelly i've encountered this bug too, will have to rethink my code execution to avoid creating too many entry points.

JPrisk avatar Jan 21 '19 00:01 JPrisk

@t-kelly Any chance a fix for this might be in the works, or even some direction on how to resolve it locally for a project? It seems like with the truncation, some of our pages work, and some don't.. I'm assuming that js file just isn't being loaded on the pages where their template name is truncated off the filename?

mtshane avatar Feb 05 '19 16:02 mtshane

@mtshane @JPrisk @b0123498765 Did you manage to implement any fix for this?

agustinbranaf avatar Apr 08 '20 19:04 agustinbranaf