-
Notifications
You must be signed in to change notification settings - Fork 68
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
Support for non-modular packages in tests and workspace resolver #2167
Conversation
🦋 Changeset detectedLatest commit: a39a00c The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
LGTM, although I would suggest we update the README.md
for workspace-resolver, so that this change is publicly documented (mainly the existence of the new type
field and it's purpose).
@@ -153,7 +152,7 @@ export function analyzeWorkspaceDependencies( | |||
// Exclude the root when analyzing package inter-dependencies | |||
const packagesWithoutRoot = Array.from(workspacePackages.entries()).filter( | |||
([, pkg]) => { | |||
return pkg.modular.type !== 'root'; | |||
return pkg.modular?.type !== 'root'; |
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.
Minor thing, but this filter can be inlined to the next forEach
on line 160 to avoid looping through the workspace twice.
As type
has been added to the ModularWorkspacePackage
, this can now be:
return pkg.modular?.type !== 'root'; | |
return pkg.type !== 'root'; |
@@ -65,7 +65,8 @@ export async function resolveWorkspace( | |||
const pkgPath = packageJsonPath(root); | |||
|
|||
const json = await readPackageJson(isRoot, workingDirToUse, pkgPath); | |||
const isModularRoot = json.modular?.type === 'root'; | |||
const type = json.modular?.type || undefined; |
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.
Do we need to cater for converting to undefined
any modular.type
that has been explicitly set to null
?
const type = json.modular?.type || undefined; | |
const type = json.modular?.type; |
Closing as it needs to be discussed further |
This PR stems from the discussion here: #2168 and from the necessity of either:
a) not list non-modular workspaces in workspace-resolver or
b) list them, but clarifying that they are non-modular.
Since we don't want to impact how
mismatchedWorkspaceDependencies
works and we like the idea of executing workspace commands on non-modular workspaces, this PR modifies the output of workspace-resolver, adding atype
field, and adds support for non-modular (from now: extraneous) workspaces inmodular test
. In particular,modular test
will:--package
,--changed
,--ancestors
), in addition to the usual modular packagesyarn workspace <extraneous-workspace-name> test
for each one of them, after running the regular jest testsI also refactored the
test
command to factor out utilities and tasks.Note: The PR seems huge, but most of the content are new test fixtures to simulate a monorepo with examples of failing, successful and non-existent test scripts in extraneous workspaces, with regular Modular workspace ancestors.
TASKS
type
is first-classtest
script for non-modular workspaces or warn