umijs / babel-plugin-import

Modularly import plugin for babel.
3.15k stars 403 forks source link

What is "libraryDirectory" referring to? #573

Open Bazze opened 3 years ago

Bazze commented 3 years ago

Hello!

I can't seem to find any documentation on what the libraryDirectory option actually refers to. What directory should it point to and why?

Thanks

mohitrajane commented 3 years ago

@Bazze where you able to figure this out ?

Bazze commented 3 years ago

Unfortunately I did not @mohitrajane. Ended up never having to use this plugin, so did not spend more time looking into it!

MinimalistYing commented 3 years ago

@Bazze Hi~ libraryDirectory actually refers to which type of module do you want to use in your project. For antd there is ESM modules under directory antd/es/* and CJS modules under directory antd/lib/*. Normally, if you use import Button from 'antd', you should config libraryDirectory: 'es'. if you use const Button = require('antd'), you should use the default behavior libraryDirectory: 'lib'.