Skip to content

Commit

Permalink
fix: mv3 not working (#11326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jan 29, 2024
1 parent 62701e1 commit 632e344
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 418 deletions.
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -42,9 +42,9 @@
"@mui/system": "5.10.8",
"@tanstack/react-query": "^5.8.7",
"@types/masknet__global-types": "workspace:^",
"@types/react": "18.2.21",
"@types/react-dom": "^18.2.7",
"@typescript/lib-dom": "npm:@types/web@^0.0.115",
"@types/react": "18.2.48",
"@types/react-dom": "^18.2.18",
"@typescript/lib-dom": "npm:@types/web@^0.0.135",
"i18next": "^23.2.11",
"knip": "^2.33.3",
"lodash-es": "^4.17.21",
Expand All @@ -63,7 +63,7 @@
"@masknet/config": "workspace:^",
"@masknet/eslint-plugin": "^0.2.0",
"@nice-labs/git-rev": "^3.5.1",
"@swc/core": "1.3.96",
"@swc/core": "1.3.106",
"@tanstack/eslint-plugin-query": "5.8.4",
"@types/lodash-es": "^4.17.9",
"@typescript-eslint/eslint-plugin": "^6.5.0",
Expand All @@ -86,14 +86,14 @@
"prettier": "^3.1.0",
"svgo": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "5.3.0-beta",
"typescript": "5.3.3",
"vite": "^4.5.0",
"vitest": "^0.34.6"
},
"pnpm": {
"overrides": {
"@types/node": "20.5.7",
"@types/react": "18.2.21",
"@types/node": "20.11.9",
"@types/react": "18.2.48",
"cross-blob": "3.0.1",
"i18next-translation-parser>html-parse-stringify2": "github:locize/html-parse-stringify2#d463109433b2c49c74a081044f54b2a6a1ccad7c",
"web3@0.20.7>bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
Expand Down
15 changes: 12 additions & 3 deletions packages/mask/.webpack/config.ts
Expand Up @@ -286,7 +286,13 @@ export async function createConfiguration(_inputFlags: BuildFlags): Promise<webp
nodeEnv: false, // provided in EnvironmentPlugin
realContentHash: false,
removeAvailableModules: productionLike,
runtimeChunk: 'single',
// cannot use single, mv3 requires a different runtime.
// cannot use false, in some cases there are more than 1 runtime in the single page and cause bug.
runtimeChunk: {
name: (entry: { name: string }) => {
return entry.name === 'backgroundWorker' ? false : 'runtime'
},
},
splitChunks:
productionLike ? undefined : (
{
Expand Down Expand Up @@ -346,13 +352,16 @@ export async function createConfiguration(_inputFlags: BuildFlags): Promise<webp
stats: flags.mode === 'production' ? 'errors-only' : undefined,
} satisfies webpack.Configuration

const entries: Record<string, EntryDescription> = (baseConfig.entry = {
const entries = (baseConfig.entry = {
dashboard: withReactDevTools(join(__dirname, '../dashboard/initialization/index.ts')),
popups: withReactDevTools(join(__dirname, '../popups/initialization/index.ts')),
contentScript: withReactDevTools(join(__dirname, '../content-script/index.ts')),
background: normalizeEntryDescription(join(__dirname, '../background/initialization/mv2-entry.ts')),
backgroundWorker: normalizeEntryDescription(join(__dirname, '../background/initialization/mv3-entry.ts')),
})
devtools: undefined as EntryDescription | undefined,
}) satisfies Record<string, EntryDescription | undefined>
delete entries.devtools

baseConfig.plugins.push(
await addHTMLEntry({ chunks: ['dashboard'], filename: 'dashboard.html', perf: flags.profiling }),
await addHTMLEntry({ chunks: ['popups'], filename: 'popups.html', perf: flags.profiling }),
Expand Down
Expand Up @@ -57,7 +57,7 @@ function isProgressEqual(a: PossibleProgress, b: PossibleProgress) {
if (a.type === 'success') return isTypedMessageEqual(a, b as SuccessDecryption)
if (a.type === 'error') return a.error === (b as FailureDecryption).error
if (a.type === 'progress') return a.progress === (b as DecryptionProgress).progress
safeUnreachable(a.type)
safeUnreachable(a)
return false
}
export function DecryptPost(props: DecryptPostProps) {
Expand Down
Expand Up @@ -66,6 +66,7 @@ function ProfileCardHolder() {
return (
<Fade in={active} easing="linear" timeout={250}>
<ShadowRootPopper
placeholder={undefined}
open={!!anchorEl}
anchorEl={anchorEl}
keepMounted
Expand Down
3 changes: 1 addition & 2 deletions packages/mask/package.json
Expand Up @@ -102,12 +102,11 @@
"@tanstack/react-query-persist-client": "^5.8.7",
"@types/elliptic": "^6.4.14",
"@types/json-stable-stringify": "^1.0.34",
"@types/node": "20.5.7",
"@types/react-avatar-editor": "^13.0.0",
"@types/react-highlight-words": "^0.16.4",
"@types/use-subscription": "^1.0.0",
"@types/uuid": "^9.0.3",
"@types/webextension-polyfill": "^0.10.2",
"@types/webextension-polyfill": "^0.10.7",
"assert": "^2.1.0",
"async-call-rpc": "^6.3.1",
"bignumber.js": "9.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/Pets/src/SiteAdaptor/PetSetDialog.tsx
Expand Up @@ -241,7 +241,7 @@ export function PetSetDialog({ configNFTs, onClose }: PetSetDialogProps) {
onChange={(_event, newValue) => onCollectionChange(newValue)}
isOptionEqualToValue={(op, value) => isSameAddress(op.contract, value.contract)}
getOptionLabel={(option) => option.name}
PopperComponent={ShadowRootPopper}
PopperComponent={ShadowRootPopper as any}
PaperComponent={({ children }) => paperComponent(children)}
renderOption={(props, option) => (
<MenuItem
Expand Down Expand Up @@ -288,7 +288,7 @@ export function PetSetDialog({ configNFTs, onClose }: PetSetDialogProps) {
isOptionEqualToValue={(op, value) =>
isSameAddress(op.address, value.address) && op.tokenId === value.tokenId
}
PopperComponent={ShadowRootPopper}
PopperComponent={ShadowRootPopper as any}
renderOption={(props, option) => (
<MenuItem {...props} key={option.tokenId}>
<Box className={classes.itemFix}>
Expand Down
Expand Up @@ -132,7 +132,13 @@ export function NftRedPacketHistoryList({ onSend }: Props) {
))}
</List>
</div>
<Popper className={classes.popper} open={!!anchorEl} placement="top" anchorEl={anchorEl} disablePortal>
<Popper
placeholder={undefined}
className={classes.popper}
open={!!anchorEl}
placement="top"
anchorEl={anchorEl}
disablePortal>
{({ placement }) => {
return (
<div className={classes.popperContent}>
Expand Down
Expand Up @@ -323,6 +323,7 @@ export const RedPacketInHistoryList = memo(function RedPacketInHistoryList(props
: t.refund()}
</ActionButton>
<Popper
placeholder={undefined}
className={classes.popper}
open={openPopper}
anchorEl={anchorEl}
Expand Down
Expand Up @@ -68,6 +68,7 @@ export const LensPopup = memo(() => {
return (
<Fade in={active} easing="linear" timeout={250}>
<ShadowRootPopper
placeholder={undefined}
open={!!anchorEl}
anchorEl={anchorEl}
keepMounted
Expand Down
8 changes: 4 additions & 4 deletions packages/polyfills/package.json
Expand Up @@ -8,18 +8,18 @@
"build": "rollup -c"
},
"dependencies": {
"@types/webextension-polyfill": "^0.10.2",
"@types/webextension-polyfill": "^0.10.7",
"clipboard-polyfill": "^3.0.3",
"core-js": "3.35.0",
"core-js": "3.35.1",
"tslib": "^2.6.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.4",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-virtual": "^3.0.2",
"@types/node": "20.5.7",
"core-js-compat": "3.35.0",
"@types/node": "20.11.9",
"core-js-compat": "3.35.1",
"regenerator-runtime": "^0.14.0",
"rollup": "^3.28.1",
"rollup-plugin-swc3": "^0.10.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"@types/gulp": "^4.0.13",
"@types/node": "20.5.7",
"@types/node": "20.11.9",
"@types/proper-lockfile": "^4.1.2",
"@types/yargs": "^17.0.24",
"gulp-cli": "^2.3.0",
Expand Down
@@ -1,5 +1,5 @@
import { Popper } from '@mui/material'
import { createShadowRootForwardedComponent } from '../../ShadowRoot/index.js'

export const ShadowRootPopper = createShadowRootForwardedComponent(Popper)
export const ShadowRootPopper: typeof Popper = createShadowRootForwardedComponent(Popper) as any
ShadowRootPopper.displayName = 'ShadowRootTooltip'

0 comments on commit 632e344

Please sign in to comment.