fix: define lazy-loaded APIs without shallow clone
This commit is contained in:
parent
2b905801c3
commit
0ad9454dce
2 changed files with 43 additions and 32 deletions
|
|
@ -1,3 +1,5 @@
|
|||
/** biome-ignore-all lint/complexity/useArrowFunction: Rolldown issue: Bug requires us to use normal functions instead of arrow functions */
|
||||
|
||||
import { _initExts, _uapi } from '@revenge-mod/plugins/_'
|
||||
import { defineLazyProperty } from '@revenge-mod/utils/objects'
|
||||
import { Logger } from './common'
|
||||
|
|
@ -7,25 +9,30 @@ import type { PluginApiDiscord } from './types/revenge'
|
|||
const uapi = _uapi as UnscopedInitPluginApi
|
||||
const discord = (uapi.discord = {} as PluginApiDiscord)
|
||||
|
||||
// TODO: Rolldown issue: Bug requires us to do { ...require('...') } instead of just require('...')
|
||||
defineLazyProperty(discord, 'actions', () => ({
|
||||
...require('@revenge-mod/discord/actions'),
|
||||
}))
|
||||
defineLazyProperty(discord, 'common', () => ({
|
||||
...require('@revenge-mod/discord/common'),
|
||||
}))
|
||||
defineLazyProperty(discord, 'design', () => ({
|
||||
...require('@revenge-mod/discord/design'),
|
||||
}))
|
||||
defineLazyProperty(discord, 'native', () => ({
|
||||
...require('@revenge-mod/discord/native'),
|
||||
}))
|
||||
defineLazyProperty(discord, 'modules', () => ({
|
||||
settings: {
|
||||
...require('@revenge-mod/discord/modules/settings'),
|
||||
renderer: require('@revenge-mod/discord/modules/settings/renderer'),
|
||||
},
|
||||
}))
|
||||
defineLazyProperty(discord, 'actions', function () {
|
||||
return require('@revenge-mod/discord/actions')
|
||||
})
|
||||
|
||||
defineLazyProperty(discord, 'common', function () {
|
||||
return require('@revenge-mod/discord/common')
|
||||
})
|
||||
|
||||
defineLazyProperty(discord, 'design', function () {
|
||||
return require('@revenge-mod/discord/design')
|
||||
})
|
||||
|
||||
defineLazyProperty(discord, 'native', function () {
|
||||
return require('@revenge-mod/discord/native')
|
||||
})
|
||||
|
||||
defineLazyProperty(discord, 'modules', function () {
|
||||
return {
|
||||
settings: {
|
||||
...require('@revenge-mod/discord/modules/settings'),
|
||||
renderer: require('@revenge-mod/discord/modules/settings/renderer'),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
_initExts.push((api, { manifest: { id } }) =>
|
||||
defineLazyProperty(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
/** biome-ignore-all lint/complexity/useArrowFunction: Rolldown issue: Bug requires us to use normal functions instead of arrow functions */
|
||||
|
||||
import { defineLazyProperty } from '@revenge-mod/utils/objects'
|
||||
|
||||
export interface PluginApiExternals {
|
||||
|
|
@ -9,16 +11,18 @@ export interface PluginApiExternals {
|
|||
|
||||
export const externals = {} as PluginApiExternals
|
||||
|
||||
// TODO: Rolldown issue: Bug requires us to do { ...require('...') } instead of just require('...')
|
||||
defineLazyProperty(externals, 'Browserify', () => ({
|
||||
...require('@revenge-mod/externals/browserify'),
|
||||
}))
|
||||
defineLazyProperty(externals, 'ReactNativeClipboard', () => ({
|
||||
...require('@revenge-mod/externals/react-native-clipboard'),
|
||||
}))
|
||||
defineLazyProperty(externals, 'ReactNavigation', () => ({
|
||||
...require('@revenge-mod/externals/react-navigation'),
|
||||
}))
|
||||
defineLazyProperty(externals, 'Shopify', () => ({
|
||||
...require('@revenge-mod/externals/shopify'),
|
||||
}))
|
||||
defineLazyProperty(externals, 'Browserify', function () {
|
||||
return require('@revenge-mod/externals/browserify')
|
||||
})
|
||||
|
||||
defineLazyProperty(externals, 'ReactNativeClipboard', function () {
|
||||
return require('@revenge-mod/externals/react-native-clipboard')
|
||||
})
|
||||
|
||||
defineLazyProperty(externals, 'ReactNavigation', function () {
|
||||
return require('@revenge-mod/externals/react-navigation')
|
||||
})
|
||||
|
||||
defineLazyProperty(externals, 'Shopify', function () {
|
||||
return require('@revenge-mod/externals/shopify')
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue