Skip to content

Commit

Permalink
perf: optimize bundle, keep only en faker
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 9, 2020
1 parent efe2322 commit 8e11fbe
Show file tree
Hide file tree
Showing 10 changed files with 54,543 additions and 47,729 deletions.
3 changes: 3 additions & 0 deletions core/core/src/faker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as faker from 'faker/locale/en_US';

export { faker };
1 change: 1 addition & 0 deletions core/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './utils';
export { randomizeData } from './randomizeData';
export * from './smartControls';
export * from './source';
export * from './faker';
2 changes: 1 addition & 1 deletion core/core/src/randomizeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ComponentControlArray,
} from '@component-controls/specification';
import deepmerge from 'deepmerge';
const faker = require('faker/locale/en_US');
import { faker } from './faker';

const arrayElements = (arr: any[], c?: number) => {
const array = arr || ['a', 'b', 'c'];
Expand Down
1 change: 1 addition & 0 deletions core/core/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare module 'escape-html';
declare module 'faker/locale/en_US';
4 changes: 2 additions & 2 deletions core/specification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- [PackageRepository](#packagerepository)
- [PackageDependency](#packagedependency)
- [StoryRenderFn](#storyrenderfn)
- [defaultExportName](#defaultexportname)
- [defaultExport](#defaultexport)
- [Configuration](#configuration)
- [StoryRenderFn](#storyrenderfn-1)
- [StoryArguments](#storyarguments-1)
Expand Down Expand Up @@ -844,7 +844,7 @@ _defined in [@component-controls/specification/src/utility.ts](https://github.co
| `context` | any | |
| `returns` | any | |

## defaultExportName
## defaultExport

_defined in [@component-controls/specification/src/utility.ts](https://github.com/ccontrols/component-controls/tree/master/core/specification/src/utility.ts#L103)_

Expand Down
2 changes: 1 addition & 1 deletion core/specification/src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type StoryRenderFn = (
context?: any,
) => any;

export const defaultExportName = 'default';
export const defaultExport = 'default';
/**
* an import name
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/storybook-6-no-docs/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
...config,
plugins: [
...config.plugins,
// new BundleAnalyzerPlugin({ generateStatsFile: true, statsFilename: 'stats.json' })
new BundleAnalyzerPlugin({ generateStatsFile: true, statsFilename: 'stats.json' })
]
};
},
Expand Down
102,240 changes: 54,527 additions & 47,713 deletions examples/storybook-6-no-docs/stats.json

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions ui/blocks/src/ComponentDeps/Dependencies.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-disable react/display-name */
import React, { FC, useMemo } from 'react';
import { Flex } from 'theme-ui';
import {
ImportName,
defaultExportName,
} from '@component-controls/specification';
import { ImportName, defaultExport } from '@component-controls/specification';
import { Table, Tag, ExternalLink } from '@component-controls/components';

export interface Dependency {
Expand Down Expand Up @@ -75,9 +72,9 @@ export const Dependencies: FC<DependenciesProps> = ({ dependencies }) => {
>
{value
.sort((a, b) => {
if (a.importedName === defaultExportName) {
if (a.importedName === defaultExport) {
return -1;
} else if (b.importedName === defaultExportName) {
} else if (b.importedName === defaultExport) {
return 1;
}
if (a.importedName > b.importedName) {
Expand All @@ -91,16 +88,14 @@ export const Dependencies: FC<DependenciesProps> = ({ dependencies }) => {
<Tag
key={`${v.name}`}
color={
v.importedName === defaultExportName ? 'green' : 'lightgrey'
v.importedName === defaultExport ? 'green' : 'lightgrey'
}
sxStyle={{
mr: 1,
mb: 1,
}}
>
{v.importedName === defaultExportName
? v.name
: v.importedName}
{v.importedName === defaultExport ? v.name : v.importedName}
</Tag>
))}
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/src/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/display-name */
import React from 'react';
import faker from 'faker';
import { faker } from '@component-controls/core';
import { Table } from './Table';
import { ThemeProvider } from '../ThemeContext';

Expand Down

0 comments on commit 8e11fbe

Please sign in to comment.