-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
loadLanguages utility causes bloat with webpack #1403
Comments
I don't know as we have a good "story" for bundlers, tbh. Maybe a babel plugin? |
For future reference, see related #1409. |
Would loading a few dependencies up front and then using dynamic imports to specific files possibly avert this bloat? Something like this: import React from "react";
import Prism from "prismjs/components/prism-core";
//other languages depend on these
import "prismjs/components/prism-clike";
import "prismjs/components/prism-c";
import "prismjs/components/prism-java";
class CodeBlock extends React.Component {
.
.
//try to load prism component for language
import("prismjs/components/prism-"+props.language);
.
.
render(){...}
}
export default CodeBlock; Is there a dependency graph for all the language packs available somewhere? Importing |
The dependency graph can be inferred from the data from |
Just to be clear, to anyone who wants to pick this up, the "good first issue" here is to add documentation. |
The babel plugin is ready here: https://www.npmjs.com/package/babel-plugin-prismjs |
I'm seeing lots of bloat when using the
loadLanguages
utility in webpack.~30k:
~755k:
Numbers are in development mode, non-gzipped. I checked a couple other languages to make sure it wasn't a dependency loading issue with
prism-ruby.js
, but results were similar with other languages.The text was updated successfully, but these errors were encountered: