Skip to content

Commit

Permalink
checkpoint: outlined dbx-web/calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
dereekb committed Dec 3, 2022
1 parent 4635fb1 commit bf283c6
Show file tree
Hide file tree
Showing 67 changed files with 2,046 additions and 1,477 deletions.
23 changes: 7 additions & 16 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Example: `nx generate @nrwl/node:library --name=fetch --buildable --publishable
This example will end up as a child of @dereekb/util.

## Creating an Angular Library

Example: `nx generate @nrwl/angular:library --name=dbx-firebase --buildable --publishable --importPath @dereekb/dbx-firebase`

### Creating a child Angular Library
Example: `nx generate @nrwl/angular:library --name=calendar --buildable --publishable --importPath @dereekb/dbx-web/calendar --directory=dbx-web`

## Creating a NestJS Library

### Creating a child NestJS Library
Expand Down Expand Up @@ -234,15 +236,9 @@ Steps/Checklist:
## Creating the Project
This example will follow the creation of dbx-form/mapbox.

Example: `nx generate @nrwl/angular:library --name=dbx-form-mapbox --buildable --publishable --importPath @dereekb/dbx-form/mapbox --directory=dbx-form/mapbox`

This will build a new library in the directory `packages/dbx-form/mapbox/dbx-form-mapbox`, but we will want to move it to `packages/dbx-form/mapbox` instead.

`workspace.json` will need to be update to point to the proper path:
Example: `nx generate @nrwl/angular:library --name=mapbox --buildable --publishable --importPath @dereekb/dbx-form/mapbox --directory=dbx-form`

```
"dbx-form-mapbox": "packages/dbx-form/mapbox",
```
This will build a new library in the directory `packages/dbx-form/mapbox`. There are several changes that need to be made for it to be properly integrated into the project though and setup to build/export with the parent project. Our example library here will be distributed with `packages/dbx-form`.

## Parent Project Changes
The "parent project" (`dbx-form` in this case) needs to be updated to ignore building this project's files.
Expand Down Expand Up @@ -291,11 +287,6 @@ For angular projects:
## New/Child Project Changes
We now need to configure the project to build and be used properly. Remember, the generated path was one level too deep, so we will need to update all the paths to reflect the new changes.

### Path Replacement
Search `packages/dbx-form/mapbox/dbx-form-mapbox` and replace it with `packages/dbx-form/mapbox`.

There will also be several relative paths that are `../../../../` that need to be replaced to `../../../` within the newly created project. Some files include `ng-package.json`, `project.json`, `tsconfig.spec.json`, `tsconfig.lib.json` and `tsconfig.json`.

### jest.config.ts
Since the dbx-components library has a lot of configuration setup in `jest.preset.ts`, we can simplify the setup here. Note, this is ONLY for this library. Your own project and other projects may be configured differently.

Expand All @@ -307,7 +298,7 @@ Since the dbx-components library has a lot of configuration setup in `jest.prese
module.exports = {
displayName: 'dbx-form-mapbox',
preset: '../../../jest.preset.ts',
coverageDirectory: '../../../../coverage/packages/dbx-form/mapbox',
coverageDirectory: '../../../coverage/packages/dbx-form/mapbox',
};
```

Expand All @@ -320,7 +311,7 @@ Change `build` to `build-base` in the child `dbx-form-mapbox` project.json.
Add the following line to `build-base`:

```
"dependsOn": []
"dependsOn": []
```

This will prevent the `build-base` step from potentially calling a build-loop. Since `dbx-form-mapbox` is always built after the parent projects, this is ok. In some cases where this has dependencies that may not be build yet, we can add them as dependencies of `dbx-form` so they're built in the proper order.
Expand Down
1 change: 1 addition & 0 deletions apps/demo-api/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "demo-api",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/demo-api/src",
"projectType": "application",
Expand Down
1 change: 1 addition & 0 deletions apps/demo-e2e/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "demo-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/demo-e2e/src",
"projectType": "application",
Expand Down
1 change: 1 addition & 0 deletions apps/demo/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "demo",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/demo/src",
Expand Down
1 change: 1 addition & 0 deletions components/demo-components/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "demo-components",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "components/demo-components/src",
Expand Down
1 change: 1 addition & 0 deletions components/demo-firebase/project.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "demo-firebase",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "components/demo-firebase/src",
"projectType": "library",
Expand Down
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;

module.exports = { ...nxPreset };
3 changes: 2 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"dependsOn": ["build"]
},
"test": {
"dependsOn": ["build"]
"dependsOn": ["build"],
"inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"]
},
"publish": {
"dependsOn": ["build"]
Expand Down
Loading

0 comments on commit bf283c6

Please sign in to comment.