2

I don't need all of the components provided in the 'core' library and was hoping to treeshake/selectively choose which components to import. I've tried a few variations and experiments based on other successes but can't seem to get this one to work.

Current: import { Menu } from '@blueprintjs/core';

Ideal: import Menu from '@blueprintjs/core/Menu';

Alex
  • 111
  • 7

2 Answers2

2

You can import specific components like this:

import { Menu } from "@blueprintjs/core/dist/components/menu/menu";

unpkg is helpful for viewing the folder structure of the published package.

Adi Dahiya
  • 578
  • 2
  • 6
  • Hi Adi, thanks for the reply. The solution you provided doesn't work (getting the standard can't resolve error). Any thoughts on why? Using webpack 2.x and blueprintjs 1.16 – Alex May 17 '17 at 20:01
  • 1
    I was missing a trailing `/menu` in the path. I've updated my answer. Also, follow along at https://github.com/palantir/blueprint/issues/309 if you're interested in tree shaking. – Adi Dahiya Jun 01 '17 at 20:04
1

Got it to work:

import { Menu } from "@blueprintjs/core/dist/components/menu/menu";

or

import { Toaster } from "@blueprintjs/core/dist/components/toast/toaster"; etc

Alex
  • 111
  • 7
  • yep this is correct! you can reach into the dist directory to get the exact component you need. i'll agree the path is awkwardly long, but such is life. – Gilad Gray May 31 '17 at 19:00