Skip to content

fix(angular): Use Angular compiler to compile @sentry/angular #4641

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

Merged
merged 21 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
383509b
build(angular): Use the Angular compiler to compile the @sentry/angul…
Lms24 Feb 25, 2022
a3db0cb
Flatten directory structure, simplify tsconfig
Lms24 Feb 25, 2022
fa18a60
remove temporary workspaces, tslint config, unintended dependency cha…
Lms24 Feb 28, 2022
73876dc
ref(angular): simplify and flatten file structure
Lms24 Feb 28, 2022
69180c4
ref(angular): re-introduce tsc compile option for "legacy" package
Lms24 Feb 28, 2022
f8c09a0
ref(angular) move tsconfig option from tsconfig to tsconfig.ngc
Lms24 Feb 28, 2022
2b62152
ref(angular): fix trailing comma in tsconfig.ts
Lms24 Feb 28, 2022
ff0b19a
ref(angular): incorporate review suggestions
Lms24 Mar 1, 2022
337991f
ref(angular): exclude npm scripts from generated `package.json` file
Lms24 Mar 2, 2022
d2aa012
ref(angular): remove unnecessary devdependencies, minor review changes
Lms24 Mar 2, 2022
2c5bdc9
ref(angular): remove more unnecessary dev dependencies
Lms24 Mar 4, 2022
78746fb
ref(angular): bump node version to 10, allow rxjs 6 and 7
Lms24 Mar 11, 2022
6ce4199
add more strict angular compiler option parameters
Lms24 Mar 11, 2022
824544e
fix angular dependencies and yarn.lock after rebase
Lms24 Apr 20, 2022
e058520
adjust angular build dir and tarball structure to be more similar to …
Lms24 Apr 20, 2022
447d7ff
fix circular dep check
Lms24 Apr 20, 2022
f94bac0
fix types path
Lms24 Apr 21, 2022
7824aea
remove legacy build scripts and tsconfigs
Lms24 Apr 21, 2022
b438540
Revert "adjust angular build dir and tarball structure to be more sim…
Lms24 Apr 21, 2022
cfac731
cleanup angular.json
Lms24 Apr 21, 2022
1cb7459
set `tsconfig.ngc.json` to es2015
Lms24 Apr 21, 2022
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
27 changes: 27 additions & 0 deletions packages/angular/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* To learn more about this file see: https://angular.io/guide/workspace-config */
{
"$schema": "../../node_modules/@angular/cli/lib/config/schema.json",
"version": 1, // version of angular.json
"projects": {
"sentry-angular": {
"projectType": "library",
"root": ".",
"sourceRoot": "src",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"tsConfig": "tsconfig.ngc.json",
"project": "ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "tsconfig.ngc.json"
}
}
}
}
}
},
"defaultProject": "sentry-angular"
}
13 changes: 13 additions & 0 deletions packages/angular/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "node_modules/ng-packagr/ng-package.schema.json",
"dest": "build",
"lib": {
"entryFile": "src/index.ts",
"umdModuleIds": {
"@sentry/browser": "Sentry",
"@sentry/utils": "Sentry.util"
}
},
"whitelistedNonPeerDependencies": ["@sentry/browser", "@sentry/utils", "@sentry/types", "tslib"],
"assets": ["README.md", "LICENSE"]
}
42 changes: 20 additions & 22 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,43 @@
"engines": {
"node": ">=8"
},
"main": "cjs/index.js",
"module": "esm/index.js",
"types": "build/types/index.d.ts",
"main": "build/bundles/sentry-angular.umd.js",
"module": "build/fesm2015/sentry-angular.js",
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"@angular/common": "10.x || 11.x || 12.x || 13.x",
"@angular/core": "10.x || 11.x || 12.x || 13.x",
"@angular/router": "10.x || 11.x || 12.x || 13.x"
"@angular/router": "10.x || 11.x || 12.x || 13.x",
"rxjs": "^6.5.5 || ^7.x"
},
"dependencies": {
"@sentry/browser": "7.0.0-alpha.1",
"@sentry/types": "7.0.0-alpha.1",
"@sentry/utils": "7.0.0-alpha.1",
"rxjs": "^6.6.0",
"tslib": "^1.9.3"
"tslib": "^2.0.0"
},
"devDependencies": {
"@angular/common": "^10.0.3",
"@angular/core": "^10.0.3",
"@angular/router": "^10.0.3"
"@angular-devkit/build-angular": "~0.1002.4",
"@angular/cli": "^10.2.4",
"@angular/common": "~10.2.5",
"@angular/compiler": "^10.2.5",
"@angular/compiler-cli": "~10.2.5",
"@angular/core": "~10.2.5",
"@angular/router": "~10.2.5",
"ng-packagr": "^10.1.0",
"typescript": "~4.0.2"
},
"scripts": {
"build": "run-p build:cjs build:esm build:types",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "yarn build:ngc",
"build:ngc": "ng build --prod",
"build:dev": "run-s build",
"build:es5": "yarn build:cjs # *** backwards compatibility - remove in v7 ***",
"build:esm": "tsc -p tsconfig.esm.json",
"build:types": "tsc -p tsconfig.types.json",
"build:watch": "run-p build:cjs:watch build:esm:watch build:types:watch",
"build:cjs:watch": "tsc -p tsconfig.cjs.json --watch",
"build:dev:watch": "run-s build:watch",
"build:es5:watch": "yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***",
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:npm": "npm pack",
"build:watch": "run-p build:ngc:watch",
"build:ngc:watch": "ng build --prod --watch",
"build:npm": "npm pack ./build",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf cjs esm build coverage",
"clean": "rimraf build coverage",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/src/errorhandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHandler as AngularErrorHandler, Injectable } from '@angular/core';
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
import * as Sentry from '@sentry/browser';

import { runOutsideAngular } from './zone';
Expand All @@ -26,7 +26,7 @@ export interface ErrorHandlerOptions {
class SentryErrorHandler implements AngularErrorHandler {
protected readonly _options: ErrorHandlerOptions;

public constructor(options?: ErrorHandlerOptions) {
public constructor(@Inject('errorHandlerOptions') options?: ErrorHandlerOptions) {
this._options = {
logErrors: true,
...options,
Expand Down
8 changes: 0 additions & 8 deletions packages/angular/tsconfig.cjs.json

This file was deleted.

8 changes: 0 additions & 8 deletions packages/angular/tsconfig.esm.json

This file was deleted.

28 changes: 28 additions & 0 deletions packages/angular/tsconfig.ngc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
// This tsconfig is used when building @sentry/angular with the Angular
// compiler and `ng-packagr`. It configures a production build conforming
// to the Angular Package Format (APF).
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es2015",
"lib": ["dom", "es2015"],
"baseUrl": "./"
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true,
// As per Angular 10, the recommendation from the library creation guide
// is to disable compilation for the Ivy rendering engine in production builds
// to ensure compatibility with Angular 10.
// For Angular 11-13 applications, ngcc and the Angular linker convert the compiled JS
// at application compile time into an Ivy-compatible version which is then further used in
// the build process. This ensures compatibility with newer Angular versions than the one
// that was used to initially compile the library (Angular 10 in our case).
"enableIvy": false
}
}
10 changes: 0 additions & 10 deletions packages/angular/tsconfig.types.json

This file was deleted.

Loading