8000 feat: esm build (#1779) · productinfo/sentry-javascript@b73d9e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit b73d9e9

Browse files
cromefireHazAT
authored andcommitted
feat: esm build (getsentry#1779)
* Added esm build and fixed some minor issues Signed-off-by: cromefire <tim.langhorst@outlook.de> * Fixed some ones prettier mismatch Signed-off-by: cromefire <tim.langhorst@outlook.de> * Utils es5 only Signed-off-by: cromefire <tim.langhorst@outlook.de> * esm for utils and import rewrites Signed-off-by: cromefire <tim.langhorst@outlook.de> * improved and documented rewrite regex Signed-off-by: cromefire <tim.langhorst@outlook.de> * Removed arrow function to support node 6 Signed-off-by: cromefire <tim.langhor 8000 st@outlook.de> * Trying to fix node 6 problem Signed-off-by: cromefire <tim.langhorst@outlook.de> * Added readme entry Signed-off-by: cromefire <tim.langhorst@outlook.de> * Mark as free of side-effects Signed-off-by: cromefire <tim.langhorst@outlook.de> * Fixed wrong bool value for side-effects Signed-off-by: cromefire <tim.langhorst@outlook.de> * Reordered .gitignore Signed-off-by: cromefire <tim.langhorst@outlook.de> * Removed as default for module builds Signed-off-by: cromefire <tim.langhorst@outlook.de> * Readded raven.js Signed-off-by: cromefire <tim.langhorst@outlook.de> * Added esm to browser .gitignore Signed-off-by: cromefire <tim.langhorst@outlook.de>
1 parent aff8415 commit b73d9e9

26 files changed

+184
-30
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node_modules/
44
# build and test
55
build/
66
packages/*/dist/
7+
/packages/*/esm
78
coverage/
89
scratch/
910
*.pyc
@@ -27,3 +28,6 @@ lerna-debug.log
2728

2829
docs
2930
lint-results.json
31+
32+
# legacy
33+
!/packages/raven-js/dist

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ init({
7272
captureMessage('Hello, world!');
7373
```
7474

75+
If you want sentry to be customized for the browsers you want to support use the `esm` build:
76+
```javascript
77+
import { init, captureMessage } from '@sentry/browser/esm';
78+
```
79+
80+
and add it to your babel/... build, if you want to support older browsers
81+
82+
> TIP: You can use [`<script type="module" str="newbrowser.js">` +
83+
`<script nomodule src="oldbrowser.js">`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#Module_Fallback)
84+
to provide builds for newer and older browsers
85+
7586
## Other Packages
7687

7788
Besides the high-level SDKs, this repository contains shared packages, helpers and configuration used for SDK

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"private": true,
33
"scripts": {
44
"build": "lerna run --stream --concurrency 1 --sort build",
5+
"build:es5": "lerna run --stream --concurrency 1 --sort build:es5",
6+
"build:esm": "lerna run --stream --concurrency 1 --sort build:esm",
57
"build:watch": "lerna run build:watch --stream --no-sort --concurrency 9999",
68
"clean": "lerna run --stream clean",
79
"fix": "lerna run --stream --concurrency 1 fix",
@@ -39,7 +41,7 @@
3941
"npm-run-all": "^4.1.2",
4042
"prettier": "^1.14.0",
4143
"prettier-check": "^2.0.0",
42-
"replace-in-file": "^3.4.0",
44+
"replace-in-file": "^3.4.2",
4345
"rimraf": "^2.6.2",
4446
"sinon": "^7.1.1",
4547
"ts-jest": "^23.10.5",

packages/browser/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*
22
!/dist/**/*
33
!/build/**/*
4+
!/esm/**/*

packages/browser/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@sentry/browser",
33
"version": "4.4.2",
44
"description": "Offical Sentry SDK for browsers",
5-
"repository": "git://github.com/getsentry/raven-js.git",
6-
"homepage": "https://github.com/getsentry/raven-js/tree/master/packages/browser",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
77
"author": "Sentry",
88
"license": "BSD-3-Clause",
99
"engines": {
@@ -52,7 +52,11 @@
5252
"webpack": "^4.26.0"
5353
},
5454
"scripts": {
55-
"build": "rollup --config",
55+
"build": "run-p build:esm build:es5",
56+
"build:es5": "rollup --config",
57+
"build:esm": "run-s build:esm:transpile build:esm:rewrite",
58+
"build:esm:transpile": "tsc -p tsconfig.esm.json",
59+
"build:esm:rewrite": "node ../../scripts/esm-rewrite.js",
5660
"build:watch": "rollup --config --watch",
5761
"clean": "rimraf dist coverage .rpt2_cache build",
5862
"lint": "run-s lint:prettier lint:tslint",
@@ -71,5 +75,6 @@
7175
"size:check": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print $1,\"kB\";}'",
7276
"version": "node ../../scripts/versionbump.js src/version.ts"
7377
},
74-
"gitHead": "a91da22f8bd3bddb38fab7f868326e376da82d4d"
78+
"gitHead": "a91da22f8bd3bddb38fab7f868326e376da82d4d",
79+
"sideEffects": false
7580
}

packages/browser/tsconfig.esm.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../tsconfig.esm.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"outDir": "esm"
6+
},
7+
"include": ["src/**/*"]
8+
}

packages/core/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*
22
!/dist/**/*
3+
!/esm/**/*

packages/core/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@sentry/core",
33
"version": "4.4.2",
44
"description": "Base implementation for all Sentry JavaScript SDKs",
5-
"repository": "git://github.com/getsentry/raven-js.git",
6-
"homepage": "https://github.com/getsentry/raven-js/tree/master/packages/core",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
77
"author": "Sentry",
88
"license": "BSD-3-Clause",
99
"engines": {
@@ -31,7 +31,11 @@
3131
"typescript": "^3.2.0"
3232
},
3333
"scripts": {
34-
"build": "tsc -p tsconfig.build.json",
34+
"build": "run-p build:es5 build:esm",
35+
"build:es5": "tsc -p tsconfig.build.json",
36+
"build:esm": "run-s build:esm:transpile build:esm:rewrite",
37+
"build:esm:transpile": "tsc -p tsconfig.esm.json",
38+
"build:esm:rewrite": "node ../../scripts/esm-rewrite.js",
3539
"build:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
3640
"clean": "rimraf dist coverage",
3741
"lint": "run-s lint:prettier lint:tslint",
@@ -64,5 +68,6 @@
6468
}
6569
}
6670
},
67-
"gitHead": "a91da22f8bd3bddb38fab7f868326e376da82d4d"
71+
"gitHead": "a91da22f8bd3bddb38fab7f868326e376da82d4d",
72+
"sideEffects": false
6873
}

packages/core/src/integration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ export function setupIntegration(integration: Integration, options: Options): vo
5757
} catch (_Oo) {
5858
/** @deprecated */
5959
// TODO: Remove in v5
60-
logger.warn(`Integration ${getIntegrationName(integration)}: The install method is deprecated. Use "setupOnce".`);
6160

6261
// tslint:disable:deprecation
6362
if (integration.install) {
63+
logger.warn(`Integration ${getIntegrationName(integration)}: The install method is deprecated. Use "setupOnce".`);
6464
integration.install(options);
6565
}
6666
// tslint:enable:deprecation

packages/core/src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface Options {
5050
* If this is set to false, default integrations will not be added, otherwise this will internally be set to the
5151
* recommended default integrations.
5252
*/
53-
defaultIntegrations?: boolean | Integration[];
53+
defaultIntegrations?: false | Integration[];
5454

5555
/**
5656
* List of integrations that should be installed after SDK was initialized.

0 commit comments

Comments
 (0)
0