Skip to content

Commit

Permalink
fix(core): merge proejcts from globs and workpace.json
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Oct 18, 2022
1 parent 6520905 commit 272abb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
3 changes: 3 additions & 0 deletions packages/nx/src/config/workspaces.spec.ts
Expand Up @@ -50,6 +50,9 @@ describe('Workspaces', () => {
vol.fromJSON(
{
'libs/lib1/project.json': JSON.stringify(standaloneConfig),
'libs/lib2/package.json': JSON.stringify({}),
'libs/domain/lib3/package.json': JSON.stringify({}),
'libs/domain/lib4/project.json': JSON.stringify({}),
'workspace.json': JSON.stringify(config),
},
'/root'
Expand Down
28 changes: 13 additions & 15 deletions packages/nx/src/config/workspaces.ts
Expand Up @@ -77,22 +77,20 @@ export class Workspaces {
return this.cachedWorkspaceConfig;
}
const nxJson = this.readNxJson();
const workspace = buildWorkspaceConfigurationFromGlobs(
nxJson,
globForProjectFiles(this.root, nxJson, opts?._ignorePluginInference),
(path) => readJsonFile(join(this.root, path))
);

const workspaceFile = workspaceConfigName(this.root);
const workspacePath = workspaceFile
? path.join(this.root, workspaceFile)
: null;
const workspace =
workspacePath && existsSync(workspacePath)
? this.readFromWorkspaceJson()
: buildWorkspaceConfigurationFromGlobs(
nxJson,
globForProjectFiles(
this.root,
nxJson,
opts?._ignorePluginInference
),
(path) => readJsonFile(join(this.root, path))
);

if (workspaceFile) {
workspace.projects = {
...workspace.projects,
...this.readFromWorkspaceJson().projects,
};
}

assertValidWorkspaceConfiguration(nxJson);
this.cachedWorkspaceConfig = {
Expand Down

4 comments on commit 272abb4

@vercel
Copy link

@vercel vercel bot commented on 272abb4 Oct 18, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

@woppa684
Copy link

@woppa684 woppa684 commented on 272abb4 Oct 24, 2022

Choose a reason for hiding this comment

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

@vsavkin
Since upgrading from 15.0.0 to 15.0.1. I get the following warning when building:

Skipping project found at dist/libs/mylib since project mylib already exists at libs/mylib! Specify a unique name for the project to allow Nx to differentiate between the two projects.

Could this be related to this commit? If so, am I doing something wrong? I just have a workspace.json file with only mylib in it.

It finds these files in the projectGlobCache:

[
  'libs\\mylib\\project.json',
  'dist\\libs\\mylib\\package.json'
]

even though /dist should be always ignored (looking at the code). If I remove the / from /dist in ALWAYS_IGNORE then it doesn't find the package.json in dist.

@vsavkin
Copy link
Member Author

Choose a reason for hiding this comment

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

@woppa684 let me cut 15.0.2 with the fix.

Btw, you aren't using git?

@woppa684
Copy link

@woppa684 woppa684 commented on 272abb4 Oct 24, 2022

Choose a reason for hiding this comment

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

Thanks! We are, but in our company's repo structure, the frontend NodeJS repo roots are a level deeper than the GIT repo root (we combine backends and frontends in single git repo's).

Please sign in to comment.