Skip to content

Commit 20aebe7

Browse files
committed
Address review comments.
1 parent f4c0ebd commit 20aebe7

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ jobs:
284284
bundle:
285285
- esm
286286
- cjs
287-
- bundle
288-
- bundle_min
287+
- bundle_es5
288+
- bundle_es5_min
289289
- bundle_es6
290290
- bundle_es6_min
291291
tracing_only:

packages/integration-tests/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ To filter tests by their title:
5757
You can refer to [Playwright documentation](https://playwright.dev/docs/test-cli) for other CLI options.
5858

5959
You can set env variable `PW_BUNDLE` to set specific build or bundle to test against.
60-
Available options: `esm`, `dist`, `bundle`, `bundle_min`, `bundle_es6`, `bundle_es6_min`
60+
Available options: `esm`, `cjs`, `bundle_es5`, `bundle_es5_min`, `bundle_es6`, `bundle_es6_min`
6161

6262
### Troubleshooting
6363

packages/integration-tests/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"type-check": "tsc",
1717
"pretest": "yarn clean && yarn type-check",
1818
"test": "playwright test ./suites",
19-
"test:bundle": "PW_BUNDLE=bundle yarn test",
20-
"test:bundle:min": "PW_BUNDLE=bundle_min yarn test",
19+
"test:bundle:es5": "PW_BUNDLE=bundle_es5 yarn test",
20+
"test:bundle:es5:min": "PW_BUNDLE=bundle_es5_min yarn test",
2121
"test:bundle:es6": "PW_BUNDLE=bundle_es6 yarn test",
2222
"test:bundle:es6:min": "PW_BUNDLE=bundle_es6_min yarn test",
2323
"test:cjs": "PW_BUNDLE=cjs yarn test",

packages/integration-tests/utils/generatePlugin.ts

+26-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import HtmlWebpackPlugin, { createHtmlTagObject } from 'html-webpack-plugin';
44
import path from 'path';
55
import { Compiler } from 'webpack';
66

7-
const PACKAGE_PATH = '../../packages';
7+
const PACKAGES_DIR = '../../packages';
88

99
const tracingOnly = process.env.PW_TRACING_ONLY === 'true';
1010
const bundleKey = process.env.PW_BUNDLE;
@@ -19,47 +19,54 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
1919
browser: {
2020
cjs: 'dist/index.js',
2121
esm: 'esm/index.js',
22-
bundle: 'build/bundle.js',
23-
bundle_min: 'build/bundle.min.js',
22+
bundle_es5: 'build/bundle.js',
23+
bundle_es5_min: 'build/bundle.min.js',
2424
bundle_es6: 'build/bundle.es6.js',
2525
bundle_es6_min: 'build/bundle.es6.min.js',
2626
},
2727
tracing: {
2828
cjs: 'dist/index.js',
2929
esm: 'esm/index.js',
30-
bundle: 'build/bundle.tracing.js',
31-
bundle_min: 'build/bundle.tracing.min.js',
32-
// `tracing` doesn't have an es6 build
30+
bundle_es5: 'build/bundle.tracing.js',
31+
bundle_es5_min: 'build/bundle.tracing.min.js',
32+
// `tracing` doesn't have an es6 build yet
3333
bundle_es6: 'build/bundle.tracing.js',
3434
bundle_es6_min: 'build/bundle.tracing.min.js',
3535
},
3636
};
3737

38-
/**
38+
/*
3939
* Generate webpack aliases based on packages in monorepo
40-
* Example of an alias: '@sentry/serverless': 'path/to/sentry-javascript/packages/serverless',
40+
*
41+
* When using compiled versions of the tracing and browser packages, their aliases look for example like
42+
* '@sentry/browser': 'path/to/sentry-javascript/packages/browser/esm/index.js'
43+
* When using bundled versions of the tracing and browser packages, their aliases look for example like
44+
* '@sentry/browser': false
45+
* so that the compiled versions aren't included
46+
* All other packages are aliased for example like
47+
* '@sentry/serverless': 'path/to/sentry-javascript/packages/serverless'
4148
*/
4249
function generateSentryAlias(): Record<string, string> {
43-
const dirents = readdirSync(PACKAGE_PATH, { withFileTypes: true })
50+
const packageNames = readdirSync(PACKAGES_DIR, { withFileTypes: true })
4451
.filter(dirent => dirent.isDirectory())
4552
.map(dir => dir.name);
4653

4754
return Object.fromEntries(
48-
dirents.map(d => {
55+
packageNames.map(packageName => {
4956
const packageJSON: Package = JSON.parse(
50-
readFileSync(path.resolve(PACKAGE_PATH, d, 'package.json'), { encoding: 'utf-8' }).toString(),
57+
readFileSync(path.resolve(PACKAGES_DIR, packageName, 'package.json'), { encoding: 'utf-8' }).toString(),
5158
);
5259

53-
const modulePath = path.resolve(PACKAGE_PATH, d);
60+
const modulePath = path.resolve(PACKAGES_DIR, packageName);
5461

55-
if (useCompiledModule && bundleKey && BUNDLE_PATHS[d]?.[bundleKey]) {
56-
const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[d][bundleKey]);
62+
if (useCompiledModule && bundleKey && BUNDLE_PATHS[packageName]?.[bundleKey]) {
63+
const bundlePath = path.resolve(modulePath, BUNDLE_PATHS[packageName][bundleKey]);
5764

5865
return [packageJSON['name'], bundlePath];
5966
}
6067

61-
if (useBundle && bundleKey && BUNDLE_PATHS[d]?.[bundleKey]) {
62-
// If we're injecting a bundle, ignore the webpack import.
68+
if (useBundle && bundleKey) {
69+
// If we're injecting a bundle, ignore the webpack imports.
6370
return [packageJSON['name'], false];
6471
}
6572

@@ -99,9 +106,10 @@ class SentryScenarioGenerationPlugin {
99106
compiler.hooks.compilation.tap(this._name, compilation => {
100107
HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapAsync(this._name, (data, cb) => {
101108
if (useBundle && bundleKey) {
102-
const bundleName = tracingOnly || this.requiresTracing ? 'tracing' : 'browser';
109+
const useTracingBundle = tracingOnly || this.requiresTracing;
110+
const bundleName = useTracingBundle ? 'tracing' : 'browser';
103111
const bundleObject = createHtmlTagObject('script', {
104-
src: path.resolve(PACKAGE_PATH, bundleName, BUNDLE_PATHS[bundleName][bundleKey]),
112+
src: path.resolve(PACKAGES_DIR, bundleName, BUNDLE_PATHS[bundleName][bundleKey]),
105113
});
106114

107115
data.assetTags.scripts.unshift(bundleObject);

0 commit comments

Comments
 (0)