kibana/packages/kbn-eslint-import-resolver-kibana
Spencer 4e8ab56497
build immutable bundles for new platform plugins (#53976)
* build immutable bundles for new platform plugins

* only inspect workers if configured to do so

* [navigation] use an index.scss file

* add yarn.lock symlink

* set pluginScanDirs in test so fixtures stay consistent

* cleanup helpers a little

* fix type error

* support KBN_OPTIMIZER_MAX_WORKERS for limiting workers via env

* test support for KBN_OPTIMIZER_MAX_WORKERS

* expand the available memory for workers when only running one or two

* add docs about KBN_OPTIMIZER_MAX_WORKERS environment variable

* fix README link

* update kbn/pm dist

* implement bundle caching/reuse

* update kbn/pm dist

* don't check for cache if --no-cache is passed

* update renovate config

* standardize on index.scss, move console styles over

* add support for --no-cache to cli

* include worker config vars in optimizer version

* ignore concatenated modules

* update integration test

* add safari to browserslist to avoid user-agent warnings in dev

* update docs, clean up optimizer message/misc naming

* always handle initialized messages, don't ignore states that are attached to specific events

* reword caching docs, add environment var to disable caching

* tweak logging and don't use optimizer.useBundleCache as that's disabled in dev

* handle change notifications

* batch changes for 1 second

* rename CompilerState type to CompilerMsg

* getChanges() no longer needs to assign changes to dirs

* remove unused deps

* split up run_worker.ts and share cacheKey generation logic

* add a couple docs

* update tests and remove unused imports

* specify files when creating bundle cache key

* remove one more unused import

* match existing dev cli output more closely

* update kbn/pm dist

* set KBN_NP_PLUGINS_BUILT to avoid warning in CI

* avoid extending global window type

* add note to keep pluginScanDirs in sync

* pass browserslistEnv in workerConfig so it is used for cache key

* load commons.bundle.js in parallel too

* emit initialized+success states if all bundles are cached

* load bootstraps as quickly as possible

* skip flaky suite

* bump

* update jest snapshots

* remove hashing from cache key generation

* remove unnecessary non-null assertion

* improve docs and break up Optimizer#run()

* remove unused import

* refactor kbn/optimizer to break up observable logic, implement more helpful cache invalidation logic with logging

* fix tests

* add initializing phase

* avoid rxjs observable constructor

* remove unnecessary rxjs helper, add tests for bundle cache

* update consumers of optimizer

* update readme with new call style

* replace "new platform" with "kibana platform"

* fix a couple more renames

* add support for several plain-text file formats

* fix naming of OptimizerMsg => OptimizerUpdate, use "store" naming too

* one more OptimizerMsg update

* ensure bundles are not cached when cache config is false

* test for initializing states and bundle cache events

* remove unnecessary timeout change

* Remove unnecessary helpers

* Add tests for BundleCache class

* Add tests for Bundle class

* test summarizeEvent$

* missing paths are no longer listed in mtimes map

* add tests for optimizer/cache_keys

* Add some extra docs

* Remove labeled loop

* add integration test for kbn-optimizer watcher components

* querystring-browser removed

* tweak logging a smidge, improve info and final message

* remove unused imports

* remove duplication of getModuleCount() method

* move type annotation that validates things

* clear up the build completion message

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-02-12 19:42:42 -07:00
..
lib [ui/utils/query_string]: Remove unused methods & migrate apps to querystring lib (#56957) 2020-02-12 19:51:03 +03:00
import_resolver_kibana.js Apache 2.0 license headers (#19383) 2018-05-28 20:06:30 -07:00
package.json build immutable bundles for new platform plugins (#53976) 2020-02-12 19:42:42 -07:00
README.md fix: name in import resolver readme (#21316) 2018-07-27 11:04:55 -07:00
yarn.lock Add lockfile symlinks (#55440) 2020-01-27 11:38:20 -05:00

@kbn/eslint-import-resolver-kibana

Resolver for Kibana imports, meant to be used with eslint-plugin-import.

Installation

To install this utility use yarn to link to the package from the Kibana project:

yarn add --dev link:../../kibana/packages/kbn-eslint-import-resolver-kibana

Usage

Specify this resolver with the import/resolver setting in your eslint config file:

# .eslintrc.yml
settings:
  import/resolver: "@kbn/eslint-import-resolver-kibana"

Settings

NOTE: All relative paths are resolved as relative to the project root, which is determined by walking up from the first linted file and looking for a package.json file. If your project has multiple package.json files then make sure to specify the rootPackageName setting.

Property Default Description
rootPackageName null The "name" property of the root package.json file. If your project has multiple package.json files then specify this setting to tell the resolver which package.json file sits at the root of your project.
pluginPaths [] if rootPackageName is set, otherwise [.] Array of relative paths which contain a Kibana plugin. Plugins must contain a package.json file to be valid.
pluginDirs [] Array of relative paths pointing to directories which contain Kibana plugins. Plugins must contain a package.json file to be valid.
pluginMap {} A map of plugin ids to relative paths, explicitly pointing to the location where Kibana should map plugin/{pluginId} import statements. Directories do not need to contain a package.json file to work.

Settings Usage

To specify additional config add a : after the resolver name and specify the argument as key-value pairs:

# .eslintrc.yml
settings:
  import/resolver:
    "@kbn/eslint-import-resolver-kibana":
      # if your project has multiple package.json files
      rootPackageName: my-project

      # if your project stores plugin source in sub directories you can specify
      # those directories via `pluginPaths`.
      pluginPaths:
        - ./plugin-one
        - ./plugin-two

      # if all of your plugins have the same parent directory you can specify
      # that directory and we will look for plugins there
      pluginDirs:
        - ./kibana-plugins

      # if you have some other special configuration supply a map of plugin
      # ids to the directory containing their code
      pluginMap:
        plugin1: plugins/plugin1
        plugin2: plugins/plugin2

See the resolvers docs or the resolver spec for more details.

Debugging

For debugging output from this resolver, run your linter with DEBUG=eslint-plugin-import:resolver:kibana.

This resolver defers to eslint-import-resolver-node and eslint-import-resolver-webpack for all of it's actual resolution logic. To get debugging output from all resolvers use DEBUG=eslint-plugin-import:resolver:*.