Skip to content

Commit 129c3c6

Browse files
committed
build(angular): Use the Angular compiler to compile the @sentry/angular SDK (WEB-622)
Switch to the Angular compiler (via Angular CLI) to ensure that all Angular 1st-class support items of the SDK are compiled in a way that the library are compatible with Angular. This fixes the compilation errors when using `TraceDirective` and `TraceModule` that are currently thrown on application compilation. Uses the Angular 10 compiler which ensures compatibility with Angular 10-13 apps. FIXES GH-3282 FIXES WEB-622
1 parent 21ae9f7 commit 129c3c6

23 files changed

+6783
-4093
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
},
2929
"workspaces": [
3030
"packages/angular",
31+
"packages/angularNew",
32+
"packages/angularNew10",
3133
"packages/browser",
3234
"packages/core",
3335
"packages/ember",
@@ -67,7 +69,7 @@
6769
"jest": "^24.9.0",
6870
"karma-browserstack-launcher": "^1.5.1",
6971
"karma-firefox-launcher": "^1.1.0",
70-
"lerna": "3.13.4",
72+
"lerna": "^3.13.4",
7173
"madge": "4.0.2",
7274
"mocha": "^6.1.4",
7375
"npm-run-all": "^4.1.5",

packages/angular/.npmignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/angular/LICENSE

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/angular/angular.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "../.././node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"sentry-angular": {
7+
"projectType": "library",
8+
"root": "lib",
9+
"sourceRoot": "lib/src",
10+
"prefix": "lib",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular-devkit/build-angular:ng-packagr",
14+
"options": {
15+
"tsConfig": "lib/tsconfig.lib.json",
16+
"project": "lib/ng-package.json"
17+
},
18+
"configurations": {
19+
"production": {
20+
"tsConfig": "lib/tsconfig.lib.prod.json"
21+
}
22+
}
23+
}
24+
}
25+
}},
26+
"defaultProject": "sentry-angular"
27+
}

packages/angular/lib/ng-package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../dist",
4+
"lib": {
5+
"entryFile": "src/index.ts",
6+
"umdModuleIds": {
7+
"@sentry/browser": "Sentry",
8+
"@sentry/utils": "utils"
9+
}
10+
},
11+
"whitelistedNonPeerDependencies": [
12+
"@sentry/browser",
13+
"@sentry/utils",
14+
"@sentry/types",
15+
"tslib"
16+
],
17+
"assets": ["README.md"]
18+
}

packages/angular/lib/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@sentry/angular",
3+
"version": "6.18.0",
4+
"description": "Official Sentry SDK for Angular",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=6"
11+
},
12+
"main": "dist/index.js",
13+
"module": "esm/index.js",
14+
"types": "dist/index.d.ts",
15+
"publishConfig": {
16+
"access": "public"
17+
},
18+
"peerDependencies": {
19+
"@angular/common": "10.x || 11.x || 12.x || 13.x",
20+
"@angular/core": "10.x || 11.x || 12.x || 13.x",
21+
"@angular/router": "10.x || 11.x || 12.x || 13.x"
22+
},
23+
"dependencies": {
24+
"@sentry/browser": "6.18.0",
25+
"@sentry/types": "6.18.0",
26+
"@sentry/utils": "6.18.0",
27+
"tslib": "^2.0.0"
28+
}
29+
}

packages/angular/src/errorhandler.ts renamed to packages/angular/lib/src/errorhandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpErrorResponse } from '@angular/common/http';
2-
import { ErrorHandler as AngularErrorHandler, Injectable } from '@angular/core';
2+
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
33
import * as Sentry from '@sentry/browser';
44

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

