Error while bundling with Rollup
niklaswolf opened this issue · comments
Hi, when I'm trying to use match-sorter in an app that gets bundled with rollup, I get the following error:
[!] Error: 'default' is not exported by node_modules/remove-accents/index.js, imported by node_modules/match-sorter/dist/match-sorter.esm.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
node_modules/match-sorter/dist/match-sorter.esm.js (2:7)
1: import _extends from '@babel/runtime/helpers/esm/extends';
2: import removeAccents from 'remove-accents';
^
3:
4: var rankings = {
Error: 'default' is not exported by node_modules/remove-accents/index.js, imported by node_modules/match-sorter/dist/match-sorter.esm.js
After having a look at remove-accents
it seams that this is valid. Do you have any clue on how to fix this?
Edit: here is my rollup config
{
output: {
exports: 'named',
format: 'umd',
dir: 'dist',
sourcemap: environment === 'development',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes'
}
},
external: ['react', 'react-dom', 'prop-types'],
plugins: [
resolve(),
postcss({
plugins: [],
minimize: true,
sourceMap: false,
modules: true
}),
json(),
injectProcessEnv({
NODE_ENV: environment
}),
babel({
include: ['src/**', 'node_modules/@mothership/**'],
plugins: [
'@babel/plugin-transform-react-jsx',
'@babel/plugin-proposal-class-properties'
],
presets: ['@babel/preset-env']
}),
commonjs({
include: 'node_modules/**'
})
]
}
@niklaswolf Were you able to figure out a solution? I am facing the same issue w/ a lerna monorepo.
Edit:
I had a bad pattern in my rollup config for the monorepo. I needed to have the following config
commonjs({
include: '../../node_modules/**',
...
Also just fyi for others, moving things to a peerDependency
also works but I didn't want to make consumers install a utility along w/ my package.
Sorry, I have no idea 😬