Skip to content

Commit aea812f

Browse files
Lms24lobsterkatie
andcommitted
feat(build): introduce root build directory in @sentry/browser
* add root build directory as the output directory for all module formats and bundles. This puts all build JS files and modules (bundles, esm, cjs) into one central build directory. Currently, `package.json`, Readme, License, etc. are still in the package root directories. This should keep things more organized and more clearly arranged. * adjust `tsconfig.json` to build type declarations (*.d.ts) into a separate directory (`build/types`). This deduplicates the identical declarations that were peviously compiled into `dist` and `esm`. * introduce `rootBuildDirectory` export in root `rollup.config.js` as it will (probably) be used in multiple packages and this lets us change the name for all of them at once. Co-authored-by: Katie Byers <[email protected]>
1 parent 4eadcaf commit aea812f

File tree

14 files changed

+68
-29
lines changed

14 files changed

+68
-29
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ jobs:
304304
with:
305305
name: ${{ github.sha }}
306306
path: |
307-
${{ github.workspace }}/packages/browser/build/**
307+
${{ github.workspace }}/packages/browser/build/bundles/**
308308
${{ github.workspace }}/packages/integrations/build/**
309309
${{ github.workspace }}/packages/tracing/build/**
310310
${{ github.workspace }}/packages/**/*.tgz

.size-limit.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
module.exports = [
22
{
33
name: '@sentry/browser - ES5 CDN Bundle (gzipped + minified)',
4-
path: 'packages/browser/build/bundle.min.js',
4+
path: 'packages/browser/build/bundles/bundle.min.js',
55
gzip: true,
66
limit: '100 KB',
77
},
88
{
99
name: '@sentry/browser - ES5 CDN Bundle (minified)',
10-
path: 'packages/browser/build/bundle.min.js',
10+
path: 'packages/browser/build/bundles/bundle.min.js',
1111
gzip: false,
1212
limit: '120 KB',
1313
},
1414
{
1515
name: '@sentry/browser - ES6 CDN Bundle (gzipped + minified)',
16-
path: 'packages/browser/build/bundle.es6.min.js',
16+
path: 'packages/browser/build/bundles/bundle.es6.min.js',
1717
gzip: true,
1818
limit: '100 KB',
1919
},
2020
{
2121
name: '@sentry/browser - ES6 CDN Bundle (minified)',
22-
path: 'packages/browser/build/bundle.es6.min.js',
22+
path: 'packages/browser/build/bundles/bundle.es6.min.js',
2323
gzip: false,
2424
limit: '120 KB',
2525
},
2626
{
2727
name: '@sentry/browser - Webpack (gzipped + minified)',
28-
path: 'packages/browser/esm/index.js',
28+
path: 'packages/browser/build/esm/index.js',
2929
import: '{ init }',
3030
gzip: true,
3131
limit: '100 KB',
3232
},
3333
{
3434
name: '@sentry/browser - Webpack (minified)',
35-
path: 'packages/browser/esm/index.js',
35+
path: 'packages/browser/build/esm/index.js',
3636
import: '{ init }',
3737
gzip: false,
3838
limit: '100 KB',

packages/browser/examples/bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../build/bundle.js
1+
../build/bundles/bundle.js

packages/browser/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"engines": {
1010
"node": ">=6"
1111
},
12-
"main": "dist/index.js",
13-
"module": "esm/index.js",
12+
"main": "build/dist/index.js",
13+
"module": "build/esm/index.js",
1414
"types": "build/types/index.d.ts",
1515
"publishConfig": {
1616
"access": "public"
@@ -44,7 +44,7 @@
4444
"webpack": "^4.30.0"
4545
},
4646
"scripts": {
47-
"build": "run-p build:cjs build:esm build:bundle build:types",
47+
"build": "run-p build:cjs build:esm build:bundle build:types && bash ../../scripts/postbuild.sh",
4848
"build:bundle": "rollup --config",
4949
"build:cjs": "tsc -p tsconfig.cjs.json",
5050
"build:dev": "run-p build:cjs build:esm build:types",
@@ -59,18 +59,18 @@
5959
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
6060
"build:types:watch": "tsc -p tsconfig.types.json --watch",
6161
"circularDepCheck": "madge --circular src/index.ts",
62-
"clean": "rimraf dist esm build coverage .rpt2_cache",
62+
"clean": "rimraf build coverage .rpt2_cache",
6363
"fix": "run-s fix:eslint fix:prettier",
6464
"fix:eslint": "eslint . --format stylish --fix",
6565
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
6666
"link:yarn": "yarn link",
6767
"lint": "run-s lint:prettier lint:eslint",
6868
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
6969
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
70-
"pack": "npm pack",
70+
"pack": "npm pack ./build",
7171
"size:check": "run-p size:check:es5 size:check:es6",
72-
"size:check:es5": "cat build/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'",
73-
"size:check:es6": "cat build/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'",
72+
"size:check:es5": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'",
73+
"size:check:es6": "cat build/bundles/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'",
7474
"test": "run-s test:unit",
7575
"test:unit": "jest --config test/unit/jest.config.js",
7676
"test:integration": "test/integration/run.js",

packages/browser/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const builds = [];
88
isAddOn: false,
99
jsVersion,
1010
licenseTitle: '@sentry/browser',
11-
outputFileBase: `bundle${jsVersion === 'es6' ? '.es6' : ''}`,
11+
outputFileBase: `bundles/bundle${jsVersion === 'es6' ? '.es6' : ''}`,
1212
});
1313

1414
builds.push(...makeConfigVariants(baseBundleConfig));

packages/browser/src/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,6 @@
212212
injectSdk(onLoadCallbacks);
213213
});
214214
}
215-
})(window, document, 'script', 'onerror', 'onunhandledrejection', 'Sentry', 'loader.js', '../../build/bundle.js', {
215+
})(window, document, 'script', 'onerror', 'onunhandledrejection', 'Sentry', 'loader.js', '../../build/bundles/bundle.js', {
216216
dsn: 'https://[email protected]/1'
217217
});

packages/browser/test/integration/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function build() {
8181
writeFile('artifacts/sdk.js', readFile('../../build/bundle.js').replace('//# sourceMappingURL=bundle.js.map', ''));
8282
writeFile(
8383
'artifacts/loader.js',
84-
readFile('../../src/loader.js').replace('../../build/bundle.js', '/base/artifacts/sdk.js')
84+
readFile('../../src/loader.js').replace('../../build/bundles/bundle.js', '/base/artifacts/sdk.js')
8585
);
8686

8787
writeFile(

packages/browser/test/package/test-code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-console */
2-
const Sentry = require('../../dist/index.js');
2+
const Sentry = require('../../build/dist/index.js');
33
const Integrations = require('../../../integrations/dist/dedupe.js');
44

55
// Init

packages/browser/tsconfig.cjs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"compilerOptions": {
55
"module": "commonjs",
6-
"outDir": "dist"
6+
"outDir": "build/dist",
77
}
88
}

packages/browser/tsconfig.esm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"compilerOptions": {
55
"module": "es6",
6-
"outDir": "esm"
6+
"outDir": "build/esm",
77
}
88
}

0 commit comments

Comments
 (0)