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

feat: restore resolving config from multiple paths and combine config discovery #66

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Jul 3, 2024

This is better config discovery that isn't as confusing and cause issues like this.

Essentially now that we have workspaces, we can use the exact same rules for discovering deno.json files that we do for package.json files:

  1. When discovering the configs it looks for both package.json and deno.json at the same time.
  2. If we find a deno.json with a workspace we stop. If we find a package.json with a workspace, then we stop.
  3. When not in a workspace, we stop on the first deno.json or first package.json
    • If a deno.json is in a root folder, then it needs to reference the package.json as part of the workspace in order to be discovered
  4. We allow finding both a deno.json and a package.json in the same folder. We allow both of them to be workspaces, but they must be in the same folder for that to work.
  5. We have to special case the node_modules folder to auto-discover outside it. For example, if someone runs something at /home/david/project/node_modules/package/file.js, then it should start discovery at /home/david/project/. That way we don't cause errors about configs not being in a workspace for stuff in the node_modules folder and so we properly discover the project configs (and not stop at the first found package.json)

This is a breaking change for some projects, but it's easy to work around by adding the config as part of the workspace and it will be better in the long term.

@dsherret dsherret requested a review from bartlomieju July 3, 2024 01:27
@dsherret dsherret requested a review from lucacasonato July 3, 2024 02:27
Comment on lines +402 to +404
log::warn!(
"Wildcards in npm workspaces are not yet supported. Ignoring."
);
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but without emoji/color this might be easy to miss.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's just leave this as-is for now because hopefully we can implement this before the next minor release. I opened #67

src/workspace/mod.rs Outdated Show resolved Hide resolved
@dsherret dsherret merged commit 40153a5 into denoland:main Jul 3, 2024
3 checks passed
@dsherret dsherret deleted the feat_combine_discovery branch July 3, 2024 17:08
dsherret added a commit to denoland/deno that referenced this pull request Jul 4, 2024
Adds much better support for the unstable Deno workspaces as well as
support for npm workspaces. npm workspaces is still lacking in that we
only install packages into the root node_modules folder. We'll make it
smarter over time in order for it to figure out when to add node_modules
folders within packages.

This includes a breaking change in config file resolution where we stop
searching for config files on the first found package.json unless it's
in a workspace. For the previous behaviour, the root deno.json needs to
be updated to be a workspace by adding `"workspace":
["./path-to-pkg-json-folder-goes-here"]`. See details in
denoland/deno_config#66

Closes #24340
Closes #24159
Closes #24161
Closes #22020
Closes #18546
Closes #16106
Closes #24160
zebreus pushed a commit to zebreus/deno that referenced this pull request Jul 8, 2024
Adds much better support for the unstable Deno workspaces as well as
support for npm workspaces. npm workspaces is still lacking in that we
only install packages into the root node_modules folder. We'll make it
smarter over time in order for it to figure out when to add node_modules
folders within packages.

This includes a breaking change in config file resolution where we stop
searching for config files on the first found package.json unless it's
in a workspace. For the previous behaviour, the root deno.json needs to
be updated to be a workspace by adding `"workspace":
["./path-to-pkg-json-folder-goes-here"]`. See details in
denoland/deno_config#66

Closes denoland#24340
Closes denoland#24159
Closes denoland#24161
Closes denoland#22020
Closes denoland#18546
Closes denoland#16106
Closes denoland#24160
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.

2 participants