Home > Software engineering >  can't import specific export from main file of library
can't import specific export from main file of library

Time:01-16

I am trying to understand how authoring libraries works with webpack and while doing works:

import add from 'sample-lib/add' 

trying to import anything from the main does not:

import { add, subtract } from 'sample-lib'

Here is the repo for your reference: https://github.com/rssilvaba/sample-lib

Any ideas why I can't do that? is it because it is umd? something with my package.json? Am I exporting from main in the wrong way?

Also extra question. how could I re export all files without having to manually add all of the files to the main.js?

CodePudding user response:

resolved doing:

export { default as add } from './add'
export { default as subtract } from './subtract'
export * from './others'
  •  Tags:  
  • Related