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

Print user friendly error if no entrypoint can be found #1848

Merged
merged 5 commits into from
Aug 23, 2018

Conversation

DeMoorJasper
Copy link
Member

Print a user friendly error message if no entrypoint can be found.
Also prints a user friendly error if a user defined entrypoint has a resolve error

Closes #1797 Closes #1829

src/Bundler.js Outdated
process.exitCode = 1;
if (process.env.NODE_ENV === 'production' || !initialised) {
await this.stop();
process.exit(1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently process.exitCode = 1; didn't exit the process anymore for some reason, so changed this to be a lil more aggresive and added await this.stop(); to make sure servers and workers shutdown properly

src/Bundler.js Outdated
this.buildQueue.add(asset);
this.entryAssets.add(asset);
} catch (err) {
throw new Error(`Failed to load entrypoint: ${entry}!`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of a more precise error message, something like: Failed to resolve entrypoint "${entry}" in "${rootDir}"

Given that we infer rootDir I think it'd be better to give users more info so they can debug why we can't find their entrypoint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I'll update it

src/Bundler.js Outdated
throwErrors:
typeof options.throwErrors === 'boolean'
? options.throwErrors
: process.env.NODE_ENV === 'test'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should default this to false in CLI and true when using the Bundler API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, I'll update it

Copy link
Member Author

@DeMoorJasper DeMoorJasper Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be considered a breaking change?

Copy link
Member Author

@DeMoorJasper DeMoorJasper Aug 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something I thought about, parcel already throws errors in the api using the event handler.
So this might cause issues as the promise of bundle only returns on initial build. What do you think?

src/Bundler.js Outdated
this.entryAssets.add(asset);
} catch (err) {
throw new Error(
`Failed to load entrypoint: "${entry}" in "${
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say "Cannot resolve entry ${entry}". As of the error we haven't actually tried to load anything yet, just resolved.

@devongovett devongovett merged commit 1eadb5f into master Aug 23, 2018
@devongovett devongovett deleted the feature/entrypoint-userfriendly-error branch August 23, 2018 18:50
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

Successfully merging this pull request may close these issues.

Should default to index.html, or show an error
3 participants