Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cyan33 opened this issue Jan 6, 2018 · 10 comments
Closed

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

cyan33 opened this issue Jan 6, 2018 · 10 comments

Comments

@cyan33
Copy link

cyan33 commented Jan 6, 2018

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
@jamesmcallister
Copy link

I think your after https:/developit/microbundle

@albinotonnina
Copy link
Contributor

Thanks @jamesmcallister , didn't know about this one!

@DeMoorJasper
Copy link
Member

related to #192 Seems like u found a solution with microbundle ;)

@eldyvoon
Copy link

Having the same issue, what's wrong with using parcel-bundler for npm package bundling?

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Mar 29, 2018

@eldyvoon it should be possible, just not 3 months ago

Sent with GitHawk

@djstein
Copy link

djstein commented Jun 26, 2018

@DeMoorJasper or anyone else, so what I'm reading is that adding:

{
  "build": "parcel build ./src/index.js --out-dir ./lib",
}

to one's package.json would remove the need for would remove the need for rollup or microbundle

@texastoland
Copy link

texastoland commented Aug 12, 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?

@bntzio
Copy link

bntzio commented Oct 17, 2018

Interesting... but what about the TS typings files?

@chocolateboy
Copy link
Contributor

Looks like this might be in scope for Parcel 2?

@tunnckoCore
Copy link

tunnckoCore commented Oct 20, 2019

@chocolateboy don't think so.

And still. Rollup HAS problems bundling everything and might be slow. Webpack is the only alternative, but cannot output ESM. There is @purtuga/esm-webpack-plugin, but it is a hack workaround just to make consuming easier. When third party is going to bundle to the generated package, the tree shaking won't work.

So. Yes we need more competition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

11 participants