Skip to content

Commit

Permalink
feat(vue-socials): remove destructure for a smaller bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
webistomin committed Mar 16, 2021
1 parent 6acbd61 commit e94dfe5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ if (!argv.format || argv.format === 'esm') {
dir: 'dist/esm',
format: 'esm',
exports: 'named',
sourcemap: true,
preserveModules: true,
},
plugins: [
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/utils/getSerialisedParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('&')}` : '';
}
4 changes: 2 additions & 2 deletions src/vue-socials-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import * as components from '@/components';
* Install function executed by Vue.use()
*/
const install: PluginFunction<never> = 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]);
});
};

Expand Down
8 changes: 4 additions & 4 deletions src/vue-socials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import plugin, * as components from '@/vue-socials-esm';
type NamedExports = Exclude<typeof components, 'default'>;
type ExtendedPlugin = typeof plugin & NamedExports;

Object.entries(components).forEach(([componentName, component]) => {
if (componentName !== 'default') {
const key = componentName as Exclude<keyof NamedExports, 'default'>;
const val = component as Exclude<ExtendedPlugin, typeof plugin>;
Object.entries(components).forEach((item) => {
if (item[0] !== 'default') {
const key = item[0] as Exclude<keyof NamedExports, 'default'>;
const val = item[1] as Exclude<ExtendedPlugin, typeof plugin>;
(plugin as ExtendedPlugin)[key] = val;
}
});
Expand Down

1 comment on commit e94dfe5

@vercel
Copy link

@vercel vercel bot commented on e94dfe5 Mar 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.