Skip to content

Commit 812676a

Browse files
Spencermisticelasticmachine
authored
chore(NA): reduce siem bundle size using babel-plugin-transfor… (#63269) (#64387)
* 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> Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 7041deb commit 812676a

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

packages/kbn-babel-preset/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"babel-plugin-add-module-exports": "^1.0.2",
1616
"babel-plugin-filter-imports": "^3.0.0",
1717
"babel-plugin-styled-components": "^1.10.6",
18-
"babel-plugin-transform-define": "^2.0.0"
18+
"babel-plugin-transform-define": "^2.0.0",
19+
"babel-plugin-transform-imports": "^2.0.0"
1920
}
2021
}

packages/kbn-babel-preset/webpack_preset.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,24 @@ module.exports = () => {
4242
},
4343
],
4444
],
45+
// NOTE: we can enable this by default for everything as soon as we only have one instance
46+
// of lodash across the entire project. For now we are just enabling it for siem
47+
// as they are extensively using the lodash v4
48+
overrides: [
49+
{
50+
test: [/x-pack[\/\\]legacy[\/\\]plugins[\/\\]siem[\/\\]public/],
51+
plugins: [
52+
[
53+
require.resolve('babel-plugin-transform-imports'),
54+
{
55+
'lodash/?(((\\w*)?/?)*)': {
56+
transform: 'lodash/${1}/${member}',
57+
preventFullImport: false,
58+
},
59+
},
60+
],
61+
],
62+
},
63+
],
4564
};
4665
};

yarn.lock

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,11 @@
284284
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed"
285285
integrity sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw==
286286

287+
"@babel/helper-validator-identifier@^7.9.5":
288+
version "7.9.5"
289+
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80"
290+
integrity sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==
291+
287292
"@babel/helper-wrap-function@^7.8.3":
288293
version "7.8.3"
289294
resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.8.3.tgz#9dbdb2bb55ef14aaa01fe8c99b629bd5352d8610"
@@ -1126,6 +1131,15 @@
11261131
lodash "^4.17.13"
11271132
to-fast-properties "^2.0.0"
11281133

1134+
"@babel/types@^7.4":
1135+
version "7.9.5"
1136+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.9.5.tgz#89231f82915a8a566a703b3b20133f73da6b9444"
1137+
integrity sha512-XjnvNqenk818r5zMaba+sLQjnbda31UfUURv3ei0qPQw4u+j2jMyJ5b11y8ZHYTRSI3NnInQkkkRT4fLqqPdHg==
1138+
dependencies:
1139+
"@babel/helper-validator-identifier" "^7.9.5"
1140+
lodash "^4.17.13"
1141+
to-fast-properties "^2.0.0"
1142+
11291143
"@cnakazawa/watch@^1.0.3":
11301144
version "1.0.3"
11311145
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef"
@@ -7051,6 +7065,14 @@ babel-plugin-transform-define@^2.0.0:
70517065
lodash "^4.17.11"
70527066
traverse "0.6.6"
70537067

7068+
babel-plugin-transform-imports@^2.0.0:
7069+
version "2.0.0"
7070+
resolved "https://registry.yarnpkg.com/babel-plugin-transform-imports/-/babel-plugin-transform-imports-2.0.0.tgz#9e5f49f751a9d34ba8f4bb988c7e48ed2419c6b6"
7071+
integrity sha512-65ewumYJ85QiXdcB/jmiU0y0jg6eL6CdnDqQAqQ8JMOKh1E52VPG3NJzbVKWcgovUR5GBH8IWpCXQ7I8Q3wjgw==
7072+
dependencies:
7073+
"@babel/types" "^7.4"
7074+
is-valid-path "^0.1.1"
7075+
70547076
babel-plugin-transform-inline-consecutive-adds@^0.4.3:
70557077
version "0.4.3"
70567078
resolved "https://registry.yarnpkg.com/babel-plugin-transform-inline-consecutive-adds/-/babel-plugin-transform-inline-consecutive-adds-0.4.3.tgz#323d47a3ea63a83a7ac3c811ae8e6941faf2b0d1"
@@ -17475,7 +17497,7 @@ is-valid-glob@^1.0.0:
1747517497
resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa"
1747617498
integrity sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao=
1747717499

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

0 commit comments

Comments
 (0)