-
Notifications
You must be signed in to change notification settings - Fork 5
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
Fix incorrect output path due to esbuild outbase. #2
base: main
Are you sure you want to change the base?
Conversation
@@ -1,6 +1,10 @@ | |||
// eslint-disable-next-line @typescript-eslint/triple-slash-reference | |||
/// <reference path = "./lowest-common-ancestor.d.ts" /> |
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.
I've created a pull-request adding types for lowest-common-ancestor
to @DefinitelyTyped, but they're awaiting approval. These lines can be deleted once it's merged.
Thanks for the pr! :) I will take a look at it tomorrow |
Hi Cameron, I've looked at the PR and worked on a test for it, but I ended up with a few reservations. I'm curious to hear your thoughts. I'm wondering what the expected behavior is in watch mode. The way the fix works atm is it checks the state of the filesystem when the plugin first runs and then calculates the lowest common ancestor from it. What should be happening when a file is added or removed while the plugin is watching and it changes the lowest common ancestor? It could maintain the same initial I feel like a user would get the most predictable behavior by explicitly setting Another thought I had is that this would be a breaking change. So we either have to put this functionality behind a configuration option or bump a major version. But given what I described above, I'm leaning more towards the documentation/warning route. I'm really happy with the improved |
Thanks for checking it out @waspeer. In my mind I'd want watch mode to behave the same way as a standard build, so if a file change resulted in a different Explicitly setting an I agree that this would be a breaking change. |
Ok! I'll play around with it and try to come up with an intuitive behavior. Could you help me out with one thing, though? Could you sketch out a situation in which you needed this option? I'd like to model a test to such a situation and work on a solution from there. This is what I've come up with:
|
Context
esbuild
calculates the lowest common ancestor of theentryPoints
to determine where to place the output file. From their docs:Issue
In watch mode, this plugin builds each added/changed file as a single entryPoint leading to the output files all being at the top-level of
outdir
. To fix the issue we need to calculate the lowest common ancestor of the resolved glob ourselves and make use of esbuild'soutbase
option to maintain the correct directory structure.