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

JSONP highlight and UglifyJS #1673

Closed
RunDevelopment opened this issue Dec 23, 2018 · 0 comments · Fixed by #1793
Closed

JSONP highlight and UglifyJS #1673

RunDevelopment opened this issue Dec 23, 2018 · 0 comments · Fixed by #1793

Comments

@RunDevelopment
Copy link
Member

Right now, we use UglifyJS to compress our .js files.

UglifyJS also replaces the names of most function with a new shorter name to decrease file size.
But this is a problem because it changes that function's .name property upon which JSONP Highlight's getAdapter relies.

As a consequence, Prism.plugins.jsonphighlight.removeAdapter("github") will remove the github adapter when using the development version, but it doesn't do anything when using the minified version.

Possible solutions

  1. We could set keep_fnames: true in the mangle options of UglifyJS but this will also blow up the file size of (almost) every other file with named functions.
  2. Change the definition of registerAdapter to take an optional name, like so:
    function registerAdapter(adapter, name) {
    	name = name || adapter.name;
    	...
    }
    We would have to change the underlying adapter list as well, but that's not a problem because we don't expose it.
  3. Change the definition of registerAdapter to require a name similar to Prism.hooks.add.
    This is a breaking change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant