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

add buildable angular library issue #256

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ testem.log
# System Files
.DS_Store
Thumbs.db

.angular
36 changes: 36 additions & 0 deletions libs/buildable-angular-library/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "nxExample",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "nx-example",
"style": "kebab-case"
}
]
},
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
]
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/buildable-angular-library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# buildable-angular-library

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test buildable-angular-library` to execute the unit tests.
22 changes: 22 additions & 0 deletions libs/buildable-angular-library/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable */
export default {
displayName: 'buildable-angular-library',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
coverageDirectory: '../../coverage/libs/buildable-angular-library',
transform: {
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
7 changes: 7 additions & 0 deletions libs/buildable-angular-library/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/libs/buildable-angular-library",
"lib": {
"entryFile": "src/index.ts"
}
}
11 changes: 11 additions & 0 deletions libs/buildable-angular-library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@nx-example/buildable-angular-library",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^15.0.0",
"@angular/core": "^15.0.0"
},
"dependencies": {
"tslib": "^2.3.0"
}
}
44 changes: 44 additions & 0 deletions libs/buildable-angular-library/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "buildable-angular-library",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/buildable-angular-library/src",
"prefix": "nx-example",
"targets": {
"build": {
"executor": "@nrwl/angular:ng-packagr-lite",
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
"options": {
"project": "libs/buildable-angular-library/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "libs/buildable-angular-library/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "libs/buildable-angular-library/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/buildable-angular-library/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": [
"libs/buildable-angular-library/**/*.ts",
"libs/buildable-angular-library/**/*.html"
]
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/buildable-angular-library/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/buildable-angular-library/buildable-angular-library.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>buildable-angular-library works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BuildableAngularLibraryComponent } from './buildable-angular-library.component';

describe('BuildableAngularLibraryComponent', () => {
let component: BuildableAngularLibraryComponent;
let fixture: ComponentFixture<BuildableAngularLibraryComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [BuildableAngularLibraryComponent],
}).compileComponents();

fixture = TestBed.createComponent(BuildableAngularLibraryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { jsLibrary } from '@nx-example/js-library';

@Component({
selector: 'nx-example-buildable-angular-library',
standalone: true,
providers: [
{
provide: 'any',
useValue: jsLibrary()
}
],
imports: [CommonModule],
templateUrl: './buildable-angular-library.component.html',
styleUrls: ['./buildable-angular-library.component.css'],
})
export class BuildableAngularLibraryComponent {}
1 change: 1 addition & 0 deletions libs/buildable-angular-library/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';
29 changes: 29 additions & 0 deletions libs/buildable-angular-library/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"target": "es2022",
"useDefineForClassFields": false,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"extends": "../../tsconfig.base.json",
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
17 changes: 17 additions & 0 deletions libs/buildable-angular-library/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": [
"src/test-setup.ts",
"src/**/*.spec.ts",
"jest.config.ts",
"src/**/*.test.ts"
],
"include": ["src/**/*.ts"]
}
7 changes: 7 additions & 0 deletions libs/buildable-angular-library/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {}
}
15 changes: 15 additions & 0 deletions libs/buildable-angular-library/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}
10 changes: 10 additions & 0 deletions libs/js-library/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@nrwl/web/babel",
{
"useBuiltIns": "usage"
}
]
]
}
18 changes: 18 additions & 0 deletions libs/js-library/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
3 changes: 3 additions & 0 deletions libs/js-library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# js-library

This library was generated with [Nx](https://nx.dev).
16 changes: 16 additions & 0 deletions libs/js-library/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "js-library",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/js-library/src",
"projectType": "library",
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/js-library/**/*.ts"]
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/js-library/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/js-library';
3 changes: 3 additions & 0 deletions libs/js-library/src/lib/js-library.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function jsLibrary(): string {
return 'js-library';
}
19 changes: 19 additions & 0 deletions libs/js-library/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}
10 changes: 10 additions & 0 deletions libs/js-library/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"include": ["src/**/*.ts"],
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
}
6 changes: 6 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@
},
"generators": {
"@nrwl/angular:application": {
"style": "css",
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nrwl/angular:library": {
"linter": "eslint",
"unitTestRunner": "jest"
},
"@nrwl/angular": {
"convert-tslint-to-eslint": {
"removeTSLintIfNoMoreTSLintTargets": true
}
},
"@nrwl/angular:component": {
"style": "css"
}
},
"defaultProject": "products",
Expand Down
Loading