Skip to content

Commit 14b7962

Browse files
authored
ref(build): Introduce central build directory to packages with bundles (#4838)
Adds the central build directory to all our packages producing CDN bundles in addition to NPM tarballs: - Browser - Integrations - Tracing - WASM Additionally, the script that would formerly be called `postbuild.ts` is now `prepack.ts` and it runs first when executing `yarn build:npm`, followed by the tarball packing procedure via npm. Exception: Tracing needs to have the modified package.json in the build dir for our Playwright integration tests, so `prepack.ts` is also executed after every build.
1 parent a064c7c commit 14b7962

30 files changed

+111
-69
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ jobs:
204204
name: ${{ github.sha }}
205205
path: |
206206
${{ github.workspace }}/packages/browser/build/bundles/**
207-
${{ github.workspace }}/packages/integrations/build/**
208-
${{ github.workspace }}/packages/tracing/build/**
207+
${{ github.workspace }}/packages/integrations/build/bundles/**
208+
${{ github.workspace }}/packages/tracing/build/bundles/**
209209
${{ github.workspace }}/packages/**/*.tgz
210210
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
211211

.size-limit.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ module.exports = [
2525
},
2626
{
2727
name: '@sentry/browser - Webpack (gzipped + minified)',
28-
path: 'packages/browser/build/esm/index.js',
28+
path: 'packages/browser/build/npm/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/build/esm/index.js',
35+
path: 'packages/browser/build/npm/esm/index.js',
3636
import: '{ init }',
3737
gzip: false,
3838
limit: '100 KB',
@@ -53,13 +53,13 @@ module.exports = [
5353
},
5454
{
5555
name: '@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified)',
56-
path: 'packages/tracing/build/bundle.tracing.min.js',
56+
path: 'packages/tracing/build/bundles/bundle.tracing.min.js',
5757
gzip: true,
5858
limit: '100 KB',
5959
},
6060
{
6161
name: '@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified)',
62-
path: 'packages/tracing/build/bundle.tracing.es6.min.js',
62+
path: 'packages/tracing/build/bundles/bundle.tracing.es6.min.js',
6363
gzip: true,
6464
limit: '100 KB',
6565
},

packages/browser/.npmignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Info: the paths in this file are specified so that they align with the file
22
# structure in `./build` where this file is copied to. This is done by the
3-
# postbuild script `sentry-javascript/scripts/postbuild.ts`.
3+
# prepack script `sentry-javascript/scripts/prepack.ts`.
44

55
*
66

7-
# TODO remove bundles in v7
8-
!/bundles/**/*
7+
# TODO remove bundles (which in the tarball are inside `build`) in v7
8+
!/build/**/*
99

1010
!/dist/**/*
1111
!/types/**/*

packages/browser/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"engines": {
1010
"node": ">=6"
1111
},
12-
"main": "build/dist/index.js",
13-
"module": "build/esm/index.js",
14-
"types": "build/types/index.d.ts",
12+
"main": "build/npm/dist/index.js",
13+
"module": "build/npm/esm/index.js",
14+
"types": "build/npm/types/index.d.ts",
1515
"publishConfig": {
1616
"access": "public"
1717
},
@@ -44,7 +44,7 @@
4444
"webpack": "^4.30.0"
4545
},
4646
"scripts": {
47-
"build": "run-p build:cjs build:esm build:bundle build:types && ts-node ../../scripts/postbuild.ts",
47+
"build": "run-p build:cjs build:esm build:bundle build:types",
4848
"build:bundle": "rollup --config",
4949
"build:cjs": "tsc -p tsconfig.cjs.json",
5050
"build:dev": "run-p build:cjs build:esm build:types",
@@ -58,7 +58,7 @@
5858
"build:dev:watch": "run-p build:cjs:watch build:esm:watch build:types:watch",
5959
"build:esm:watch": "tsc -p tsconfig.esm.json --watch",
6060
"build:types:watch": "tsc -p tsconfig.types.json --watch",
61-
"build:npm": "npm pack ./build",
61+
"build:npm": "ts-node ../../scripts/prepack.ts && npm pack ./build/npm",
6262
"circularDepCheck": "madge --circular src/index.ts",
6363
"clean": "rimraf build coverage .rpt2_cache",
6464
"fix": "run-s fix:eslint fix:prettier",

packages/browser/test/integration/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function build() {
7373

7474
writeFile(
7575
'artifacts/dedupe.js',
76-
readFile('../../../integrations/build/dedupe.js').replace('//# sourceMappingURL=dedupe.js.map', '')
76+
readFile('../../../integrations/build/bundles/dedupe.js').replace('//# sourceMappingURL=dedupe.js.map', '')
7777
);
7878
concatFiles('artifacts/setup.js', ['artifacts/dedupe.js', 'common/utils.js', 'common/triggers.js', 'common/init.js']);
7979
rmdir('artifacts/dedupe.js');

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

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

55
// Init
66
Sentry.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": "build/dist",
6+
"outDir": "build/npm/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": "build/esm",
6+
"outDir": "build/npm/esm"
77
}
88
}

packages/browser/tsconfig.types.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"declaration": true,
66
"declarationMap": true,
77
"emitDeclarationOnly": true,
8-
"outDir": "build/types"
8+
"outDir": "build/npm/types"
99
}
1010
}

packages/integration-tests/utils/generatePlugin.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ const useBundle = bundleKey && !useCompiledModule;
1717

1818
const BUNDLE_PATHS: Record<string, Record<string, string>> = {
1919
browser: {
20-
cjs: 'build/dist/index.js',
21-
esm: 'build/esm/index.js',
20+
cjs: 'build/npm/dist/index.js',
21+
esm: 'build/npm/esm/index.js',
2222
bundle_es5: 'build/bundles/bundle.js',
2323
bundle_es5_min: 'build/bundles/bundle.min.js',
2424
bundle_es6: 'build/bundles/bundle.es6.js',
2525
bundle_es6_min: 'build/bundles/bundle.es6.min.js',
2626
},
2727
tracing: {
28-
cjs: 'dist/index.js',
29-
esm: 'esm/index.js',
30-
bundle_es5: 'build/bundle.tracing.js',
31-
bundle_es5_min: 'build/bundle.tracing.min.js',
32-
bundle_es6: 'build/bundle.tracing.es6.js',
33-
bundle_es6_min: 'build/bundle.tracing.es6.min.js',
28+
cjs: 'build/npm/dist/index.js',
29+
esm: 'build/npm/esm/index.js',
30+
bundle_es5: 'build/bundles/bundle.tracing.js',
31+
bundle_es5_min: 'build/bundles/bundle.tracing.min.js',
32+
bundle_es6: 'build/bundles/bundle.tracing.es6.js',
33+
bundle_es6_min: 'build/bundles/bundle.tracing.es6.min.js',
3434
},
3535
};
3636

0 commit comments

Comments
 (0)