Skip to content

Commit 6e8bd06

Browse files
committed
ref: Add bundle build
1 parent b496298 commit 6e8bd06

File tree

7 files changed

+212
-29
lines changed

7 files changed

+212
-29
lines changed

.craft.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ targets:
3838
onlyIfPresent: /^sentry-react-.*\.tgz$/
3939
config:
4040
canonical: 'npm:@sentry/react'
41+
- name: registry
42+
type: sdk
43+
onlyIfPresent: /^sentry-vue-.*\.tgz$/
44+
config:
45+
canonical: 'npm:@sentry/vue'
4146
- name: registry
4247
type: sdk
4348
onlyIfPresent: /^sentry-gatsby-.*\.tgz$/

packages/vue/.npmignore

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

packages/vue/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"tslib": "^1.9.3"
2525
},
2626
"peerDependencies": {
27-
"vue": "2.x || 3.x"
27+
"vue": "2.x"
2828
},
2929
"devDependencies": {
3030
"@sentry-internal/eslint-config-sdk": "5.27.4",
@@ -35,11 +35,19 @@
3535
"prettier": "1.19.0",
3636
"react": "^16.0.0",
3737
"rimraf": "^2.6.3",
38+
"rollup": "^1.10.1",
39+
"rollup-plugin-commonjs": "^9.3.4",
40+
"rollup-plugin-license": "^0.8.1",
41+
"rollup-plugin-node-resolve": "^4.2.3",
42+
"rollup-plugin-terser": "^4.0.4",
43+
"rollup-plugin-typescript2": "^0.21.0",
3844
"typescript": "3.7.5",
3945
"vue": "^2.6"
4046
},
4147
"scripts": {
42-
"build": "run-p build:es5 build:esm",
48+
"build": "run-p build:es5 build:esm build:bundle",
49+
"build:bundle": "rollup --config",
50+
"build:bundle:watch": "rollup --config --watch",
4351
"build:es5": "tsc -p tsconfig.build.json",
4452
"build:esm": "tsc -p tsconfig.esm.json",
4553
"build:watch": "run-p build:watch:es5 build:watch:esm",

packages/vue/rollup.config.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { terser } from 'rollup-plugin-terser';
2+
import typescript from 'rollup-plugin-typescript2';
3+
import license from 'rollup-plugin-license';
4+
import resolve from 'rollup-plugin-node-resolve';
5+
import commonjs from 'rollup-plugin-commonjs';
6+
7+
const commitHash = require('child_process')
8+
.execSync('git rev-parse --short HEAD', { encoding: 'utf-8' })
9+
.trim();
10+
11+
const terserInstance = terser({
12+
mangle: {
13+
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
14+
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
15+
// We need those full names to correctly detect our internal frames for stripping.
16+
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
17+
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
18+
properties: {
19+
regex: /^_[^_]/,
20+
},
21+
},
22+
});
23+
24+
const paths = {
25+
'@sentry/utils': ['../utils/src'],
26+
'@sentry/core': ['../core/src'],
27+
'@sentry/hub': ['../hub/src'],
28+
'@sentry/types': ['../types/src'],
29+
'@sentry/minimal': ['../minimal/src'],
30+
'@sentry/browser': ['../browser/src'],
31+
};
32+
33+
const plugins = [
34+
typescript({
35+
tsconfig: 'tsconfig.build.json',
36+
tsconfigOverride: {
37+
compilerOptions: {
38+
declaration: false,
39+
declarationMap: false,
40+
module: 'ES2015',
41+
paths,
42+
},
43+
},
44+
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
45+
}),
46+
resolve({
47+
mainFields: ['module'],
48+
}),
49+
commonjs(),
50+
];
51+
52+
const bundleConfig = {
53+
input: 'src/index.ts',
54+
output: {
55+
format: 'iife',
56+
name: 'Sentry',
57+
sourcemap: true,
58+
strict: false,
59+
},
60+
context: 'window',
61+
plugins: [
62+
...plugins,
63+
license({
64+
sourcemap: true,
65+
banner: `/*! @sentry/vue <%= pkg.version %> (${commitHash}) | https://github.com/getsentry/sentry-javascript */`,
66+
}),
67+
],
68+
};
69+
70+
export default [
71+
// ES5 Browser Tracing Bundle
72+
{
73+
...bundleConfig,
74+
input: 'src/index.bundle.ts',
75+
output: {
76+
...bundleConfig.output,
77+
file: 'build/bundle.vue.js',
78+
},
79+
plugins: bundleConfig.plugins,
80+
},
81+
{
82+
...bundleConfig,
83+
input: 'src/index.bundle.ts',
84+
output: {
85+
...bundleConfig.output,
86+
file: 'build/bundle.vue.min.js',
87+
},
88+
// Uglify has to be at the end of compilation, BUT before the license banner
89+
plugins: bundleConfig.plugins
90+
.slice(0, -1)
91+
.concat(terserInstance)
92+
.concat(bundleConfig.plugins.slice(-1)),
93+
},
94+
];

packages/vue/src/eventprocessor.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { addGlobalEventProcessor, SDK_VERSION } from '@sentry/browser';
2+
3+
/**
4+
* A global side effect that makes sure Sentry events that user
5+
* `@sentry/react` will correctly have Sentry events associated
6+
* with it.
7+
*/
8+
export function createVueEventProcessor(): void {
9+
if (addGlobalEventProcessor) {
10+
addGlobalEventProcessor(event => {
11+
event.sdk = {
12+
...event.sdk,
13+
name: 'sentry.javascript.vue',
14+
packages: [
15+
...((event.sdk && event.sdk.packages) || []),
16+
{
17+
name: 'npm:@sentry/vue',
18+
version: SDK_VERSION,
19+
},
20+
],
21+
version: SDK_VERSION,
22+
};
23+
24+
return event;
25+
});
26+
}
27+
}

packages/vue/src/index.bundle.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { createVueEventProcessor } from './eventprocessor';
2+
3+
export {
4+
Breadcrumb,
5+
Request,
6+
SdkInfo,
7+
Event,
8+
Exception,
9+
Response,
10+
Severity,
11+
StackFrame,
12+
Stacktrace,
13+
Status,
14+
Thread,
15+
User,
16+
} from '@sentry/types';
17+
18+
export {
19+
addGlobalEventProcessor,
20+
addBreadcrumb,
21+
captureException,
22+
captureEvent,
23+
captureMessage,
24+
configureScope,
25+
getHubFromCarrier,
26+
getCurrentHub,
27+
Hub,
28+
Scope,
29+
setContext,
30+
setExtra,
31+
setExtras,
32+
setTag,
33+
setTags,
34+
setUser,
35+
startTransaction,
36+
Transports,
37+
withScope,
38+
} from '@sentry/browser';
39+
40+
export { BrowserOptions } from '@sentry/browser';
41+
export { BrowserClient, ReportDialogOptions } from '@sentry/browser';
42+
export {
43+
defaultIntegrations,
44+
forceLoad,
45+
lastEventId,
46+
onLoad,
47+
showReportDialog,
48+
flush,
49+
close,
50+
wrap,
51+
} from '@sentry/browser';
52+
export { SDK_NAME, SDK_VERSION } from '@sentry/browser';
53+
54+
import { Integrations as BrowserIntegrations } from '@sentry/browser';
55+
import { getGlobalObject } from '@sentry/utils';
56+
57+
export { init } from './sdk';
58+
59+
let windowIntegrations = {};
60+
61+
// This block is needed to add compatibility with the integrations packages when used with a CDN
62+
const _window = getGlobalObject<Window>();
63+
if (_window.Sentry && _window.Sentry.Integrations) {
64+
windowIntegrations = _window.Sentry.Integrations;
65+
}
66+
67+
const INTEGRATIONS = {
68+
...windowIntegrations,
69+
...BrowserIntegrations,
70+
};
71+
72+
export { INTEGRATIONS as Integrations };
73+
74+
createVueEventProcessor();

packages/vue/src/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,4 @@
1-
import { addGlobalEventProcessor, SDK_VERSION } from '@sentry/browser';
2-
3-
/**
4-
* A global side effect that makes sure Sentry events that user
5-
* `@sentry/react` will correctly have Sentry events associated
6-
* with it.
7-
*/
8-
function createVueEventProcessor(): void {
9-
if (addGlobalEventProcessor) {
10-
addGlobalEventProcessor(event => {
11-
event.sdk = {
12-
...event.sdk,
13-
name: 'sentry.javascript.vue',
14-
packages: [
15-
...((event.sdk && event.sdk.packages) || []),
16-
{
17-
name: 'npm:@sentry/vue',
18-
version: SDK_VERSION,
19-
},
20-
],
21-
version: SDK_VERSION,
22-
};
23-
24-
return event;
25-
});
26-
}
27-
}
1+
import { createVueEventProcessor } from './eventprocessor';
282

293
export {
304
addGlobalEventProcessor,

0 commit comments

Comments
 (0)