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

Platform X-Pack plugins can't import non-types from client-side/public Core. #58327

Closed
azasypkin opened this issue Feb 24, 2020 · 9 comments · Fixed by #61011
Closed

Platform X-Pack plugins can't import non-types from client-side/public Core. #58327

azasypkin opened this issue Feb 24, 2020 · 9 comments · Fixed by #61011
Assignees
Labels
blocker bug Fixes for quality problems that affect the customer experience Feature:New Platform Team:Operations Team label for Operations Team

Comments

@azasypkin
Copy link
Member

azasypkin commented Feb 24, 2020

We're not sure yet where the underlying problem is and whether it's optimizer related, but here is what we see with these reduced steps-to-reproduce:

  1. If we import enum from the core using 'src/core/public' alias:
// e.g. from x-pack/plugins/security/public/plugin.tsx
import { AppNavLinkStatus } from 'src/core/public';
.....
const hidden = AppNavLinkStatus.hidden;
....

Optimizer fails with:

np bld    log   [12:03:16.392] [error][@kbn/optimizer] webpack compile errors
   │np bld    log   [12:03:16.392] [error][@kbn/optimizer] [security] build
       │np bld    log   [12:03:16.392] [error][@kbn/optimizer] Optimizations failure.
       │         700 modules
       │          
       │          ERROR in ./public/plugin.tsx
       │          Module not found: Error: Can't resolve 'src/core/public' in '/projects/elastic/master/kibana/x-pack/plugins/security/public'
  1. If we import enum from the core using relative path:
// e.g. from x-pack/plugins/security/public/plugin.tsx
import { AppNavLinkStatus } from '../../../../src/core/public';
.....
const hidden = AppNavLinkStatus.hidden;
....

Optimizer fails with:

np bld    log   [12:07:29.741] [error][@kbn/optimizer] webpack compile errors
   │np bld    log   [12:07:29.742] [error][@kbn/optimizer] [security] build
       │np bld    log   [12:07:29.742] [error][@kbn/optimizer] Optimizations failure.
       │         1122 modules
       │          
       │          ERROR in /projects/elastic/master/kibana/src/core/public/legacy/legacy_service.ts
       │          Module not found: Error: Can't resolve 'ui/chrome' in '/projects/elastic/master/kibana/src/core/public/legacy'

       │          ERROR in /projects/elastic/master/kibana/src/core/public/legacy/legacy_service.ts
       │          Module not found: Error: Can't resolve 'ui/new_platform' in '/projects/elastic/master/kibana/src/core/public/legacy'
       │          
       │          ERROR in /projects/elastic/master/kibana/src/legacy/ui/public/routes/route_setup_manager.js
       │          Module not found: Error: Can't resolve 'ui/promises' in '/projects/elastic/master/kibana/src/legacy/ui/public/routes'

       │          ERROR in /projects/elastic/master/kibana/src/legacy/ui/public/routes/wrap_route_with_prep.js
       │          Module not found: Error: Can't resolve 'ui/promises' in '/projects/elastic/master/kibana/src/legacy/ui/public/routes'
       │          
       │          ERROR in /projects/elastic/master/kibana/src/core/public/legacy/legacy_service.ts
       │          Module not found: Error: Can't resolve 'ui/test_harness' in '/projects/elastic/master/kibana/src/core/public/legacy'

       │          ERROR in /projects/elastic/master/kibana/src/core/public/core.css 5:0
       │          Module parse failed: Unexpected token (5:0)
       │          You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
       │          |  * prevention previously handled in kbn_chrome.less
       │          |  */
       │          > .coreSystemRootDomElement {
       │          |   overflow-x: hidden;
       │          |   min-width: 100%;

Type check scripts seems to be OK with either of the approaches above. When we import just type's, interface's etc. everything works as expected.

/cc @restrry

@azasypkin azasypkin added bug Fixes for quality problems that affect the customer experience blocker Team:Operations Team label for Operations Team Feature:New Platform labels Feb 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@mshustov
Copy link
Contributor

to note: it's not related to enum implementation in TS. I have failure for the next case as well:

// src/core/public/index.ts
export const hello = 'world';
// x-pack
import { hello } from 'src/core/public';

@azasypkin
Copy link
Member Author

Hey @elastic/kibana-operations ,

Did you have a chance to take a look at this issue? We had to resort to workarounds for now (using hardcoded values instead of enum members provided by the core).

@rudolf
Copy link
Contributor

rudolf commented Mar 6, 2020

This is also affecting the SIEM team's NP migration.

@spalger
Copy link
Contributor

spalger commented Mar 6, 2020

Sorry, but the build system for Kibana platform plugins doesn't support all of the crazy things the legacy optimizer does, including aliases like ui/. Since core includes tons of legacy code we can't import core in plugins built by the Kibana platform build system. The values you're describing need to be provided via the core API or from a module that doesn't include tons of legacy code.

@mshustov
Copy link
Contributor

mshustov commented Mar 6, 2020

The values you're describing need to be provided via the core API

We can go this way, although it will require public API refactoring later.

As I can see src/core/public/legacy contains references to ui/new_platform, ui/test_harness, ui/chrome. Can we load them separately and provide as webpack.externals?

@spalger
Copy link
Contributor

spalger commented Mar 6, 2020

If those modules wanted to write a global and then the src/core/public/legacy wanted to read those globals then we could remove all ui/ imports from core. I imagine this working great. No changes to webpack required.

@joshdover
Copy link
Contributor

@rylnd How pressing of a blocker is this for SIEM right now? From my understanding, the SIEM client-side migration is still blocked by the Maps embeddable as well. Would it be acceptable if this is solved around the same time as that during 7.8?

@rylnd
Copy link
Contributor

rylnd commented Mar 11, 2020

@joshdover yep, the Maps embeddable is the bigger issue as we lose UI functionality. This one can happen any time before then 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Fixes for quality problems that affect the customer experience Feature:New Platform Team:Operations Team label for Operations Team
Projects
Development

Successfully merging a pull request may close this issue.

7 participants