Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide component path in componentChunkName #18791

d4rekanguok opened this issue Oct 18, 2019 · 2 comments


Copy link

@d4rekanguok d4rekanguok commented Oct 18, 2019


Currently, the component path is exposed publicly via window.___chunkMapping:


"component---src-pages-blog-tags-js": [ "/component---src-pages-blog-tags-js-f81e0bfcd17d0da590e9.js" ]
"component---src-pages-contributing-events-js": [ "/component---src-pages-contributing-events-js-1c105d1d9312ff38c747.js" ]

I recently saw this SO question link & I think it's reasonable to hide these path, maybe only in production build.

Upon a bit of search, I found that the code here is responsible for generating:

const name = path.relative(directory, componentPath)
return `component---${kebabCase(name)}`

I tested my idea with uuidv5:

  const NAMESPACE = `c8e9d964-7090-46ef-a1ed-8311a822b0e7`

  return process.env.NODE_ENV === `production`
    ? `component---${uuidv5(name, NAMESPACE)}`
    : `component---${kebabCase(name)}`

All local unit tests passed & the site I tested this on seems to perform as expected.


"component---11d478fe-6a55-579c-becf-625ab1e57cf4": [ "/component---11d478fe-6a55-579c-becf-625ab1e57cf4-76c90ae50035c52657a0.js" ]
"component---15c76861-b723-5e0a-823c-b6832aeeb0a0": [ "/component---15c76861-b723-5e0a-823c-b6832aeeb0a0-18eb457ba6c147e1b31b.js" ]

What do you think? Should the component path in componentChunkName be hidden?


This comment has been minimized.

Copy link

@davidhellsing davidhellsing commented Oct 21, 2019



This comment has been minimized.

Copy link
Contributor Author

@d4rekanguok d4rekanguok commented Nov 2, 2019

This would affect the caching of currently deployed Gatsby sites, so perhaps we can consider making it an opt-in thing? Like an option in gatsby-config.js maybe.

What do you think @pieh @wardpeet? Could this be considered, or is it a wont fix thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.