29-
public constructor(options?: ErrorHandlerOptions) {
29+
public constructor(@Inject('errorHandlerOptions') options?: ErrorHandlerOptions) {
3030
this._options = {
3131
logErrors: true,
3232
...options,
File renamed without changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*
2+
* Public API Surface of angular
3+
*/
4+
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
2+
{
3+
"extends": "../tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "../../out-tsc/lib",
6+
"target": "es2015",
7+
"declaration": true,
8+
"declarationMap": true,
9+
"inlineSources": true,
10+
"types": [],
11+
"lib": [
12+
"dom",
13+
"es2018"
14+
]
15+
},
16+
"angularCompilerOptions": {
17+
"skipTemplateCodegen": true,
18+
"strictMetadataEmit": true,
19+
"enableResourceInlining": true
20+
},
21+
"exclude": [
22+
"src/test.ts",
23+
"**/*.spec.ts"
24+
]
25+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
2+
{
3+
"extends": "./tsconfig.lib.json",
4+
"compilerOptions": {
5+
"declarationMap": false
6+
},
7+
"angularCompilerOptions": {
8+
"enableIvy": false,
9+
// "compilationMode": "partial"
10+
}
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
2+
{
3+
"extends": "../tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "../../out-tsc/spec",
6+
"types": [
7+
"jasmine"
8+
]
9+
},
10+
"files": [
11+
"src/test.ts"
12+
],
13+
"include": [
14+
"**/*.spec.ts",
15+
"**/*.d.ts"
16+
]
17+
}

packages/angular/lib/tslint.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "../../tslint.json",
3+
"rules": {
4+
"directive-selector": [
5+
true,
6+
"attribute",
7+
"lib",
8+
"camelCase"
9+
],
10+
"component-selector": [
11+
true,
12+
"element",
13+
"lib",
14+
"kebab-case"
15+
]
16+
}
17+
}

packages/angular/package.json

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,57 @@
2020
"@angular/core": "10.x || 11.x || 12.x || 13.x",
2121
"@angular/router": "10.x || 11.x || 12.x || 13.x"
2222
},
23+
"private": true,
24+
2325
"dependencies": {
24-
"@sentry/browser": "6.18.0",
25-
"@sentry/types": "6.18.0",
26-
"@sentry/utils": "6.18.0",
27-
"rxjs": "^6.6.0",
28-
"tslib": "^1.9.3"
26+
"@angular/animations": "~10.2.5",
27+
"@angular/common": "~10.2.5",
28+
"@angular/compiler": "~10.2.5",
29+
"@angular/core": "~10.2.5",
30+
"@angular/forms": "~10.2.5",
31+
"@angular/platform-browser": "~10.2.5",
32+
"@angular/platform-browser-dynamic": "~10.2.5",
33+
"@angular/router": "~10.2.5",
34+
"@sentry/browser": "^6.18.0",
35+
"@sentry/types": "^6.18.0",
36+
"@sentry/utils": "^6.18.0",
37+
"rxjs": "~6.6.0",
38+
"tslib": "^2.0.0",
39+
"zone.js": "~0.10.2"
2940
},
3041
"devDependencies": {
31-
"@angular/common": "^10.0.3",
32-
"@angular/core": "^10.0.3",
33-
"@angular/router": "^10.0.3"
42+
"@angular-devkit/build-angular": "~0.1002.4",
43+
"@angular/cli": "~10.2.4",
44+
"@angular/compiler-cli": "~10.2.5",
45+
"@types/jasmine": "~3.5.0",
46+
"@types/jasminewd2": "~2.0.3",
47+
"@types/node": "^12.11.1",
48+
"codelyzer": "^6.0.0",
49+
"jasmine-core": "~3.6.0",
50+
"jasmine-spec-reporter": "~5.0.0",
51+
"karma": "~5.0.0",
52+
"karma-chrome-launcher": "~3.1.0",
53+
"karma-coverage-istanbul-reporter": "~3.0.2",
54+
"karma-jasmine": "~4.0.0",
55+
"karma-jasmine-html-reporter": "~1.5.0",
56+
"ng-packagr": "^10.1.0",
57+
"protractor": "~7.0.0",
58+
"ts-node": "~8.3.0",
59+
"tslint": "~6.1.0",
60+
"typescript": "~4.0.2"
3461
},
3562
"scripts": {
36-
"build": "run-p build:cjs build:esm",
37-
"build:cjs": "tsc -p tsconfig.cjs.json",
63+
"build": "run-p build:esm #**not necessary** build:cjs",
64+
"build:cjs": "#**not necessary** tsc -p tsconfig.cjs.json",
3865
"build:dev": "run-s build",
39-
"build:es5": "yarn build:cjs # *** backwards compatibility - remove in v7 ***",
40-
"build:esm": "tsc -p tsconfig.esm.json",
41-
"build:watch": "run-p build:cjs:watch build:esm:watch",
42-
"build:cjs:watch": "tsc -p tsconfig.cjs.json --watch",
66+
"build:es5": "#**not necessary** yarn build:cjs # *** backwards compatibility - remove in v7 ***",
67+
"build:esm": "ng build --prod",
68+
"build:watch": "run-p build:esm:watch #build:cjs:watch",
69+
"build:cjs:watch": "#**not necessary** tsc -p tsconfig.cjs.json --watch",
4370
"build:dev:watch": "run-s build:watch",
44-
"build:es5:watch": "yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***",
45-
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
46-
"circularDepCheck": "madge --circular src/index.ts",
71+
"build:es5:watch": "#**not necessary** yarn build:cjs:watch # *** backwards compatibility - remove in v7 ***",
72+
"build:esm:watch": "ng build --prod --watch",
73+
"circularDepCheck": "madge --circular projects/sentry-angular/src/index.ts #TODO change to final index path!!",
4774
"clean": "rimraf dist esm build coverage",
4875
"fix": "run-s fix:eslint fix:prettier",
4976
"fix:eslint": "eslint . --format stylish --fix",
@@ -52,7 +79,7 @@
5279
"lint": "run-s lint:prettier lint:eslint",
5380
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
5481
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
55-
"pack": "npm pack"
82+
"pack": "cd ./dist && npm pack"
5683
},
5784
"volta": {
5885
"extends": "../../package.json"

packages/angular/tsconfig.cjs.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/angular/tsconfig.esm.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/angular/tsconfig.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
{
2-
"extends": "../../tsconfig.json",
3-
4-
"include": ["src/**/*"],
5-
2+
"compileOnSave": false,
63
"compilerOptions": {
7-
// package-specific options
8-
"experimentalDecorators": true
4+
"baseUrl": "./",
5+
"outDir": "./dist/out-tsc",
6+
"sourceMap": true,
7+
"declaration": false,
8+
"downlevelIteration": true,
9+
"experimentalDecorators": true,
10+
"moduleResolution": "node",
11+
"importHelpers": true,
12+
"target": "es2015",
13+
"module": "es2020",
14+
"lib": [
15+
"es2018",
16+
"dom"
17+
],
18+
"paths": {
19+
"sentry-angular": [
20+
"dist/sentry-angular/sentry-angular",
21+
"dist/sentry-angular"
22+
]
23+
}
924
}
1025
}

packages/angular/tsconfig.test.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)