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

Webpack error when building platform plugins #123236

Closed
jportner opened this issue Jan 18, 2022 · 4 comments
Closed

Webpack error when building platform plugins #123236

jportner opened this issue Jan 18, 2022 · 4 comments
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team

Comments

@jportner
Copy link
Contributor

jportner commented Jan 18, 2022

Kibana version: current main (HEAD: 6dc31d7)

Describe the bug:

I am seeing a webpack error when building platform plugins.

Steps to reproduce:

  1. Make sure the Kibana repo directory is not named "kibana".

  2. Use the current main branch and run the script to build platform plugins:

    node scripts/build_kibana_platform_plugins
    
  3. Observe the console logs:

    ...
    [ts refs]  info Building TypeScript projects refs for tsconfig.refs.json...
    [ts refs]  info [tsc] > node_modules/typescript/bin/tsc -b tsconfig.refs.json --pretty
    [ts refs]  info [tsc] exited with 0 after 22.0 seconds
    [ts refs]  succ ts refs build successfully
    ✨  Done in 41.18s.
     info initialized, 145 bundles cached
     info starting worker [1 bundle]
    ERROR webpack compile errors
       │ERROR [reportingExample] build
           │ERROR Optimizations failure.
           │         35 modules
           │          
           │          ERROR in ./public/application.tsx
           │          Module not found: Error: Can't resolve '../../../../../kibana/src/plugins/kibana_react/public' in '/Users/joe/GitHub/kibana-1/x-pack/examples/reporting_example/public'
           │          resolve '../../../../../kibana/src/plugins/kibana_react/public' in '/Users/joe/GitHub/kibana-1/x-pack/examples/reporting_example/public'
           │            using description file: /Users/joe/GitHub/kibana-1/x-pack/package.json (relative path: ./examples/reporting_example/public)
           │              Field 'browser' doesn't contain a valid alias configuration
           │              No description file found
           │              no extension
           │                Field 'browser' doesn't contain a valid alias configuration
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public doesn't exist
           │              .js
           │                Field 'browser' doesn't contain a valid alias configuration
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public.js doesn't exist
           │              .ts
           │                Field 'browser' doesn't contain a valid alias configuration
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public.ts doesn't exist
           │              .tsx
           │                Field 'browser' doesn't contain a valid alias configuration
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public.tsx doesn't exist
           │              .json
           │                Field 'browser' doesn't contain a valid alias configuration
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public.json doesn't exist
           │              as directory
           │                /Users/joe/GitHub/kibana/src/plugins/kibana_react/public doesn't exist
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public/package.json]
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public]
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public.js]
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public.ts]
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public.tsx]
           │          [/Users/joe/GitHub/kibana/src/plugins/kibana_react/public.json]
           │           @ ./public/application.tsx 12:0-92 25:19-38
           │           @ ./public/plugin.ts
           │           @ ./public/index.ts
           │           @ /Users/joe/GitHub/kibana-1/node_modules/@kbn/optimizer/target_node/worker/entry_point_creator.js
    ERROR webpack issue
    

This error message in the console logs is telling:

"directory /Users/joe/GitHub/kibana/src/plugins/kibana_react/public doesn't exist"

My kibana directory is kibana-1, not kibana.

Also, I'm not sure why I am only seeing this error when running node scripts/build_kibana_platform_plugins, but I am not seeing it when using the optimizer via npm start - perhaps that's indicative of a bigger problem? Is npm start swallowing errors like this?

Expected behavior:

  1. Webpack should not fail, obviously 😄
  2. CI should catch relative paths that rely on Kibana being installed in a directory named "kibana" and prevent this (maybe this is as simple as changing CI to clone the Kibana repo to a directory with a different name than "kibana" like I have in my local setup?)
  3. Webpack should behave the same whether initiated via npm start or node scripts/build_kibana_platform_plugins (?) Edit: see Webpack error when building platform plugins #123236 (comment)

Any additional context:

It looks like the the problem was introduced in #122370. Any bigger fix to the bullets outlined above should also fix this problematic import:

import { KibanaThemeProvider } from '../../../../../kibana/src/plugins/kibana_react/public';

Edit: since I opened this issue, it looks like the problematic import has been fixed in #121644:

import { KibanaThemeProvider } from '../../../../src/plugins/kibana_react/public';

@jportner jportner added bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team labels Jan 18, 2022
@elasticmachine
Copy link
Contributor

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

@spalger
Copy link
Contributor

spalger commented Jan 19, 2022

Sounds like a reasonable eslint rule to have, took a look and eslint-plugin-import doesn't seem to have an off the shelf option for us.

@jportner
Copy link
Contributor Author

Sounds like a reasonable eslint rule to have, took a look and eslint-plugin-import doesn't seem to have an off the shelf option for us.

👍

3. Webpack should behave the same whether initiated via npm start or node scripts/build_kibana_platform_plugins (?)

After looking at this again, I realized that node scripts/build_kibana_platform_plugins is building 144 plugin bundles, while yarn start is only building 122. The one that's causing an error is an example plugin, so I guess those aren't getting built with yarn start by default.

@exalate-issue-sync exalate-issue-sync bot added impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. loe:small Small Level of Effort labels Feb 16, 2022
@tylersmalley tylersmalley removed loe:small Small Level of Effort impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. labels Mar 16, 2022
@tylersmalley
Copy link
Contributor

Closed in favor of #128017

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

No branches or pull requests

4 participants