Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create vendor dll for the client modules #22618

Merged
merged 219 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from 183 commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
953963d
feat(NA): first dll bundler code.
mistic Jul 12, 2018
eb4f031
chore(NA): upgrade to webpack 4.
mistic Jul 12, 2018
534d890
chore(NA): updated package.json
mistic Jul 12, 2018
b5c7ed0
chore(NA): removed old code.
mistic Jul 12, 2018
7869c02
chore(NA): add parallel option.
mistic Jul 12, 2018
ae9d734
chore(NA): removed console log and old var about node modules.
mistic Jul 12, 2018
dadc1f3
chore(NA): turn off unsafe cache.
mistic Jul 12, 2018
a62d903
chore(NA): update lock files.
mistic Jul 12, 2018
2af2fcd
chore(NA): new config for dll generation.
mistic Jul 12, 2018
1868ea2
chore(NA): update stats emit.
mistic Jul 12, 2018
f7620a6
chore(NA): update dependencies.
mistic Jul 12, 2018
a741468
chore(NA): right cache loaders.
mistic Jul 12, 2018
24c35da
chore(NA): remove ui_bundles alias.
mistic Jul 16, 2018
7d39593
feat(20749): init implementation on bridge plugin for dll bundler.
mistic Jul 18, 2018
c4d83d0
feat(20749): init implementation for dll compiler.
mistic Jul 18, 2018
0a18835
feat(20749): dll bundler init from other process and webpack wrapper..
mistic Jul 18, 2018
9a65fbf
feat(20749): optimizer changes to integrate with dll bundler.
mistic Jul 18, 2018
dd7e51d
chore(20749): split into different processes.
mistic Jul 18, 2018
fcbbd33
refact(20749): change to single running process.
mistic Jul 18, 2018
dc0d451
refact(NA): improvements on dll bundler plugin.
mistic Jul 19, 2018
52d1234
refact(NA): removing including loop on plugins.
mistic Jul 19, 2018
4927a4f
refact(20749): only run dllReference once.
mistic Jul 19, 2018
d9990bf
chore(20749): todo on result.request path building.
mistic Jul 19, 2018
5c30d6a
chore(NA): merge with master.
mistic Jul 19, 2018
3ec23d1
chore(NA): lock files updated.
mistic Jul 19, 2018
59c5b92
chore(NA): avoiding dll paths being removed.
mistic Jul 19, 2018
d5cdcfe
chore(NA): tests on sync generation.
mistic Jul 24, 2018
8662a5d
chore(NA): changes on entry paths compiler.
mistic Jul 24, 2018
50eaee3
chore(NA): different hooks tests.
mistic Jul 24, 2018
f0d9317
chore(20749): first working version, single process, for dynamic buil…
mistic Jul 27, 2018
78c4ed4
chore(20749): merge with master.
mistic Jul 27, 2018
6c0be92
feat(20749): last gross features for the dynamicdllplugin.
mistic Jul 27, 2018
e648ec8
refact(20749): string interpolation when creating the path to delete …
mistic Jul 27, 2018
bf08f3c
chore(NA): updated base optimizer run function args.
mistic Jul 31, 2018
3d7f3e8
chore(20749): first working solution with vendor dll both for prod an…
mistic Aug 2, 2018
7154992
chore(20749): useful todos on client dlls.
mistic Aug 6, 2018
f50b654
chore(NA): merge dll spike branch with master solving all the conflicts.
mistic Aug 14, 2018
1708305
feat(NA): auto built blacklist for server node_modules.
mistic Aug 20, 2018
a61383e
refact(NA): removed unused code.
mistic Aug 20, 2018
0462654
chore(NA): merge with master
mistic Aug 20, 2018
6fc647f
chore(NA): update all webpack and loaders stuff to last versions.
mistic Aug 23, 2018
c42fdc9
refact(NA): first refacts on clean taks related with dll. feat(NA): a…
mistic Aug 23, 2018
c95468f
refact(NA): removed support for console logs during the build.
mistic Aug 23, 2018
8d18c2e
refact(NA): removed extra space.
mistic Aug 23, 2018
d0d993f
refact(NA): removed extra space.
mistic Aug 23, 2018
28d8746
refact(NA): getDllModules function.
mistic Aug 23, 2018
f9ab3b8
chore(NA): removed unsafeCache option.
mistic Aug 24, 2018
69086f2
feat(NA): removed unsafeCache option.
mistic Aug 24, 2018
42cf9e9
refact(NA): apply general inheritance principles to the optimizer: ho…
mistic Aug 24, 2018
7b28c68
refact(NA): solve conflicts
mistic Aug 24, 2018
e34cb76
fix(NA): fs_optimizer run function by not returning inside async func.
mistic Aug 24, 2018
305838a
fix(NA): change template anchor name from vendor to vendors.
mistic Aug 24, 2018
8341aa8
docs(NA): added info about files were keeping when cleaning the bundles.
mistic Aug 24, 2018
fe10085
fix(NA): filtering elible dll modules to delete.
mistic Aug 24, 2018
00219f5
refact(NA): removed old dll bundler in favor on new dynamic dll plugin.
mistic Aug 24, 2018
4b94fd1
refact(NA): initial split for clean modules on dll task.
mistic Aug 27, 2018
afd0db2
refact(NA): update new dll config model. refact(NA): update config on…
mistic Aug 27, 2018
9dd8789
refact(NA): major work refactor for dynamic dll plugin.
mistic Aug 28, 2018
4e14767
refact(NA): extract clean node modules on dll task to its own folder.
mistic Aug 28, 2018
3d75c8c
refact(NA): organize imports.
mistic Aug 28, 2018
259a41c
docs(NA): add docs to registerCompilerHooks function for the optimizer.
mistic Aug 28, 2018
4ded34a
refact(NA): finished refactor for dynamic dll plugin with correct err…
mistic Aug 29, 2018
2b6db05
refact(NA): basic structure for clean client modules on dll task.
mistic Aug 29, 2018
74008e7
fix(NA): resolve path for dll manifest during cclean build tasks.
mistic Aug 29, 2018
a9863fd
refact(NA): split webpack dll related functions to their own file for…
mistic Aug 29, 2018
538b80a
refact(NA): added error handling for the clean client modules on dll …
mistic Aug 29, 2018
668c4c3
docs(NA): added license header.
mistic Aug 29, 2018
2befb2c
refact(NA): complete split out the functions from the clean modules o…
mistic Aug 30, 2018
6467579
refact(NA): main task entries compose.
mistic Aug 30, 2018
095cc17
docs(NA): extend docs for the getDependenciesFromFile function.
mistic Aug 30, 2018
a7ef927
refact(NA): final structure split for clean client node modules dll t…
mistic Aug 30, 2018
9ac946e
fix(NA): added missing param to calculate top level dependencies.
mistic Aug 30, 2018
7e8f34b
docs(NA): completed todo description about dll location.
mistic Aug 30, 2018
87aae93
fix(NA): add production option to webpack config on kbn-pm.
mistic Aug 30, 2018
e990dcb
docs(NA): extended documentation about style extraction.
mistic Aug 30, 2018
4fa3b00
refact(NA): removed extra comments.
mistic Aug 31, 2018
b683ec9
feat(NA): env variable to force dll creation.
mistic Aug 31, 2018
d318008
feat(NA): include option to define folders to keep on delete empty fo…
mistic Aug 31, 2018
ba83a26
refact(NA): remove unused method from dll compiler.
mistic Aug 31, 2018
5591a06
feat(NA): move dlls outside bundles folder and support request for /d…
mistic Sep 1, 2018
b9f2372
chore(NA): merge and solve conflicts with master.
mistic Sep 1, 2018
bac2104
chore(NA): gitignore updated to include new dlls folder.
mistic Sep 1, 2018
2c82f84
chore(NA): eslintignore updated.
mistic Sep 1, 2018
7903bc0
chore(NA): removed strange file from repo.
mistic Sep 1, 2018
147c83a
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 2, 2018
1764541
test(NA): fix failing tests for bundles_route.
mistic Sep 3, 2018
a026d33
chore(NA): merge and fix conflicts with master.
mistic Sep 3, 2018
0966675
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 3, 2018
f84c773
fix(NA): change paths array to path string in a server route config.
mistic Sep 3, 2018
7aea76c
fix(NA): remove infinite loop calls on register hooks functions.
mistic Sep 3, 2018
4a555db
fix(NA): readFile should only override the file in case it not exists.
mistic Sep 3, 2018
be129ff
refact(NA): removed dll compiler finish log on success with stats.
mistic Sep 3, 2018
d57d4b1
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 3, 2018
179571c
fix(NA): dll compiler alias.
mistic Sep 4, 2018
389715d
fix(NA): dynamic dll plugin flow on needs compile.
mistic Sep 4, 2018
ebb245a
fix(NA): raw alias config.
mistic Sep 4, 2018
3d9b2aa
Revert "fix(NA): raw alias config."
mistic Sep 4, 2018
8770f72
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 4, 2018
23c7388
feat(NA): raw alias for moment on dll config model.
mistic Sep 4, 2018
6e6d19b
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 4, 2018
2819ed4
fix(NA): removed uiBundles from base_optimizer call on dynamicdllplugin.
mistic Sep 4, 2018
1435ae0
chore(NA): decrease moment versions.
mistic Sep 4, 2018
3c352c7
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 4, 2018
3d0b795
chore(NA): temporary changes on dll compiler.
mistic Sep 5, 2018
db76c57
fix(NA): majority of problems between dll approach, webpackshims and …
mistic Sep 5, 2018
6d639e9
fix(NA): webpackShims integration with client vendors dll. fix(NA): e…
mistic Sep 5, 2018
3e53a0e
fix(NA): fix for endless dll compilation loop.
mistic Sep 6, 2018
249d72d
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 6, 2018
d68bbd6
fix(NA): removed esm plugin and skipped test using wrong stub strategy.
mistic Sep 6, 2018
db6b16a
docs(NA): added some comments for the skipped test.
mistic Sep 6, 2018
0814b76
feat(NA): considering requires inside webpackShims valid entry paths …
mistic Sep 7, 2018
48a84dc
fix(NA): small fix for the max compilation logic.
mistic Sep 7, 2018
c40eadd
docs(NA): add small explanatory note.
mistic Sep 7, 2018
4a77106
fix(NA): building requires results with relative requires found onn w…
mistic Sep 7, 2018
5177995
docs(NA): add small note for error handling on dll compiler.
mistic Sep 7, 2018
839f9dc
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 7, 2018
9840243
fix(NA): move precinct to prod dependencies.
mistic Sep 7, 2018
d5bf9bf
chore(NA): fix conflicts and merge with master.
mistic Sep 8, 2018
6eefd60
test(NA): testing running functional tests on production.
mistic Sep 9, 2018
fc475a0
fix(NA): restore tests run config for development flag. feat(NA): for…
mistic Sep 9, 2018
b0eecf3
chore(NA): update dependencies.
mistic Sep 9, 2018
136b120
feat(NA): test update dll to completely match base optimizer one.
mistic Sep 9, 2018
56b75b6
fix(NA): removed ts.
mistic Sep 9, 2018
8ab70ac
refact(NA): removed unused consts.
mistic Sep 9, 2018
6f57c1f
fix(NA): set back transpile sacss task in place.
mistic Sep 9, 2018
bc4f629
fix(NA): fix resolve remoing ts and tsx.
mistic Sep 9, 2018
6bd4904
fix(NA): set back transpile sacss task in place.
mistic Sep 9, 2018
7076918
fix(NA): removing isDevmode from mustCompileDll.
mistic Sep 9, 2018
1c2239f
chore(NA): merge and solve conflicts with master.
mistic Sep 19, 2018
37f93af
Merge remote-tracking branch 'upstream/master' into optimizer-spike-s…
mistic Sep 20, 2018
5fff9f0
fix(NA): add search for import statements into the dependencies visitor.
mistic Sep 20, 2018
45819b2
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 20, 2018
a45e05b
chore(NA): merge and solve conflicts with master.
mistic Sep 24, 2018
4843ee7
fix(NA): add dll suffix to vendors resource on ui bootstrap template.
mistic Sep 25, 2018
a4b045b
chore(NA): merge and solve conflicts with master.
mistic Sep 27, 2018
dcd379a
fix(NA): some configs for unrelated dll work projects.
mistic Sep 27, 2018
b9c6d85
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 28, 2018
73df47a
chore(NA): upgrade canvas plugins webpack build to webpack4.
mistic Sep 28, 2018
debd652
chore(NA): add shim for moment-duration-format.
mistic Sep 28, 2018
6aa7fde
chore(NA): stup moment-duration-format into the moment webpackShim.
mistic Sep 28, 2018
b132606
chore(NA): setup moment-duration-format into the moment-timezone webp…
mistic Sep 28, 2018
35ca15a
fix(NA): moment and moment-timezone webpackShims
mistic Sep 28, 2018
db67038
chore(NA): added moment and moment-timezone webpackShims to x-pack. f…
mistic Sep 28, 2018
7570a4c
fix(NA): xpack webpackshims for moment.
mistic Sep 28, 2018
9258559
fix(NA): remove xpack webpakcshims for moment.
mistic Sep 28, 2018
973d9fb
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Sep 28, 2018
2e9460a
fix(NA): webpakcshims for moment.
mistic Sep 28, 2018
377265e
fix(NA): remove every changes from webpackShims and xpack webpackShims.
mistic Sep 28, 2018
f4c118b
fix(NA): merge and solve conflicts with master.
mistic Sep 28, 2018
a7bc920
fix(NA): fix visitors to gather server dependencies resulting from ex…
mistic Sep 28, 2018
ef5ed19
chore(NA): update some webpack related dependencies.
mistic Oct 1, 2018
98eb8f0
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Oct 2, 2018
1824b9f
fix(NA): in the dll the plugins need to have their own dependencies. …
mistic Oct 2, 2018
310f25e
feat(NA): including test/plugin_functional plugins into the kbn-pm bo…
mistic Oct 3, 2018
509113c
chore(NA): merge and solve conflicts with master.
mistic Oct 3, 2018
9b8bdd5
chore(NA): merge with master. Solve conflicts into the canvas webpack…
mistic Oct 4, 2018
610487f
chore(NA): solve conflicts with master.
mistic Oct 5, 2018
5379ae5
chore(NA): merge and solve conflicts with master.
mistic Oct 16, 2018
b5aef06
fix(NA): wrong built yarn lock files.
mistic Oct 16, 2018
3626200
fix(NA): merge and solve conflicts with master. fix(NA): removed dupl…
mistic Oct 19, 2018
9cc3f22
chore(NA): updated webpack related dependencies.
mistic Oct 19, 2018
9e89838
feat(NA): add missing color for dynamic_dll_plugin logging tag.
mistic Oct 19, 2018
e8d8d5a
chore(NA): removed forgotten console.log.
mistic Oct 20, 2018
0f44509
chore(NA): removed forgotten dead code.
mistic Oct 20, 2018
12f4598
chore(NA): removed missing old comment.
mistic Oct 20, 2018
9431b16
docs(NA): added missing notice for 2 tools we have relied on.
mistic Oct 20, 2018
bf5e22b
refact(NA): added is to a boolean variable to keep the consistency in…
mistic Oct 20, 2018
9bd56ce
fix(NA): update notice cli to exclude search inside dlls bundles. cho…
mistic Oct 21, 2018
5313e65
feat(NA): use lodash matches in the code parser visitors logic.
mistic Oct 21, 2018
70c6fac
docs(NA): updated notice file related with the code parser visitors l…
mistic Oct 21, 2018
cac7c9e
docs(NA): added explanation for the process that decides if we should…
mistic Oct 21, 2018
0c22295
test(NA): added missing tests for some usefull parts of the code.
mistic Oct 22, 2018
0244db3
refact(NA): split registerCompileHook function into small ones.
mistic Oct 22, 2018
9b2e99b
chore(NA): merge and solve conflicts with master. fix(NA): add packag…
mistic Oct 25, 2018
2b66fa3
chore(NA): uncomment scripts from tests.
mistic Oct 25, 2018
bcee6d5
feat(NA): isolate code-parser in a kbn package
mistic Oct 25, 2018
4f0c9f4
fix(NA): missing relative dot into the cwd function.
mistic Oct 25, 2018
e3992b3
chore(NA): marge and solve conflicts with last version in master.
mistic Oct 26, 2018
c1143df
chore(NA): update all inter deps to match.
mistic Oct 26, 2018
ac4ad93
fix(NA): rebuild the yarn locks and the package jsons based on master…
mistic Oct 26, 2018
40bffcb
fix(NA): move babel-code-parser to the prod deps.
mistic Oct 26, 2018
98ef351
chore(NA): include build path instead of the base root path.
mistic Oct 29, 2018
2791630
chore(NA): merge and solve conflicts with master.
mistic Nov 7, 2018
50ebf6d
chore(NA): merge and solve conflicts with master.
mistic Nov 13, 2018
f00b77f
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Nov 15, 2018
436f986
refact(NA): integrate plugin_functional test plugins with workspaces.
mistic Nov 15, 2018
6fcc285
fix(NA): include missing license for plugin functional test plugins.
mistic Nov 15, 2018
ab6c130
fix(NA): always write posix paths into the dll entry file in order to…
mistic Nov 20, 2018
c192d77
chore(NA): merge and solve conflicts with last master.
mistic Nov 22, 2018
afca6c1
fix(NA): revert wrong moved line from canvas.
mistic Nov 22, 2018
a821363
fix(NA): match ts-loader version between kibana and x-pack.
mistic Nov 22, 2018
3796188
fix(NA): sync dll compiler with base_optimizer.
mistic Nov 22, 2018
aaf9b77
fix(NA): merge and solve conflicts with last master.
mistic Nov 24, 2018
e9c7082
fix(NA): exclude kbn-interpreter from the dll.
mistic Nov 24, 2018
68727ca
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Nov 26, 2018
efd2230
refact(NA): remove exclusion of kbn-interpretor from base_optimizer.
mistic Nov 26, 2018
b3ca691
fix(NA):merge and solve conflicts with last master.
mistic Nov 27, 2018
1dd9e2f
chore(NA): merge and solve conflicts with last master.
mistic Nov 27, 2018
5b42836
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Nov 27, 2018
279b30c
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Nov 28, 2018
e9ff090
chore(NA): add dlls folder to the yarn kbn clean script.
mistic Nov 28, 2018
9c40c08
feat(NA): extend watch optimizer cache invalidation to understand the…
mistic Nov 28, 2018
9a7b222
fix(NA): missing utf8 input format encoding when reading a file to cr…
mistic Nov 28, 2018
d517911
chore(NA): merge and solve conflicts with master
mistic Nov 28, 2018
de565c6
refact(NA): re-engineering to the dynamic_dll_plugin logs and lifecycle.
mistic Nov 28, 2018
3bafbd4
fix(NA): include webpack-cli into kbn interpreter.
mistic Nov 28, 2018
c76e58c
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Nov 28, 2018
6a06501
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Dec 3, 2018
4e26749
fix(NA): update clean node modules task to search under legacy/core_p…
mistic Dec 3, 2018
24cccf3
fix(NA): fix build on windows with globby on cleaning dlls for the wa…
mistic Dec 3, 2018
625d497
chore(NA): merge and solve conflicts with master.
mistic Dec 4, 2018
560ba5b
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Dec 4, 2018
491b6b2
docs(NA): update documentation for the clean client node modules buil…
mistic Dec 4, 2018
3ee7f16
docs(NA): added extra comment to clarify the purpose for the built en…
mistic Dec 4, 2018
2c23f93
chore(NA): update clean client node_modules code to use posix path.
mistic Dec 4, 2018
7d5b36a
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Dec 4, 2018
4132d48
feat(NA): add support for discovering server entries over the legacy …
mistic Dec 4, 2018
6a4d0c9
chore(NA): merge and solve conflicts with last master.
mistic Dec 5, 2018
a572308
Merge branch 'master' into optimizer-spike-single-process-v3
mistic Dec 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ bower_components
/.es
/plugins
/optimize
/dlls
/src/fixtures/vislib/mock_data
/src/ui/public/angular-bootstrap
/src/ui/public/flot-charts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ node_modules
!/src/dev/notice/__fixtures__/node_modules
trash
/optimize
/dlls
target
/build
.jruby
Expand Down
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ The `config/kibana.yml` file stores user configuration directives. Since this fi

