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

eui dependency - highlight.js #3164

Closed
lior-fortifieddata opened this issue Mar 25, 2020 · 3 comments
Closed

eui dependency - highlight.js #3164

lior-fortifieddata opened this issue Mar 25, 2020 · 3 comments

Comments

@lior-fortifieddata
Copy link

lior-fortifieddata commented Mar 25, 2020

hello

I'm using eui 20.1.0 for my react website (and love it!)

when analyzing my bundle, I've notices that highlight.js, which is eui dependency,is taking lots of it: (highlight.js "^9.12.0")

image

is there anyway to remove it from the bundle?
it seems to be in use in EuiCodeBlock but I dont use this component in my website.

thanks!

@lior-fortifieddata lior-fortifieddata changed the title eui dependency - highlist.js eui dependency - highlight.js Mar 25, 2020
@chandlerprall
Copy link
Contributor

Thanks for reporting! We are aware of this and better modularization is somewhat tracked on our roadmap.

I did confirm a few months ago that a properly configured webpack project will tree shake unused modules (off the top of my head that is ensuring es imports are used, production mode, and minification), though this can be cumbersome and error prone. Another option is to configure those modules you don't use as externals or otherwise disable, e.g. with webpack:

module.exports = {
  //...
  resolve: {
    alias: {
      'highlight.js': path.resolve(__dirname, './empty_mock.js')
    }
  }
};

or

module.exports = {
  // ...
  externals: {
    'highlight.js': 'noop'
  }
};

We would like to address this better in the future, but it's definitely a lower priority right now.

@snide
Copy link
Contributor

snide commented Mar 30, 2020

Closing in favor of a better roadmap description #2520

@snide snide closed this as completed Mar 30, 2020
@lior-fortifieddata
Copy link
Author

lior-fortifieddata commented Mar 31, 2020

i'll just update what I did as a future reference:

  1. installed craco: https://github.com/gsoft-inc/craco
  2. created craco.config.js with the following content:
module.exports = {
  webpack: {
    configure: webpackConfig => {
      webpackConfig.module.rules.push({
        test: /highlight\.js/, 
        use: "null-loader"
      })

      return webpackConfig
    }
  }
}

thanks!

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

No branches or pull requests

3 participants