parcel: [v2] bad error message for package.json#main mismatch with html entry point: "Destination name index.js extension does not match bundle type "html"
🐛 bug report
parcel build is broken. if you take the basic index.html/styles.css setup in the readme: https://github.com/parcel-bundler/parcel/tree/v2#getting-started
you can run parcel index.html fine, but when you run parcel build you get the above mentioned error
🎛 Configuration (.babelrc, package.json, cli command)
{
"name": "netlify-drop-demo-site-master",
"version": "1.0.0",
"main": "index.js",
"repository": "https://github.com/sw-yx/netlify-drop-demo-site-master.git",
"author": "sw-yx <swyx@dontemail.me>",
"license": "MIT",
"devDependencies": {
"parcel": "^2.0.0-alpha.1.1"
},
"scripts": {
"build": "parcel build basic.html"
},
"dependencies": {
"react": "^16.9.0",
"react-dom": "^16.9.0"
}
}
🤔 Expected Behavior
it should build
😯 Current Behavior
doesnt build
yarn run v1.17.0
$ /Users/swyx/Downloads/netlify-drop-demo-site-master/node_modules/.bin/parcel build basic.html
🚨 Destination name index.js extension does not match bundle type "html"
at BundlerRunner.nameBundle (/Users/swyx/Downloads/netlify-drop-demo-site-master/node_modules/
@parcel/core/lib/BundlerRunner.js:137:17)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
💁 Possible Solution
no idea
🔦 Context
just trying to try out parcel v2
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.0.0-alpha.1.1 |
| Node | 10.13 |
| npm/Yarn | 6.51/1.17 |
| Operating System | osx latest |
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 18 (8 by maintainers)
https://v2.parceljs.org/features/targets/#library-targets:
I think could be related to your
package.json#main. It uses that to define the output files and your entry is anhtmlfile, but yourmainis expected it to output as ajsfile. Try updating yourmaintodist/index.htmli see, thanks kyle. yeah… if im specifying my entry point in the cli, i dont expect my package json main to have Any Effect at all… so this feels like a nasty implicit relationship here that isnt documented.
oh wow, just figured out that if you just leave out the “main” field in package.json and run
parcel build index.htmlit WORKS BEAUTIFUULLY we should just recommend that. it also causes https://github.com/parcel-bundler/parcel/issues/3442 btw, because there will be twoindex.htmlentries (one from package.json, one from command line)Based on this feedback and other confusion about this, we’re considering only using
mainas a target if the entry point is a JS file. This feature was mostly meant for building libraries instead of applications, where you’d want the package.json to point to the built file. For applications, you typically wouldn’t need amainin package.json, but we can ignore it if you do.We should add a better error message for this…
@sw-yx what do you think of the below error message? Trying to make it as clear as possible.