Replies: 6 comments 3 replies
-
|
For example, what am I to do about |
Beta Was this translation helpful? Give feedback.
-
|
I am also interested in this. I am looking into converting a set of micro-services over to using bun instead of node, and would also like to use it as much as possible for a library of shared code for them. Do I use bun for everything but the |
Beta Was this translation helpful? Give feedback.
-
|
May be a starting point: https://github.com/wobsoriano/bun-lib-starter (found here: https://github.com/oven-sh/awesome-bun#boilerplates) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Yes, you can absolutely use Bun to develop and publish npm packages. Here's the full workflow: 1. Initialize bun initThis creates package.json, index.ts, and .gitignore. 2. Structure 3. Build for npm bun build ./src/index.ts --outdir ./dist --target nodeFor TypeScript declarations, add a postbuild script: {
"scripts": {
"build": "bun build ./src/index.ts --outdir ./dist --target node",
"postbuild": "tsc --emitDeclarationOnly --outDir dist"
}
}4. package.json fields {
"name": "@yourscope/my-package",
"version": "0.1.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist"],
"scripts": {
"build": "bun build ./src/index.ts --outdir ./dist --target node",
"prepublishOnly": "bun run build"
}
}5. About bun.lockb No action needed. npm automatically ignores lockfiles when packing the tarball. 6. Publish bun publish # Bun 1.1+
# or
bunx npm publishYour users can install with npm install, yarn add, pnpm add, or bun add. 7. Alternative: bunup.dev wraps bun build with declarations, ESM/CJS dual output, and minification. |
Beta Was this translation helpful? Give feedback.
-
|
By the way, how can I use bun to pack a package into a tarball like I know it now, it's |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create a JavaScript library to publish on NPM, but develop it using Bun for runtime testing and dependency management. Is there any official documentation on how to do it? I assume it's exactly the same as you would create an NPM package normally, except you .npmignore all the bun stuff. Any other steps I should take?
Beta Was this translation helpful? Give feedback.
All reactions