From acad8d7dad11d73018bc6f04c9fda9975053eb93 Mon Sep 17 00:00:00 2001 From: Jaco Date: Thu, 9 Feb 2023 21:02:15 +0200 Subject: [PATCH] Updates for typesBundle (#8996) * Updates for typesBundle * comment chunk rationale --- packages/apps-config/src/api/spec/mangata.ts | 4 +-- packages/apps-config/src/cjs/cjs/mangata.js | 6 ---- packages/apps-config/src/cjs/mangata.d.ts | 6 ---- packages/apps-config/src/cjs/mangata.js | 6 ---- packages/apps-config/src/cjs/package.json | 3 -- packages/apps-config/src/endpoints/index.ts | 15 +++++++-- packages/apps-config/src/util.ts | 33 -------------------- packages/apps/webpack.base.cjs | 8 +++++ 8 files changed, 22 insertions(+), 59 deletions(-) delete mode 100644 packages/apps-config/src/cjs/cjs/mangata.js delete mode 100644 packages/apps-config/src/cjs/mangata.d.ts delete mode 100644 packages/apps-config/src/cjs/mangata.js delete mode 100644 packages/apps-config/src/cjs/package.json delete mode 100644 packages/apps-config/src/util.ts diff --git a/packages/apps-config/src/api/spec/mangata.ts b/packages/apps-config/src/api/spec/mangata.ts index 09d33bbe16..a8cf3d2bee 100644 --- a/packages/apps-config/src/api/spec/mangata.ts +++ b/packages/apps-config/src/api/spec/mangata.ts @@ -1,8 +1,6 @@ // Copyright 2017-2023 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -// Since this libary includes augmented definitions, we inmport it via -// a CJS bridge ... which hopefully just short-circuits all of that -import { typesBundleForPolkadotApps } from '../../cjs/mangata.js'; +import { typesBundleForPolkadotApps } from '@mangata-finance/types'; export default typesBundleForPolkadotApps; diff --git a/packages/apps-config/src/cjs/cjs/mangata.js b/packages/apps-config/src/cjs/cjs/mangata.js deleted file mode 100644 index c2bca1e6ef..0000000000 --- a/packages/apps-config/src/cjs/cjs/mangata.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017-2023 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -const { typesBundleForPolkadotApps } = require('../mangata.js'); - -module.exports = { typesBundleForPolkadotApps }; diff --git a/packages/apps-config/src/cjs/mangata.d.ts b/packages/apps-config/src/cjs/mangata.d.ts deleted file mode 100644 index cb5edba02d..0000000000 --- a/packages/apps-config/src/cjs/mangata.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017-2023 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import { OverrideBundleDefinition } from '@polkadot/types/types'; - -declare const typesBundleForPolkadotApps: OverrideBundleDefinition; diff --git a/packages/apps-config/src/cjs/mangata.js b/packages/apps-config/src/cjs/mangata.js deleted file mode 100644 index ba4e25bb4c..0000000000 --- a/packages/apps-config/src/cjs/mangata.js +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2017-2023 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -const { typesBundleForPolkadotApps } = require('@mangata-finance/types'); - -module.exports = { typesBundleForPolkadotApps }; diff --git a/packages/apps-config/src/cjs/package.json b/packages/apps-config/src/cjs/package.json deleted file mode 100644 index 4f77acae33..0000000000 --- a/packages/apps-config/src/cjs/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "module": "commonjs" -} diff --git a/packages/apps-config/src/endpoints/index.ts b/packages/apps-config/src/endpoints/index.ts index 8fb80c2657..dc3a16c56d 100644 --- a/packages/apps-config/src/endpoints/index.ts +++ b/packages/apps-config/src/endpoints/index.ts @@ -1,10 +1,9 @@ // Copyright 2017-2023 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { TFunction } from '../types'; +import type { TFunction, TOptions } from '../types'; import type { LinkOption } from './types'; -import { defaultT } from '../util'; import { createCustom, createDev, createOwn } from './development'; import { prodChains, prodRelayKusama, prodRelayPolkadot } from './production'; import { testChains, testRelayRococo, testRelayWestend } from './testing'; @@ -14,6 +13,18 @@ export { CUSTOM_ENDPOINT_KEY } from './development'; export * from './production'; export * from './testing'; +function defaultT (keyOrText: string, text?: string, options?: TOptions): string { + return ( + ( + options && + options.replace && + options.replace.host + ) || + text || + keyOrText + ); +} + export function createWsEndpoints (t: TFunction = defaultT, firstOnly = false, withSort = true): LinkOption[] { return [ ...createCustom(t), diff --git a/packages/apps-config/src/util.ts b/packages/apps-config/src/util.ts deleted file mode 100644 index 27aa997c0e..0000000000 --- a/packages/apps-config/src/util.ts +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017-2023 @polkadot/apps-config authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { TOptions } from './types'; - -import { u8aToString } from '@polkadot/util'; -import { base64Decode, unzlibSync } from '@polkadot/wasm-util'; - -const HDR = ';base64,'; - -export function defaultT (keyOrText: string, text?: string, options?: TOptions): string { - return ( - ( - options && - options.replace && - options.replace.host - ) || - text || - keyOrText - ); -} - -export function unz (base64: string, lenIn: number, lenOut: number): string { - return u8aToString( - unzlibSync( - base64Decode( - base64.substring(HDR.length), - new Uint8Array(lenIn) - ), - new Uint8Array(lenOut) - ) - ); -} diff --git a/packages/apps/webpack.base.cjs b/packages/apps/webpack.base.cjs index f8ce7eb487..058a9d88fd 100644 --- a/packages/apps/webpack.base.cjs +++ b/packages/apps/webpack.base.cjs @@ -78,11 +78,19 @@ function createWebpack (context, mode = 'production') { runtimeChunk: 'single', splitChunks: { cacheGroups: [ + // this one is massive (less-frequently updated, alongside deps) ['type', /[\\/]packages[\\/]apps-config[\\/]src[\\/]api[\\/]typesBundle/], + // should just change when totally new teams are onboarded ['logo', /[\\/]packages[\\/]apps-config[\\/]src[\\/]ui[\\/]logos/], + // config cannot go in main - it has multiple users + ['conf', /[\\/]packages[\\/]apps-config[\\/]src[\\/]/], + // exceptionally large - should not change at all ['robo', /[\\/]packages[\\/]react-components[\\/]src[\\/]IdentityIcon[\\/]RoboHash/], + // library split (although it probably changes alongside pages) ['comm', /[\\/]packages[\\/]react-.*[\\/]src[\\/]/], + // pages are seperated out (non-perfect, but indv. too small) ['page', /[\\/]packages[\\/]page-.*[\\/]src[\\/]/], + // all other modules ['modu', /[\\/]node_modules[\\/]/] ].reduce((result, [name, test], index) => ({ ...result,