parcel
parcel copied to clipboard
Parcel bundler not working for npm module library
🐛 bug report
If I try to install a module pointing to a bundled file generated from parcel build it throws an error.
🎛 Configuration (.babelrc, package.json, cli command)
package.json
{
"name": "parcel-package",
"version": "1.0.0",
"description": "Reproduction of parcel error",
"source": "src/index.ts",
"main": "dist/main.js",
"module": "dist/module.js",
"types": "dist/types.d.ts",
"bin": {
"parcel-package": "dist/main.js"
},
"scripts": {
"build": "parcel build",
"install-module": "npm i -g .",
"test-module": "parcel-package"
},
"author": "Caio Borghi",
"license": "ISC",
"dependencies": {
"chalk": "^5.1.2"
},
"devDependencies": {
"@parcel/packager-ts": "2.8.0",
"@parcel/transformer-typescript-types": "2.8.0",
"parcel": "^2.8.0",
"typescript": ">=3.0.0"
}
}
🤔 Expected Behavior
It should work after install
😯 Current Behavior
It's not working.
💁 Possible Solution
Understand why NPM cannot run the bundle and fix the issue.
🔦 Context
I'm trying to build a npm module to publish on npm
💻 Code Sample
With this index file and the package.json you're already able to reproduce it.
src/index.ts
import chalk from "chalk"
console.log(chalk.green('This is a test application'))
Simply run:
npm run install-module
Then
npm run test-module
And you'll see the following error
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | ^2.8.0 |
Node | 18.12.1 |
npm/Yarn | 8.19.2 |
Operating System | Arch linux WSL |
Please provide a reproduction by filling out the issue template
Comment updated with src/index.ts file and package.json
Hey @mischnic were you able to check it?