Skip to content

Commit

Permalink
chore(NA): reduce siem bundle size using babel-plugin-transfor… (#63269)
Browse files Browse the repository at this point in the history
* chore(NA): reduce siem bundle size using babel-plugin-transform-imports for lodash

* fix(NA): dont use preventFullImport

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
mistic and elasticmachine authored Apr 24, 2020
1 parent 34de1ae commit e3ee02c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-filter-imports": "^3.0.0",
"babel-plugin-styled-components": "^1.10.6",
"babel-plugin-transform-define": "^1.3.1"
"babel-plugin-transform-define": "^1.3.1",
"babel-plugin-transform-imports": "^2.0.0"
}
}
19 changes: 19 additions & 0 deletions packages/kbn-babel-preset/webpack_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,24 @@ module.exports = () => {
},
],
],
// NOTE: we can enable this by default for everything as soon as we only have one instance
// of lodash across the entire project. For now we are just enabling it for siem
// as they are extensively using the lodash v4
overrides: [
{
test: [/x-pack[\/\\]legacy[\/\\]plugins[\/\\]siem[\/\\]public/],
plugins: [
[
require.resolve('babel-plugin-transform-imports'),
{
'lodash/?(((\\w*)?/?)*)': {
transform: 'lodash/${1}/${member}',
preventFullImport: false,
},
},
],
],
},
],
};
};
12 changes: 10 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.9.5":
"@babel/types@^7.4", "@babel/types@^7.9.5":
version "7.9.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.5.tgz#89231f82915a8a566a703b3b20133f73da6b9444"
integrity sha512-XjnvNqenk818r5zMaba+sLQjnbda31UfUURv3ei0qPQw4u+j2jMyJ5b11y8ZHYTRSI3NnInQkkkRT4fLqqPdHg==
Expand Down Expand Up @@ -7125,6 +7125,14 @@ babel-plugin-transform-define@^1.3.1:
lodash "^4.17.11"
traverse "0.6.6"

babel-plugin-transform-imports@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-imports/-/babel-plugin-transform-imports-2.0.0.tgz#9e5f49f751a9d34ba8f4bb988c7e48ed2419c6b6"
integrity sha512-65ewumYJ85QiXdcB/jmiU0y0jg6eL6CdnDqQAqQ8JMOKh1E52VPG3NJzbVKWcgovUR5GBH8IWpCXQ7I8Q3wjgw==
dependencies:
"@babel/types" "^7.4"
is-valid-path "^0.1.1"

babel-plugin-transform-inline-consecutive-adds@^0.4.3:
version "0.4.3"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-consecutive-adds/-/babel-plugin-transform-inline-consecutive-adds-0.4.3.tgz#323d47a3ea63a83a7ac3c811ae8e6941faf2b0d1"
Expand Down Expand Up @@ -17579,7 +17587,7 @@ is-valid-glob@^1.0.0:
resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa"
integrity sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=

is-valid-path@0.1.1:
is-valid-path@0.1.1, is-valid-path@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-valid-path/-/is-valid-path-0.1.1.tgz#110f9ff74c37f663e1ec7915eb451f2db93ac9df"
integrity sha1-EQ+f90w39mPh7HkV60UfLbk6yd8=
Expand Down

0 comments on commit e3ee02c

Please sign in to comment.