Skip to content

Commit b69739c

Browse files
committed
chore: remove react external
1 parent c53457c commit b69739c

4 files changed

Lines changed: 21 additions & 49 deletions

File tree

rsbuild.config.ts

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ export default defineConfig({
5656
}
5757
callback();
5858
},
59-
{
60-
react: 'React',
61-
'react-dom': 'ReactDOM',
62-
},
6359
],
6460
},
6561
dev: {
@@ -68,10 +64,10 @@ export default defineConfig({
6864
liveReload: false,
6965
},
7066
performance: {
71-
// bundleAnalyze: {
72-
// analyzerMode: 'static',
73-
// openAnalyzer: false,
74-
// },
67+
bundleAnalyze: {
68+
analyzerMode: 'static',
69+
openAnalyzer: false,
70+
},
7571
},
7672
tools: {
7773
swc: {
@@ -123,18 +119,6 @@ export default defineConfig({
123119
popup: './src/pages/popup/index.tsx',
124120
},
125121
},
126-
output: {
127-
copy: [
128-
{
129-
from: `./node_modules/react/umd/react.${isDev ? 'development' : 'production.min'}.js`,
130-
to: 'external/react.js',
131-
},
132-
{
133-
from: `./node_modules/react-dom/umd/react-dom.${isDev ? 'development' : 'production.min'}.js`,
134-
to: 'external/react-dom.js',
135-
},
136-
],
137-
},
138122
performance: {
139123
chunkSplit: {
140124
strategy: 'split-by-experience',
@@ -162,22 +146,6 @@ export default defineConfig({
162146
children:
163147
'body{margin:0;background-color:var(--semi-color-bg-0);color:var(--semi-color-text-0)}',
164148
},
165-
{
166-
tag: 'script',
167-
head: true,
168-
append: false,
169-
attrs: {
170-
src: 'external/react.js',
171-
},
172-
},
173-
{
174-
tag: 'script',
175-
head: true,
176-
append: false,
177-
attrs: {
178-
src: 'external/react-dom.js',
179-
},
180-
},
181149
],
182150
},
183151
plugins: [pluginReact()],

scripts/pack-utils/xpi.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ async function packXpi({
3434
if (downloadedFiles.length === 0) {
3535
throw new Error('No signed addon found');
3636
}
37-
console.log(`Downloaded signed addon: ${downloadedFiles.join(', ')}`);
37+
console.log(`[xpi] Downloaded: ${downloadedFiles.join(', ')}`);
3838
const fileName = getOutputFile(extensionConfig.browser, version, 'xpi');
39-
const out = join(releasePath, fileName);
39+
const outFile = join(releasePath, fileName);
4040
// Move download file to output dir
41-
await rename(downloadedFiles[0], out);
42-
console.log('Downloaded signed addon');
41+
await rename(downloadedFiles[0], outFile);
42+
console.log(`[xpi] move to ${outFile}`);
4343
const infoFile = join(releasePath, `${fileName}-config.json`);
4444
await outputJSON(infoFile, {
4545
id: extensionConfig.id,

src/pages/background/core/rules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { cloneDeep, isEqual } from 'lodash-es';
1+
import isEqual from 'fast-deep-equal';
2+
import { cloneDeep } from 'lodash-es';
23
import {
34
APIs,
45
EVENTs,

src/share/core/prefs.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import equal from 'fast-deep-equal';
1+
import isEqual from 'fast-deep-equal';
22
import browser from 'webextension-polyfill';
3-
import emitter from './emitter';
43
import { defaultPrefValue } from './constant';
4+
import emitter from './emitter';
55
import { getSync } from './storage';
66
import type { PrefValue } from './types';
77

@@ -15,13 +15,13 @@ class Prefs {
1515
constructor() {
1616
this.values = { ...defaultPrefValue };
1717

18-
Object.entries(defaultPrefValue).forEach((it) => {
18+
Object.entries(defaultPrefValue).forEach(it => {
1919
this.set(it[0], it[1], true);
2020
});
2121

2222
getSync()
2323
.get('settings')
24-
.then((result) => {
24+
.then(result => {
2525
const synced: any = result.settings;
2626
for (const key in defaultPrefValue) {
2727
if (synced && key in synced) {
@@ -49,7 +49,10 @@ class Prefs {
4949
});
5050
}
5151

52-
get<K extends keyof PrefValue>(key: K, defaultValue?: PrefValue[K]): PrefValue[K] {
52+
get<K extends keyof PrefValue>(
53+
key: K,
54+
defaultValue?: PrefValue[K],
55+
): PrefValue[K] {
5356
if (key in this.boundMethods) {
5457
if (key in this.boundWrappers) {
5558
return this.boundWrappers[key];
@@ -72,9 +75,9 @@ class Prefs {
7275
}
7376

7477
set(key: string, value: any, noSync = false) {
75-
const oldValue = this.values[key];
76-
if (!equal(value, oldValue)) {
77-
this.values[key] = value;
78+
const oldValue = this.values[key as keyof PrefValue];
79+
if (!isEqual(value, oldValue)) {
80+
(this.values as any)[key] = value;
7881
emitter.emit(emitter.EVENT_PREFS_UPDATE, key, value);
7982
if (!noSync) {
8083
getSync().set({

0 commit comments

Comments
 (0)