Bundle error when using peerDependencies and devDependencies
See original GitHub issueI spent an entire day and a half just trying to work out why size-limit was erroring 😥
It turns out, with this setup…
index.mjs
:
export { extractFiles } from 'extract-files'
package.json
:
{
"dependencies": {
"extract-files": "^5.0.0",
},
"devDependencies": {
"size-limit": "^0.21.1"
},
"scripts": {
"size": "size-limit"
},
"size-limit": [
{
"path": "index.mjs",
"limit": "5 KB"
}
]
}
npm run size
works ok.
But if you change package.json
to this:
{
"peerDependencies": {
"extract-files": "^5.0.0"
},
"devDependencies": {
"extract-files": "^5.0.0",
"size-limit": "^0.21.1"
},
"scripts": {
"size": "size-limit"
},
"size-limit": [
{
"path": "index.mjs",
"limit": "5 KB"
}
]
}
You get this error:
ERROR Error:
ERROR in ./index.mjs 1:0-44
Can't reexport the named export 'extractFiles' from non EcmaScript module (only default export is available)
@ multi ./index.mjs
at runWebpack.then.stats ([redacted]/node_modules/size-limit/index.js:214:15)
I suspect it might have something to do with peer dependencies being ignored:
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
node.js - What's the difference between dependencies ...
When using Webpack to bundle a frontend application, the distinction between dependencies and devDependencies is not so clear. For the ...
Read more >Understanding Peer Dependencies in JavaScript
Express middleware packages: This is just one example of an NPM module that would require the use of peer dependencies.
Read more >How to handle peer dependencies when developing modules
The problem with peer dependencies is npm and yarn don't install them at all. This is the right behavior for production purpose but...
Read more >Common npm mistakes - Medium
Common npm mistakes · Mistake 1: using the wrong dependency type · Mistake 2: avoiding peerDependencies · Mistake 3: not using shrinkwrap ·...
Read more >An In-Depth Explanation of package.json's Dependencies
Dependencies, devDependencies, and peerDependencies: What do they mean? If you use npm (Node Package Manager) to manage a JavaScript project, it is vital...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed cdc608f
Released in 1.3.3