question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Is parcel suitable for building a npm package?

See original GitHub issue

Choose 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:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
jamesmcallistercommented, Jan 13, 2018
8reactions
texastolandcommented, Aug 21, 2018

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found