#### Potential Optimization Pitfalls

In development mode, Kibana runs a customized version of [Webpack](http://webpack.github.io/) with some optimizations enabled to make building the browser bundles as fast as possible. These optimizations make the build process about 2x as fast for initial builds, and about 7x faster for rebuilds, but are labeled "unsafe" by Webpack because they can sometimes cause changes to go unnoticed by the compiler. If you experience any of the scenarios below either restart the dev server, or add `optimize.unsafeCache: false` to your `config/kibana.dev.yml` file to disable these optimizations completely.

- Webpack is trying to include a file in the bundle that I deleted and is now complaining about it is missing
- A module id that used to resolve to a single file now resolves to a directory, but webpack isn't adapting
- (if you discover other scenarios, please send a PR!)
Expand Down
3 changes: 3 additions & 0 deletions NOTICE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Kibana source code with Kibana X-Pack source code
Copyright 2012-2018 Elasticsearch B.V.

---
This product has relied on ASTExplorer that is licensed under MIT.

---
This product includes code that was extracted from [email protected]
which is available under an "MIT" license
Expand Down
44 changes: 23 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
"@elastic/good": "8.1.1-kibana1",
"@elastic/numeral": "2.3.2",
"@elastic/ui-ace": "0.2.3",
"@kbn/babel-code-parser": "link:packages/kbn-babel-code-parser",
"@kbn/babel-preset": "link:packages/kbn-babel-preset",
"@kbn/config-schema": "link:packages/kbn-config-schema",
"@kbn/datemath": "link:packages/kbn-datemath",
"@kbn/i18n": "link:packages/kbn-i18n",
"@kbn/pm": "link:packages/kbn-pm",
"@kbn/test-subj-selector": "link:packages/kbn-test-subj-selector",
"@kbn/ui-framework": "link:packages/kbn-ui-framework",
"JSONStream": "1.1.1",
"abortcontroller-polyfill": "^1.1.9",
"angular": "1.6.9",
"angular-aria": "1.6.6",
Expand All @@ -88,19 +88,19 @@
"angular-sanitize": "1.5.7",
"angular-sortable-view": "0.0.15",
"autoprefixer": "^9.1.0",
"babel-core": "6.21.0",
"babel-loader": "7.1.2",
"babel-polyfill": "6.20.0",
"babel-register": "6.18.0",
"babel-core": "6.26.3",
"babel-loader": "7.1.5",
"babel-polyfill": "6.26.0",
"babel-register": "6.26.0",
"bluebird": "2.9.34",
"boom": "^7.2.0",
"brace": "0.11.1",
"cache-loader": "1.0.3",
"cache-loader": "1.2.2",
"chalk": "^2.4.1",
"color": "1.0.3",
"commander": "2.8.1",
"compare-versions": "3.1.0",
"css-loader": "0.28.7",
"css-loader": "1.0.0",
"custom-event-polyfill": "^0.3.0",
"d3": "3.5.6",
"d3-cloud": "1.2.1",
Expand All @@ -111,8 +111,7 @@
"encode-uri-query": "1.0.0",
"execa": "^0.10.0",
"expiry-js": "0.1.7",
"extract-text-webpack-plugin": "3.0.1",
"file-loader": "1.1.4",
"file-loader": "2.0.0",
"font-awesome": "4.4.0",
"getos": "^3.1.0",
"glob": "^7.1.2",
Expand All @@ -138,10 +137,11 @@
"leaflet-vega": "^0.8.6",
"leaflet.heat": "0.2.0",
"less": "2.7.1",
"less-loader": "4.0.5",
"less-loader": "4.1.0",
"lodash": "npm:@elastic/[email protected]",
"lru-cache": "4.1.1",
"markdown-it": "^8.4.1",
"mini-css-extract-plugin": "0.4.4",
"minimatch": "^3.0.4",
"mkdirp": "0.5.1",
"moment": "^2.20.1",
Expand All @@ -152,7 +152,7 @@
"node-fetch": "1.3.2",
"oppsy": "^2.0.0",
"pegjs": "0.9.0",
"postcss-loader": "2.0.6",
"postcss-loader": "3.0.0",
"prop-types": "15.5.8",
"proxy-from-env": "1.0.0",
"pug": "^2.0.3",
Expand Down Expand Up @@ -183,7 +183,7 @@
"rxjs": "^6.2.1",
"script-loader": "0.7.2",
"semver": "^5.5.0",
"style-loader": "0.19.0",
"style-loader": "0.23.1",
"tar": "2.2.0",
"tinygradient": "0.3.0",
"tinymath": "1.1.0",
Expand All @@ -195,17 +195,17 @@
"type-detect": "^4.0.8",
"uglifyjs-webpack-plugin": "^1.2.7",
"ui-select": "0.19.6",
"url-loader": "0.5.9",
"url-loader": "1.1.2",
"uuid": "3.0.1",
"val-loader": "^1.1.0",
"val-loader": "^1.1.1",
"validate-npm-package-name": "2.2.2",
"vega-lib": "^3.3.1",
"vega-lite": "^2.4.0",
"vega-schema-url-parser": "1.0.0",
"vega-tooltip": "^0.9.14",
"vision": "^5.3.3",
"webpack": "3.6.0",
"webpack-merge": "4.1.0",
"webpack": "4.23.1",
"webpack-merge": "4.1.4",
"whatwg-fetch": "^2.0.3",
"wreck": "^14.0.2",
"x-pack": "link:x-pack",
Expand All @@ -222,7 +222,7 @@
"@kbn/plugin-generator": "link:packages/kbn-plugin-generator",
"@kbn/test": "link:packages/kbn-test",
"@octokit/rest": "^15.10.0",
"@types/angular": "^1.6.50",
"@types/angular": "1.6.50",
"@types/angular-mocks": "^1.7.0",
"@types/babel-core": "^6.25.5",
"@types/bluebird": "^3.1.1",
Expand Down Expand Up @@ -280,6 +280,7 @@
"classnames": "2.2.5",
"compressing": "^1.3.1",
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
"enzyme": "3.2.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "3.3.1",
Expand Down Expand Up @@ -313,7 +314,7 @@
"husky": "^0.14.3",
"image-diff": "1.6.0",
"intl-messageformat-parser": "^1.4.0",
"istanbul-instrumenter-loader": "3.0.0",
"istanbul-instrumenter-loader": "3.0.1",
"jest": "^23.5.0",
"jest-cli": "^23.5.0",
"jest-raw-loader": "^1.0.1",
Expand All @@ -337,10 +338,11 @@
"murmurhash3js": "3.0.1",
"mutation-observer": "^1.0.3",
"nock": "8.0.0",
"node-sass": "^4.9.0",
"node-sass": "^4.9.4",
"normalize-path": "^3.0.0",
"pixelmatch": "4.0.2",
"postcss": "^7.0.2",
"pkg-up": "^2.0.0",
"postcss": "^7.0.5",
"prettier": "^1.14.3",
"proxyquire": "1.7.11",
"regenerate": "^1.4.0",
Expand All @@ -351,7 +353,7 @@
"supertest-as-promised": "^4.0.2",
"tree-kill": "^1.1.0",
"ts-jest": "^23.1.4",
"ts-loader": "^3.5.0",
"ts-loader": "^5.2.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-babel-code-parser/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@kbn/babel-preset/node_preset"]
}
19 changes: 19 additions & 0 deletions packages/kbn-babel-code-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# @kbn/babel-code-parser

