[Question] Is parcel suitable for building a npm package?
See original GitHub issueChoose one: is this a 🐛 bug report or 🙋 feature request?
A question.
🎛 Configuration (.babelrc, package.json, cli command)
I’m writing a npm package, where I use the npm script to bundle the src files together into a single file. But I found the dist file doesn’t bundle everything together, which causes this error:
/Users/changyan/Documents/repos/test/node_modules/react-animation-wrapper/lib/index.js:12:29: Cannot resolve dependency './emptyFunction'...
and when looking into the bundled file I noticed it’s requiring something like this:
var e,r=require("./emptyFunction")
My npm script looks like this:
{
"build": "parcel build ./src/index.js --out-dir ./lib",
}
And I searched around on the internet but didn’t find something useful to resolve my problem. Also, I read a post that addressed that rollup or webpack are probably better choices for writing npm packages. Is that true? Or am I using it wrong?
🤔 Expected Behavior
😯 Current Behavior
💁 Possible Solution
🔦 Context
💻 Code Sample
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | |
Node | |
npm/Yarn | |
Operating System |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Building a library with Parcel
A getting started guide walking through how to setup a library with Parcel, including output of an ES module, CommonJS, and TypeScript definitions....
Read more >parcel - npm
Parcel makes your code portable. You can build your code for different environments, for the web for your server, or for an app....
Read more >Parcel JS - How to Get Started - YouTube
In this video I will show you how to get started with Parcel in just minutes. This is for beginners but if you...
Read more >How To Create And Publish Your First NPM Package - YouTube
It may seem daunting to create your first NPM package, but it is surprisingly easy to do so. In this video I will...
Read more >How To Set Up a React Project With Parcel - DigitalOcean
Parcel is based on the premise that building apps with JavaScript bundlers could be easier. Webpack provides greater configurability, but there ...
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 Free
Top 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
I think your after https://github.com/developit/microbundle
@djstein it looks
parcel build --target node
was added in #652.For libraries Microbundle is intended for building multiple outputs from the same input. In theory you get CJS, ESM, UMD,
.min.js
,.d.ts
, etc. in one pass.I don’t think that’s in scope for Parcel?