Skip to content

Instantly share code, notes, and snippets.

View ah584d's full-sized avatar
🏠

Avraham Hamu 🏂🏻 ah584d

🏠
  • Israel
  • 10:37 (UTC +02:00)
View GitHub Profile
@ah584d
ah584d / .eslintrc.js
Last active December 8, 2021 16:30
eslint-rule
'no-restricted-imports': [
ERROR,
{
name: 'lodash',
message: "Please use our ES6 module lodash import: ==> import { isNil } from '@lodash'",
},
{
name: 'lodash/chain',
message: 'This function is not exported as an ES6 module, please use an alternative',
},
@ah584d
ah584d / tsconfig.json
Last active December 1, 2021 09:39
tsconfig.json 'module':'commonjs'
{
"compilerOptions": {
/* Basic Options */
"target": "esnext",
"module": "commonjs",
"lib": ["es2017"], ....
@ah584d
ah584d / tsconfig.json
Last active December 1, 2021 09:40
tsconfig.json 'module': 'es2015'
{
"compilerOptions": {
/* Basic Options */
"target": "esnext",
"module": "es2015" or "esnext",
"lib": ["es2017"], ....
@ah584d
ah584d / tsconfig.json
Last active December 1, 2021 09:41
tsconfig.json alias to map file
"paths": {
"@lodash": ["src/common/utils/lodash/lodashES.ts"],
},
@ah584d
ah584d / lodashES.ts
Last active December 1, 2021 09:42
new-mapping-file-lodash
export { default as cloneDeep } from 'lodash/cloneDeep';
export { default as find } from 'lodash/find';
export { default as findIndex } from 'lodash/findIndex';
export { default as flow } from 'lodash/flow';
export { default as forEach } from 'lodash/forEach';
etc...
@ah584d
ah584d / replace your old import by new one
Last active December 1, 2021 09:42
component-example
component file:
replace all lodash import statement by @lodash e.g.
import { orderBy } from 'lodash';
becomes:
import { orderBy } from '@lodash';
@ah584d
ah584d / babel.config.json
Created November 30, 2021 20:58
babel.config.json
{
"presets": ["module:metro-react-native-babel-preset", "@babel/preset-typescript", "@babel/preset-react"],
"parserOpts": { "strictMode": true },
"plugins": [
[
"module-resolver",
{
"root": ["./"],
"extensions": [".ios.js", ".android.js", ".js", ".ts", ".tsx", ".json"],
"alias": {
@ah584d
ah584d / bundle-command
Created November 30, 2021 20:53
bundle size analyzer
npx react-native-bundle-visualizer - only-mapped - bundle-output ./myapp.bundle - format html
@ah584d
ah584d / lodash-size-summary.csv
Last active November 30, 2021 20:46
tables in medium
tsconfig.json 'module': XXX node_modules size lodash size lodash tree shaking activated
'commonsjs' (without our mapping) 2.95MB 117KB NO
'commonsjs' (with our mapping) 2.88MB 46KB YES
'esnext' (without our mapping) 2.97MB 117KB NO
'esnext' (with babel plugin) 2.9MB 46KB YES