Simple abstraction over the `@babel/parser` and the `@babel/traverse` in order
to build a code parser on top.

We have two main functions `parseSingleFile` (sync and sync version) and the
`parseEntries` (only async version). The first one just parse one entry file
and the second one parses recursively all the files from a list of
start entry points.

Then we have `visitors` and `strategies`. The first ones are basically the
`visitors` to use into the ast from the `@babel/traverse`. They are the only
way to collect info when using the `parseSingleFile`. The `strategies` are
meant to be used with the `parseEntries` and configures the info we want
to collect from our parsed code. After each loop, one per entry file, the
`parseEntries` method will call the given `strategy` expecting that
`strategy` would call the desired visitors, assemble the important
information to collect and adds them to the final results.

26 changes: 26 additions & 0 deletions packages/kbn-babel-code-parser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@kbn/babel-code-parser",
"description": "babel code parser for Kibana",
"private": true,
"version": "1.0.0",
"main": "./target/index.js",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/elastic/kibana/tree/master/packages/kbn-babel-code-parser"
},
"scripts": {
"build": "babel src --out-dir target",
mistic marked this conversation as resolved.
Show resolved Hide resolved
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},
"devDependencies": {
"babel-cli": "^6.26.0"
},
"dependencies": {
"@kbn/babel-preset": "link:../kbn-babel-preset",
"@babel/parser": "^7.1.3",
"@babel/traverse": "^7.1.4",
"lodash": "^4.17.11"
}
}
36 changes: 36 additions & 0 deletions packages/kbn-babel-code-parser/src/can_require.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export function canRequire(cwd, entry) {
try {
// We will try to test if we can resolve
// this entry through the require.resolve
// setting as the start looking path the
// given cwd. Require.resolve will keep
// looking recursively as normal starting
// from that location.
return require.resolve(entry, {
paths: [
cwd
]
});
} catch (e) {
return false;
}
}
103 changes: 103 additions & 0 deletions packages/kbn-babel-code-parser/src/code_parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { canRequire } from './can_require';
import { readFile, readFileSync } from 'fs';
import { extname } from 'path';
import { promisify } from 'util';
import * as parser from '@babel/parser';
import traverse from '@babel/traverse';
import * as babelParserOptions from '@kbn/babel-preset/common_babel_parser_options';

