Skip to content

Commit 06eee4c

Browse files
🔧 migrate the developer-extension to wxt (#3962)
🔧 migrate the developer-extension to wxt ✅ fix e2e test edit readme merge main branch Apply suggestions from code review Co-authored-by: Ursula Chen <[email protected]> 👌 remove build warning Merge remote-tracking branch 'origin/main' into benoit/migrate-devext-to-wxt Co-authored-by: benoit.zugmeyer <[email protected]>
1 parent 38dd992 commit 06eee4c

30 files changed

+2778
-1246
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ browserstack.err
1111
package.tgz
1212
docs/
1313
*.tsbuildinfo
14+
/developer-extension/.output
15+
/developer-extension/.wxt
1416

1517
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
1618
.pnp.*

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ esm
44
coverage
55
rum-events-format
66
.yarn
7-
developer-extension/dist
87
test/**/dist
98
yarn.lock
109
/docs
10+
/developer-extension/.output
11+
/developer-extension/.wxt

LICENSE-3rdparty.csv

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@ dev,@types/node-forge,MIT,Copyright Microsoft Corporation
2424
dev,@types/pako,MIT,Copyright Microsoft Corporation
2525
dev,@types/react,MIT,Copyright Microsoft Corporation
2626
dev,@types/react-dom,MIT,Copyright Microsoft Corporation
27+
dev,@wxt-dev/module-react,MIT,Copyright (c) 2023 Aaron
2728
dev,@types/react-window,MIT,Copyright Microsoft Corporation
2829
dev,@vitejs/plugin-react,MIT,Copyright (c) 2019-present Evan You & Vite Contributors
29-
dev,@webextension-toolbox/webpack-webextension-plugin,MIT,Copyright 2018 Henrik Wenz ([email protected])
3030
dev,ajv,MIT,Copyright 2015-2017 Evgeny Poberezkin
3131
dev,browserstack-local,MIT,Copyright 2016 BrowserStack
3232
dev,chrome-webstore-upload,MIT,Copyright Federico Brigante <[email protected]> (https://fregante.com), 2020 Andrew Levine
3333
dev,connect-busboy,MIT,Copyright Brian White
34-
dev,copy-webpack-plugin,MIT,Copyright JS Foundation and other contributors
3534
dev,cors,MIT,Copyright 2013 Troy Goode
36-
dev,css-loader,MIT,Copyright JS Foundation and other contributors
3735
dev,emoji-name-map,MIT,Copyright 2016-19 Ionică Bizău <[email protected]> (https://ionicabizau.net)
3836
dev,eslint,MIT,Copyright JS Foundation and other contributors
3937
dev,eslint-module-utils,MIT,Copyright (c) 2015 Ben Mosher
@@ -64,7 +62,6 @@ dev,puppeteer,Apache-2.0,Copyright 2017 Google Inc.
6462
dev,react-router-dom,MIT,Copyright (c) React Training LLC 2015-2019 Copyright (c) Remix Software Inc. 2020-2021 Copyright (c) Shopify Inc. 2022-2023
6563
dev,react-window,MIT,Copyright (c) 2018 Brian Vaughn
6664
dev,recharts,MIT,Copyright (c) 2015-present recharts
67-
dev,style-loader,MIT,Copyright JS Foundation and other contributors
6865
dev,terser-webpack-plugin,MIT,Copyright JS Foundation and other contributors
6966
dev,ts-loader,MIT,Copyright 2015 TypeStrong
7067
dev,tsconfig-paths-webpack-plugin,MIT,Copyright 2016 Jonas Kello
@@ -76,10 +73,6 @@ dev,webpack-cli,MIT,Copyright JS Foundation and other contributors
7673
dev,webpack-dev-middleware,MIT,Copyright JS Foundation and other contributors
7774
dev,@swc/core,Apache-2.0,Copyright (c) SWC Contributors
7875
dev,swc-loader,MIT,Copyright (c) SWC Contributors
79-
dev,@pmmmwh/react-refresh-webpack-plugin,MIT,Copyright (c) Michael Mok
80-
dev,@types/webpack-env,MIT,Copyright Microsoft Corporation
81-
dev,react-refresh,MIT,Copyright (c) Facebook, Inc. and its affiliates.
82-
dev,react-refresh-typescript,MIT,Copyright (c) Piotr Monwid-Olechnowicz
83-
dev,webpack-dev-server,MIT,Copyright JS Foundation and other contributors
8476
dev,http-server,MIT,Copyright http-party contributors
8577
dev,react-router,MIT,Copyright (c) React Training LLC 2015-2019 Copyright (c) Remix Software Inc. 2020-2021 Copyright (c) Shopify Inc. 2022-2023
78+
dev,wxt,MIT,Copyright (c) 2023 Aaron

developer-extension/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

developer-extension/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ Info tab contains information about Session and RUM SDK configurations
8787

8888
## Contribution tips
8989

90+
Read the [Extend the developers
91+
tools](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools)
92+
MDN guide to get up to speed with WebExtensions for devtools. In particular, look for the
93+
various entrypoints (panel.html, devtools.html) and the content script communication, as it'
94+
s not straightforward.
95+
9096
To work on the developer extension and debug it easily:
9197

9298
1. In a terminal, cd into the `developer-extension` folder.
9399

94100
2. Run `yarn dev`.
95101

96-
3. In Chrome, load the `developer-extension/dist` folder as an unpacked extension.
97-
98-
4. After you make a change, right-click on the extension UI and “Reload frame”.
102+
3. A Chrome browser window with the developer extension loaded opens.

developer-extension/manifest.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

developer-extension/package.json

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,15 @@
33
"version": "6.24.1",
44
"private": true,
55
"scripts": {
6-
"build": "rm -rf dist && webpack --disable-interpret --mode production",
7-
"dev": "rm -rf dist && webpack --disable-interpret --mode development && webpack serve --disable-interpret --mode development --config-name=panel --hot"
6+
"build": "wxt build",
7+
"dev": "wxt"
88
},
99
"devDependencies": {
10-
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.0",
1110
"@types/chrome": "0.1.27",
1211
"@types/react": "19.2.2",
1312
"@types/react-dom": "19.2.2",
14-
"@types/webpack-env": "^1.18.4",
15-
"@webextension-toolbox/webpack-webextension-plugin": "3.3.1",
16-
"copy-webpack-plugin": "13.0.1",
17-
"css-loader": "7.1.2",
18-
"html-webpack-plugin": "5.6.4",
19-
"react-refresh": "^0.18.0",
20-
"react-refresh-typescript": "^2.0.9",
21-
"style-loader": "4.0.0",
22-
"typescript": "5.9.3",
23-
"webpack": "5.102.1",
24-
"webpack-cli": "^6.0.0",
25-
"webpack-dev-server": "^5.0.4"
13+
"@wxt-dev/module-react": "1.1.5",
14+
"typescript": "5.9.3"
2615
},
2716
"dependencies": {
2817
"@datadog/browser-core": "workspace:*",
@@ -33,7 +22,8 @@
3322
"@tabler/icons-react": "3.35.0",
3423
"clsx": "2.1.1",
3524
"react": "19.2.0",
36-
"react-dom": "19.2.0"
25+
"react-dom": "19.2.0",
26+
"wxt": "0.20.11"
3727
},
3828
"volta": {
3929
"extends": "../package.json"
File renamed without changes.

developer-extension/src/background/domain/messageRelay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ const CONTENT_SCRIPTS: Array<{
3030
{
3131
id: 'browser-sdk-content-script-main',
3232
world: chrome.scripting.ExecutionWorld.MAIN,
33-
file: './content-script-main.js',
33+
file: './contentScriptMain.js',
3434
},
3535
{
3636
id: 'browser-sdk-content-script-isolated',
3737
world: chrome.scripting.ExecutionWorld.ISOLATED,
38-
file: './content-script-isolated.js',
38+
file: './contentScriptIsolated.js',
3939
},
4040
]
4141

developer-extension/src/content-scripts/isolated.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,39 @@
33
import { isDisconnectError } from '../common/isDisconnectError'
44
import { createLogger } from '../common/logger'
55

6-
const logger = createLogger('content-script-isolated')
6+
export function main() {
7+
const logger = createLogger('content-script-isolated')
78

8-
interface IsolatedWindow {
9-
unregisterIsolatedScript?(): void
10-
}
9+
interface IsolatedWindow {
10+
unregisterIsolatedScript?(): void
11+
}
1112

12-
const isolatedWindow = window as IsolatedWindow
13+
const isolatedWindow = window as IsolatedWindow
1314

14-
// Unregister any callback from a previously injected isolated content script
15-
if (isolatedWindow.unregisterIsolatedScript) {
16-
isolatedWindow.unregisterIsolatedScript()
17-
}
18-
// Register the new callback
19-
window.addEventListener('__ddBrowserSdkMessage', browserSdkMessageListener)
15+
// Unregister any callback from a previously injected isolated content script
16+
if (isolatedWindow.unregisterIsolatedScript) {
17+
isolatedWindow.unregisterIsolatedScript()
18+
}
19+
// Register the new callback
20+
window.addEventListener('__ddBrowserSdkMessage', browserSdkMessageListener)
2021

21-
isolatedWindow.unregisterIsolatedScript = () => {
22-
window.removeEventListener('__ddBrowserSdkMessage', browserSdkMessageListener)
23-
}
22+
isolatedWindow.unregisterIsolatedScript = () => {
23+
window.removeEventListener('__ddBrowserSdkMessage', browserSdkMessageListener)
24+
}
2425

25-
// Listen to events from the "main" content script and relays them to the background script via the
26-
// webextension API.
27-
function browserSdkMessageListener(event: unknown) {
28-
const detail = (event as CustomEvent).detail
26+
// Listen to events from the "main" content script and relays them to the background script via the
27+
// webextension API.
28+
function browserSdkMessageListener(event: unknown) {
29+
const detail = (event as CustomEvent).detail
2930

30-
try {
31-
chrome.runtime.sendMessage(detail).catch((error) => logger.error('Failed to send message:', error))
32-
} catch (error) {
33-
// Ignore errors when the background script is unloaded, as this is expected to happen sometimes and we
34-
// don't want to spam the console in this case.
35-
if (!isDisconnectError(error)) {
36-
logger.error('Failed to send message:', error)
31+
try {
32+
chrome.runtime.sendMessage(detail).catch((error) => logger.error('Failed to send message:', error))
33+
} catch (error) {
34+
// Ignore errors when the background script is unloaded, as this is expected to happen sometimes and we
35+
// don't want to spam the console in this case.
36+
if (!isDisconnectError(error)) {
37+
logger.error('Failed to send message:', error)
38+
}
3739
}
3840
}
3941
}

0 commit comments

Comments
 (0)