nx-enforce-module-boundaries for source project with multiple tags
See original GitHub issuePrerequisites
I have a workspace that contains some projects with multiple tags likes below nx.json file
{
"booking-api": {
"tags": ["type:app", "scope:server", "service:booking"]
},
"booking-data-access": {
"tags": ["service:booking", "scope:server"]
},
"booking-api-interfaces": {
"tags": ["service:booking"]
}
}
The enforce module boundaries rule is defined in the tslint.json file as below
"nx-enforce-module-boundaries": [
true,
{
"allow": [],
"depConstraints": [
{
"sourceTag": "service:booking",
"onlyDependOnLibsWithTags": ["service:booking"]
},
{
"sourceTag": "type:app",
"onlyDependOnLibsWithTags": ["scope:shared", "scope:util"]
},
{
"sourceTag": "scope:server",
"onlyDependOnLibsWithTags": ["scope:server", "scope:shared", "scope:util"]
},
{
"sourceTag": "scope:util",
"onlyDependOnLibsWithTags": ["scope:util"]
}
]
}
]
From the booking-api
app, I tried to import the data access from the booking-api-interfaces
, I am getting an error
A project tagged with "type:app" can only depend on libs tagged with "scope:shared", "scope:util" (nx-enforce-module-boundaries)tslint(1)
Expected Behavior
booking-api
and booking-data-access
have same tag service:booking
so we should allow import without error.
Current Behavior
Lint error that prevents importing. I think right now the link only check the first tag of the source project, so the service
tag is ignored.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:22 (5 by maintainers)
Top Results From Across the Web
Enforce Project Boundaries - Nx
Nx comes with a generic mechanism for expressing constraints on project dependencies: tags. First, use your project configuration (in project.json or package.
Read more >Decomposing a project using Nx - Part 1 - This Dot Labs
2 approaches for decomposing a project ... You can find the source code on my repository. ... This is where Nx tags comes...
Read more >Enforcing Dependency Constraints Within Service ... - HackMD
In the tslint.json notice, I am defining source tag for sales. Then I am also defining a source tag per project. For example...
Read more >Fixing Nrwl Nx Monorepo Workspace Dependency Graph Error
“Error: A project without tags cannot depend on any libraries ... "nx-enforce-module-boundaries": [ true, ... There are 2 options.
Read more >How does nx enforce module boundaries? | by Olavi Sau
The target project is where the imported file is in. It has gathered the constraints for the source project, by comparing each project...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nx boundary rules work as AND vertically and OR horizontally. In the following example:
each project imported into project marked with
scope:first
will have to defined innx.json
with:scope:second
ORscope:third
ANDtype:one
ORtype:two
ORtype:three
At least one tag in the
onlyDependOnLibsWithTags
has to be satisfied (unless defined as*
) and all of the rules apply.In the original code from @hoang-innomizetech, he defined restriction for all
type:app
to only importscope:shared
orscope:util
(same for third rule forscope:server
), but then tried to importbooking-api-interfaces
which included none of these.If you get stuck, try reducing the tags and plan them carefully (correct naming is half of the work). If the boundaries start to feel too strict, you have probably overdone it.
Hi, I’m having a similar issue. I’m trying to setup my project based on this article which is using a similar structure described on the initial issue. But this boundaries are not working as expected on both eslint and tslint.