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

Strip query and hash by sanitizeURIComponent #138

Closed
1 task done
antfu opened this issue Jan 8, 2023 · 5 comments · Fixed by #141
Closed
1 task done

Strip query and hash by sanitizeURIComponent #138

antfu opened this issue Jan 8, 2023 · 5 comments · Fixed by #141

Comments

@antfu
Copy link
Member

antfu commented Jan 8, 2023

Describe the feature

Related to #137 - Even that PR fixes the bug, it still makes the file name necessarily long. And in practice, if you check the dist of a Nuxt app, you will find there are a lot of files ending with .vue_vue_type_script_setup_true_lang:

image

Since the bundle already has a hash in the end, the uniqueness shouldn't be a problem.

I would propose to make sanitizeURIComponent striping the query and hash directly

Additional information

  • Would you be willing to help implement this feature?
@pi0
Copy link
Member

pi0 commented Jan 9, 2023

@antfu Shall we close this?

@antfu
Copy link
Member Author

antfu commented Jan 9, 2023

No, it's not #137.

Rather I am asking if you think it's a good idea to strip ?query and #hash for the bundle name (either on mlly or nuxt).

So Foo.vue?vue&type=script&setup=true&lang.js will be generated as:

  • foo.vue.{hash}.js

instead of the current

  • foo.vue_vue_type_script_setup_true_lang.{hash}.js

@pi0
Copy link
Member

pi0 commented Jan 9, 2023

Hashing payload (query, hash) seems a really nice idea indeed. Feel free to open PR i can wait for next release.

@antfu
Copy link
Member Author

antfu commented Jan 9, 2023

I am more referring to https://github.com/nuxt/framework/blob/c67dbed40755b03cc98497141089a8b54adf06b4/packages/vite/src/vite.ts#L63-L67

Where we use sanitizeURIComponent to generate the bundle name. The hash is generated by Rollup already. Do you think the removal of URL query and hash should happen on Nuxt side to keep sanitizeURIComponent simple? Or we do another hash here?

@pi0
Copy link
Member

pi0 commented Jan 9, 2023

I think removing it here makes sense as well even with a simple hashing or simply removing anything after ? altogether. sanitizeURIComponent is already a lossy strip function (irreversible removals) and we should as you mention always make sure a hash addition as added to guarantee uniqueness that can happen on nuxt side.

Here we can either strip or use simple hash (like length)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants