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

Handling import() errors through .catch() doesn't silence bundling warnings. #893

Closed
darionco opened this issue Feb 26, 2021 · 0 comments
Closed

Comments

@darionco
Copy link

darionco commented Feb 26, 2021

Hi,

I can see that in 6be8e44 changes to silence warnings about the use of import with non-string literals inside try/catch blocks were added, however the rules apply only if the call is used with async/await, from the commit:

// this silences the warnings
async function main(name) {
	try {
		return await import(name)
	} catch {
	}
}
main('fs')

// this doesn't
async function main(name) {
	try {
		return import(name)
	} catch {
	}
}
main('fs')

so far it makes sense, however, I believe that the following code should also silence the warnings:

function main(name) {
	import(name)
          .then(mod => { // do stuff })
          .catch(e => { // do stuff })
}
main('fs')

Thanks for the awesome tool!

@darionco darionco changed the title Handling import() errors through .catch() doesn't silence bindling warnings. Handling import() errors through .catch() doesn't silence bundling warnings. Feb 26, 2021
@evanw evanw closed this as completed in 071e8f9 Feb 27, 2021
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 a pull request may close this issue.

1 participant