const read = promisify(readFile);

function _cannotParseFile(filePath) {
return extname(filePath) !== '.js';
}

function _parseAndTraverseFileContent(fileContent, visitorsGenerator) {
const results = [];

// Parse and get the code AST
// All the babel parser plugins
// were enabled
const ast = parser.parse(fileContent, babelParserOptions);

// Loop through the code AST with
// the defined visitors
traverse(ast, visitorsGenerator(results));

return results;
}

export async function parseSingleFile(filePath, visitorsGenerator) {
// Don't parse any other files than .js ones
if (_cannotParseFile(filePath)) {
return [];
}

// Read the file
const content = await read(filePath, { encoding: 'utf8' });

// return the results found on parse and traverse
// the file content with the given visitors
return _parseAndTraverseFileContent(content, visitorsGenerator);
}

export function parseSingleFileSync(filePath, visitorsGenerator) {
// Don't parse any other files than .js ones
if (_cannotParseFile(filePath)) {
return [];
}

// Read the file
const content = readFileSync(filePath, { encoding: 'utf8' });

// return the results found on parse and traverse
// the file content with the given visitors
return _parseAndTraverseFileContent(content, visitorsGenerator);
}

export async function parseEntries(cwd, entries, strategy, results, wasParsed = {}) {
// Assure that we always have a cwd
const sanitizedCwd = cwd || process.cwd();

// Test each entry against canRequire function
const entriesQueue = entries.map(entry => canRequire(sanitizedCwd, entry));

while(entriesQueue.length) {
// Get the first element in the queue as
// select it as our current entry to parse
const mainEntry = entriesQueue.shift();

// Avoid parse the current entry if it is not valid
// or it was already parsed
if (typeof mainEntry !== 'string' || wasParsed[mainEntry]) {
continue;
}

// Find new entries and adds them to the end of the queue
entriesQueue.push(...(await strategy(sanitizedCwd, parseSingleFile, mainEntry, wasParsed, results)));

// Mark the current main entry as already parsed
wasParsed[mainEntry] = true;
}

return results;
}
Loading