mapbox / rehype-prism

rehype plugin to highlight code blocks in HTML with Prism (via refractor)
MIT License
178 stars 24 forks source link

Lower browser footprint with `options.langs` #5

Closed iamskok closed 5 years ago

iamskok commented 5 years ago

Hi @mapbox, @davidtheclark 👋

Would you be interested in my PR, which adds an option to register languages?

It will let the end user to define the languages they will actually need and as a result it will lower browser footprint.

iamskok commented 5 years ago

@davidtheclark You are totally right about Webpack.

The other way we can go about it is to register all languages by default as you used to do it and to provide a way to generate a custom template with required languages.

davidtheclark commented 5 years ago

Interesting idea, @iamskok; but this looks like too much additional complexity for the library.

What about using dependency injection: Make refractor itself an argument you can pass into the plugin's options; set up the current Node entrypoint to pass in all of refactor; and expose another file where a browser user could pass in their own smaller version?

iamskok commented 5 years ago

@davidtheclark Do you mind giving more information on how to do it? I'm having a hard time understanding how to make webpack load external refractor script passed by a user without adding settings to the webpack config.

iamskok commented 5 years ago

@davidtheclark could you give me more information or should I close this PR?

davidtheclark commented 5 years ago

@iamskok This is not a priority for us right now, so I don't think we'll be able to dedicate time to walking through an implementation. If you'd like to open an issue describing the problem and potential solution, we can keep that on hand in case somebody else wants to take a shot at it.

iamskok commented 5 years ago

@davidtheclark Sounds reasonable, thanks for assisting me along the way.

In the meantime I leave the link on template generator https://github.com/iamskok/rehype-prism-template.