From e94dfe590d6c8a19c940f866126ae9051a8c8cce Mon Sep 17 00:00:00 2001 From: webistomin Date: Tue, 16 Mar 2021 17:53:27 +0300 Subject: [PATCH] feat(vue-socials): remove destructure for a smaller bundle size --- build/rollup.config.js | 2 -- src/utils/getSerialisedParams.ts | 4 ++-- src/vue-socials-esm.ts | 4 ++-- src/vue-socials.ts | 8 ++++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build/rollup.config.js b/build/rollup.config.js index 1dff399..c011430 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -110,7 +110,6 @@ if (!argv.format || argv.format === 'esm') { dir: 'dist/esm', format: 'esm', exports: 'named', - sourcemap: true, preserveModules: true, }, plugins: [ @@ -148,7 +147,6 @@ if (!argv.format || argv.format === 'es') { file: 'dist/vue-socials.es.js', format: 'esm', exports: 'named', - sourcemap: true, }, plugins: [ resolve(BASE_CONFIG.plugins.resolve), diff --git a/src/utils/getSerialisedParams.ts b/src/utils/getSerialisedParams.ts index 798c6f6..8853afa 100644 --- a/src/utils/getSerialisedParams.ts +++ b/src/utils/getSerialisedParams.ts @@ -10,8 +10,8 @@ export interface IParamsObject { */ export default function getSerialisedParams(object: IParamsObject): string { const params = Object.entries(object) - .filter(([, value]) => value !== undefined && value !== null && !Number.isNaN(value) && value !== '') - .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`); + .filter((param) => param[1] !== undefined && param[1] !== null && !Number.isNaN(param[1]) && param[1] !== '') + .map((param) => `${encodeURIComponent(param[0])}=${encodeURIComponent(String(param[1]))}`); return params.length > 0 ? `?${params.join('&')}` : ''; } diff --git a/src/vue-socials-esm.ts b/src/vue-socials-esm.ts index 2e48ffa..47f331e 100644 --- a/src/vue-socials-esm.ts +++ b/src/vue-socials-esm.ts @@ -9,8 +9,8 @@ import * as components from '@/components'; * Install function executed by Vue.use() */ const install: PluginFunction = function installVueSocials(Vue: typeof _Vue) { - Object.entries(components).forEach(([componentName, component]) => { - Vue.component(componentName, component); + Object.entries(components).forEach((item) => { + Vue.component(item[0], item[1]); }); }; diff --git a/src/vue-socials.ts b/src/vue-socials.ts index e3a8332..c150050 100644 --- a/src/vue-socials.ts +++ b/src/vue-socials.ts @@ -11,10 +11,10 @@ import plugin, * as components from '@/vue-socials-esm'; type NamedExports = Exclude; type ExtendedPlugin = typeof plugin & NamedExports; -Object.entries(components).forEach(([componentName, component]) => { - if (componentName !== 'default') { - const key = componentName as Exclude; - const val = component as Exclude; +Object.entries(components).forEach((item) => { + if (item[0] !== 'default') { + const key = item[0] as Exclude; + const val = item[1] as Exclude; (plugin as ExtendedPlugin)[key] = val; } });