-
Notifications
You must be signed in to change notification settings - Fork 9.6k
core(build): add warnings to inline-fs plugin #13240
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
Conversation
| // @ts-expect-error - see https://github.com/acornjs/acorn/issues/946 | ||
| return node; |
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 is a bit of noise that's mostly for the compiler, but the nice thing is that if/when acorn types are ever updated, the @ts-expect-error will throw type-check errors and hopefully it will be obvious this whole method can be dropped
| return outputCode; | ||
| return { | ||
| code: outputCode, | ||
| warnings, |
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.
is it not awkward that warnings can be an empty array and missing? callers must then check for both.
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.
Yeah, probably. We could make it non-optional
| return JSON.stringify(contents); | ||
| } catch (err) { | ||
| throw new Error(`could not inline fs.readdirSync call: ${err.message}`); | ||
| throw new Error(`could not inline fs.readdirSync contents: ${err.message}`); |
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.
could this error reference the node param?
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.
it could but it's kind of a last ditch something broke check, so there's not much to say about it except the fs.readdirSync call failed, which it'll default to anyways. Explicit might be better, but it seems ok to rely on the default behavior since there's a lot of other possible thrown errors in here that also default to pointing to the fs.readdirSync as the culprit (e.g. the asserts, etc)
8e3246a to
d4d1998
Compare
part of #13231
adds structured warnings to inline-fs plugin. Type is a subset of the esbuild warning type, in case we ever want to move over to that :) More seriously, esbuild uses the location to do nice
logging, and we could maybe do the same if there's a nice library somewhere we could use, or we could just live with plain old
filepath:line:columnlogging until we ever need something fancier.All that's for later, though. This just keeps a list of encountered warnings.