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

Feature request: Allow disabling escaping #6055

Closed
ghost opened this issue Aug 5, 2017 · 2 comments
Closed

Feature request: Allow disabling escaping #6055

ghost opened this issue Aug 5, 2017 · 2 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories

Comments

@ghost
Copy link

ghost commented Aug 5, 2017

I've recently brought this up with jsesc: Essentially, there are valid scenarios where unescaped (or: non-ASCII-safe) code is required to prevent transpiled files from exploding in size.

Allow me to copy the gist of it over with some slight edits:

One of my projects requires me to have a binary blob (synchronously) ready at require time. Hence, part of the build pipeline is to load the blob into a string in the build step, and then read the string and convert it to a TypedArray during runtime.

When running the files through babel, the 119 KiB blob and 64 KiB source bundle up to 408 KiB after minification. One might have (very rougly) expected a total of around 64 KiB + 119 KiB = 183 KiB.

The problem is that most of the binary blob, which is loaded into the bundle, is escaped once babel has processed it, and the escaped representation takes up a lot of space. This limitation seems to be known and has been brought up in this discussion already.

I see you've implemented a minimal mode which only escapes very few characters. Since my payload contains a good amount of null bytes, this wouldn't help me a lot. My best option would be to specify an option such as none (feel free to bikeshed!), once babel allows passing options to jsesc.

@michaelficarra then rightfully argued:

Asking a dependency for an option which effectively disables it so that the consuming application doesn't need to avoid calling it seems inappropriate. Just have babel not call jsesc.

One solution to this problem would be to specify a boolean flag in the configuration that allows turning off escaping entirely.

@babel-bot
Copy link
Collaborator

Hey @Kdex! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@xtuc xtuc added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Aug 6, 2017
@JLHwung
Copy link
Contributor

JLHwung commented Jun 24, 2020

Closing this as it has been fixed in #11384.

@JLHwung JLHwung closed this as completed Jun 24, 2020
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

No branches or pull requests

3 participants