Skip to content

Commit 678f77b

Browse files
committed
fix: Build for browser
1 parent b6c429a commit 678f77b

File tree

4 files changed

+130
-62
lines changed

4 files changed

+130
-62
lines changed

packages/browser/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"main": "dist/index.js",
1313
"module": "esm/index.js",
14+
"browser": "dist/index.js",
1415
"types": "dist/index.d.ts",
1516
"publishConfig": {
1617
"access": "public"
@@ -41,21 +42,23 @@
4142
"prettier": "^1.16.4",
4243
"prettier-check": "^2.0.0",
4344
"rimraf": "^2.6.3",
44-
"rollup": "^1.2.1",
45+
"rollup": "^1.4.0",
46+
"rollup-plugin-commonjs": "^9.2.1",
4547
"rollup-plugin-license": "^0.8.1",
46-
"rollup-plugin-typescript2": "^0.19.2",
48+
"rollup-plugin-node-resolve": "^4.0.1",
4749
"rollup-plugin-terser": "^4.0.4",
50+
"rollup-plugin-typescript2": "^0.19.2",
4851
"sinon": "^7.2.3",
4952
"tslint": "^5.12.1",
5053
"typescript": "^3.3.3",
5154
"webpack": "^4.29.5"
5255
},
5356
"scripts": {
54-
"build": "run-p build:esm build:es5",
57+
"build": "run-s build:esm build:es5",
5558
"build:es5": "rollup --config",
5659
"build:esm": "tsc -p tsconfig.esm.json",
5760
"build:watch": "rollup --config --watch",
58-
"clean": "rimraf dist coverage .rpt2_cache build",
61+
"clean": "rimraf dist coverage .rpt2_cache build esm",
5962
"lint": "run-s lint:prettier lint:tslint",
6063
"lint:prettier": "prettier-check \"{src,test}/**/*.ts\"",
6164
"lint:tslint": "tslint -t stylish -p .",

packages/browser/rollup.config.js

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { terser } from 'rollup-plugin-terser';
22
import typescript from 'rollup-plugin-typescript2';
33
import license from 'rollup-plugin-license';
4+
import resolve from 'rollup-plugin-node-resolve';
5+
import commonjs from 'rollup-plugin-commonjs';
46

57
const commitHash = require('child_process')
68
.execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
@@ -19,6 +21,32 @@ const terserInstance = terser({
1921
},
2022
});
2123

24+
const plugins = [
25+
typescript({
26+
tsconfig: 'tsconfig.build.json',
27+
tsconfigOverride: {
28+
compilerOptions: {
29+
declaration: false,
30+
module: 'ES2015',
31+
paths: {
32+
'@sentry/utils/*': ['../utils/src/*'],
33+
'@sentry/core': ['../core/src'],
34+
'@sentry/hub': ['../hub/src'],
35+
'@sentry/types': ['../types/src'],
36+
'@sentry/minimal': ['../minimal/src'],
37+
},
38+
},
39+
},
40+
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
41+
}),
42+
resolve({
43+
browser: true,
44+
module: false,
45+
modulesOnly: true,
46+
}),
47+
commonjs(),
48+
];
49+
2250
const bundleConfig = {
2351
input: 'src/index.ts',
2452
output: {
@@ -28,22 +56,7 @@ const bundleConfig = {
2856
},
2957
context: 'window',
3058
plugins: [
31-
typescript({
32-
tsconfig: 'tsconfig.build.json',
33-
tsconfigOverride: {
34-
compilerOptions: {
35-
declaration: false,
36-
paths: {
37-
'@sentry/utils/*': ['../utils/src/*'],
38-
'@sentry/core': ['../core/src'],
39-
'@sentry/hub': ['../hub/src'],
40-
'@sentry/types': ['../types/src'],
41-
'@sentry/minimal': ['../minimal/src'],
42-
},
43-
},
44-
},
45-
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
46-
}),
59+
...plugins,
4760
license({
4861
sourcemap: true,
4962
banner: `/*! @sentry/browser <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
@@ -61,32 +74,8 @@ export default [
6174
interop: false,
6275
sourcemap: true,
6376
},
64-
external: [
65-
'@sentry/core',
66-
'@sentry/hub',
67-
'@sentry/minimal',
68-
'@sentry/types',
69-
'@sentry/utils/logger',
70-
'@sentry/utils/misc',
71-
'@sentry/utils/is',
72-
'@sentry/utils/supports',
73-
'@sentry/utils/syncpromise',
74-
'@sentry/utils/object',
75-
'@sentry/utils/string',
76-
'@sentry/utils/error',
77-
'@sentry/utils/promisebuffer',
78-
'tslib',
79-
],
80-
plugins: [
81-
typescript({
82-
tsconfig: 'tsconfig.build.json',
83-
tsconfigOverride: {
84-
compilerOptions: {
85-
rootDir: 'src',
86-
},
87-
},
88-
}),
89-
],
77+
external: ['tslib'],
78+
plugins,
9079
},
9180
Object.assign({}, bundleConfig, {
9281
output: Object.assign({}, bundleConfig.output, {

packages/browser/tsconfig.build.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"outDir": "dist",
6-
"target": "es6",
7-
"module": "es6"
5+
"outDir": "dist"
86
},
97
"include": ["src/**/*"]
108
}

0 commit comments

Comments
 (0)