diff --git a/esbuild.config.js b/esbuild.config.js
index 63fc4e6..6f66cfa 100644
--- a/esbuild.config.js
+++ b/esbuild.config.js
@@ -1,6 +1,5 @@
import esbuild from 'esbuild';
import scss from 'esbuild-plugin-sass';
-import svg from 'esbuild-plugin-svgr';
const watch = process.argv.includes('--watch') && {
onRebuild(error) {
@@ -9,6 +8,39 @@ const watch = process.argv.includes('--watch') && {
},
};
+// see https://github.com/evanw/esbuild/issues/806#issuecomment-779138268
+let skipReactImports = {
+ name: 'skipReactImports',
+ setup(build) {
+ build.onResolve({ filter: /^react(-dom)?$/ }, (args) => {
+ return {
+ path: args.path,
+ namespace: `globalExternal_${args.path}`,
+ };
+ });
+
+ build.onLoad(
+ { filter: /.*/, namespace: 'globalExternal_react' },
+ () => {
+ return {
+ contents: `module.exports = globalThis.React`,
+ loader: 'js',
+ };
+ }
+ );
+
+ build.onLoad(
+ { filter: /.*/, namespace: 'globalExternal_react-dom' },
+ () => {
+ return {
+ contents: `module.exports = globalThis.ReactDOM`,
+ loader: 'js',
+ };
+ }
+ );
+ },
+};
+
esbuild
.build({
entryPoints: [
@@ -21,7 +53,8 @@ esbuild
// minify: true,
outdir: './lib',
loader: { '.woff': 'file', '.woff2': 'file' },
- plugins: [scss(), svg()],
+ plugins: [scss(), skipReactImports],
+ external: ['react', 'react-dom'],
watch,
})
.then(() => console.log('Add-on was built'))
diff --git a/package.json b/package.json
index 8125e12..a657706 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,6 @@
"addons-linter": "^4.7.0",
"esbuild": "^0.14.14",
"esbuild-plugin-sass": "^1.0.1",
- "esbuild-plugin-svgr": "^1.0.0",
"web-ext": "^6.6.0",
"web-ext-types": "^3.2.1"
}
diff --git a/sidebar/sidebar.html b/sidebar/sidebar.html
index 7518769..ab525c3 100644
--- a/sidebar/sidebar.html
+++ b/sidebar/sidebar.html
@@ -18,8 +18,10 @@
rel="stylesheet"
href="/lib/sidebar/sidebar.css"
>
+
+