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
Show warning message when entry file not provided (#1797) #1829
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't check for main in pkg or any other resolving that might happen?
I originally thought you were gonna catch the error and just print a user-friendly one instead (if not entry if found)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't check for main in pkg or any other resolving that might happen?
I originally thought you were gonna catch the error and just print a user-friendly one instead (if not entry if found)?
@DeMoorJasper According to my understanding none of the entry points you mentioned are not checking for |
It's still checking it, but it shouldn't throw a warning. Parcel can be used without entrypoint it's optional, it should just throw a user friendly error if it can't find one. |
@rajikaimal I think @DeMoorJasper means |
@mohsen1 Yeah that's what I meant by @DeMoorJasper Isn't a warning log the best for this scenario, rather than an error log? |
Users of parcel are allowed to use non explicit entrypoints at their own risk, we can log the entrypoints if that's really necessary. But the most important thing is if parcel can't resolve an entrypoint it should throw a nice error, otherwise users think it's a parcel bug or something. Because users expect too much magic. I'm basically talking about wrapping this The error should probably also exit the parcel process (as parcel can't do anything without), not sure how that would be achieved |
@DeMoorJasper Is this what you're looking for? for (let entry of this.entryFiles) {
try {
let asset = await this.resolveAsset(entry);
this.buildQueue.add(asset);
this.entryAssets.add(asset);
} catch (err) {
const errMsg = `Failed to load entrypoint. ${err}`
logger.error(errMsg);
process.exit(1);
}
} |
Sort of the process.exit seems a bit hacky to me though as in the catch of build we already have something similar Sent with GitHawk |
@DeMoorJasper Copy that. I don't have a lot of familiarity with exiting processes - maybe someone else can chime in |
@jchiatt Hey, did you test the code with |
@rajikaimal what bug? User friendly errors are a feature. In theory the Personally I would probably create something like this: for (let entry of this.entryFiles) {
try {
let asset = await this.resolveAsset(entry);
this.buildQueue.add(asset);
this.entryAssets.add(asset);
} catch (err) {
err = new Error(`Failed to load entrypoint: ${entry}`);
// Scary error throwing
throw err;
// Or use the logger
logger.error(err);
process.exit(1);
}
} Throwing an error will output a fairly big error message, this might be too scary? You can try it out with the logger it should work in theory, as it's a singleton. It should print errors by default. But definitely change the error to show |
"what bug?" Misinterpretation should have mentioned as "the issue". Anyways execution doesn't go to catch block at all. |
That’s strange than it can resolve it right? Might be that the resolver just doesn’t check a file exists |
I've opened a PR with what I had in mind, see #1848 |
Fixes #1797