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

[Plugins] Problem with building plugins in 8.7.0 #154325

Closed
Karql opened this issue Apr 4, 2023 · 19 comments
Closed

[Plugins] Problem with building plugins in 8.7.0 #154325

Karql opened this issue Apr 4, 2023 · 19 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team

Comments

@Karql
Copy link

Karql commented Apr 4, 2023

Hi!

I have maintain a external plugin.

After upgrading kibana to version v8.7.0 a plugin after build has incorect path to @kbn/config-schema.

var _kbnConfigSchema = require("../../../packages/kbn-config-schema");

insted of: var _kbnConfigSchema = require("@kbn/config-schema");

image

Probably it is regression after: #146212

IMO I have configured everything correctly:

  • tsconfig.json
  • kibana.json
    etc.

When I run kibana in dev mode: yarn start --oss everything works ok, but problem occurs after plugin installation in desire instance.

Logs:

[2023-04-04T10:34:17.240+00:00][DEBUG][elasticsearch-service] Stopping elasticsearch service

 FATAL  Error: Cannot find module '../../../packages/kbn-config-schema'
Require stack:
- /usr/share/kibana/plugins/plugin-name/server/config.js
- /usr/share/kibana/plugins/plugin-name/server/index.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugin.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/plugins_discovery.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/index.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugins_service.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/index.js
- /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/index.js
- /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/server.js
- /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/index.js
- /usr/share/kibana/node_modules/@kbn/core-root-server-internal/index.js
- /usr/share/kibana/src/core/server/index.js
- /usr/share/kibana/src/cli/serve/serve.js
- /usr/share/kibana/src/cli/cli.js
- /usr/share/kibana/src/cli/dist.js

I have also tried copy plugin preboot_example from examples/ to plugins/ and add package.json:

{
  "name": "foo",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "yarn plugin-helpers build",
    "plugin-helpers": "node ../../scripts/plugin_helpers",
    "kbn": "node ../../scripts/kbn"
  }
}

but result is the same.
Here is plugin after build: prebootExample-8.7.0.zip

Best regards,
Mateusz

@Karql Karql added the bug Fixes for quality problems that affect the customer experience label Apr 4, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Apr 4, 2023
@jsanz jsanz added the Team:Operations Team label for Operations Team label Apr 11, 2023
@elasticmachine
Copy link
Contributor

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

@botelastic botelastic bot removed the needs-team Issues missing a team label label Apr 11, 2023
@andrewthad
Copy link

I'm encountering the same issue when trying to upgrade our plugins so that we can upgrade our stack to 8.7.0.

@mistic
Copy link
Member

mistic commented May 8, 2023

We will spend time looking into this once we get a chance on our backlog. Thanks for reporting this 👍

@mistic
Copy link
Member

mistic commented May 9, 2023

I've spent time looking at this issue and found out that the problem is fixed for 8.8 and onwards. I will investigate how much work would be to fix this for 8.7 (but I anticipate it is not trivial at this point).

As a workaround I would say you can use the Kibana 8.8 branch to build your plugins for v8.7.0 🙂

@andrewthad
Copy link

I didn't realize that kibana could load plugins built by a different version of kibana. It seems like I had trouble with that in the past, but I'll give it a try and let you know what I find.

@mistic
Copy link
Member

mistic commented May 9, 2023

@andrewthad when running yarn build on your plugin using kibana 8.8 you can list ,in one of the prompts from the cli, 8.7.1 as your target 🙂

Let me know what you find out after trying it 👍

@Karql
Copy link
Author

Karql commented May 10, 2023

Thank you @mistic

I have tried it looks like in 8.8 problem with @kbn/config-schema is fixed.

But there is another one.

For plugin.ts setup:

...
  public setup(core: CoreSetup): PluginNamePluginSetup {
    // Register an application into the side navigation menu
    core.application.register({
      id: 'pluginName',
      title: PLUGIN_NAME,
      async mount(params: AppMountParameters) {
        // Load application bundle


        const { renderApp } = await import('./application'); // <--- THIS LINE
...

I get error:

image

image

image

For older version in this chunk I have number insted of path something like this:

e.exports=i(19)(2)

Other plugins in kibana instance looks similar e.g:

kibana@3eafb8eb6280:~/src/plugins/home/target/public$ cat home.chunk.1.js
(window.home_bundle_jsonpfunction=window.home_bundle_jsonpfunction||[]).push([[1],Array(23).concat([function(e,t,a){e.exports=a(6)(3)},function(e,t,a){e.exports=a(6)(2664)},

Do I forgot about something?

I have done similar action like for preBootExample for examples/search_examples (it has similar code).

  1. copy examples/search_examples to plugins

  2. add package.json

{
  "name": "foo",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "yarn plugin-helpers build",
    "plugin-helpers": "node ../../scripts/plugin_helpers",
    "kbn": "node ../../scripts/kbn"
  }
}
  1. remove kiban.jsonc and add kibana.json
{
  "owner": {
    "name": "owner"
  },
  "description": "Foo",
  "version": "1.0.0",
  "id": "searchExamples",
  "server": true,
  "ui": true,
  "browser": true,
  "requiredPlugins": [
    "navigation",
    "data",
    "developerExamples",
    "inspector",
    "kibanaUtils",
    "share",
    "unifiedSearch"
  ],
  "requiredBundles": [
    "kibanaReact"
  ]
}
  1. build: yarn build --kibana-version=8.7.1

After build there is also a path in exports:

{e.exports=s(9)("../../node_modules/@babel/runtime/helpers/extends.js")

searchExamples-8.7.1.zip

@mistic
Copy link
Member

mistic commented May 11, 2023

@Karql I just realised that on the previous workaround , and in more complex plugin scenarios, due to the way we static link and map shared dependencies this error could occur. I think I was able to successfully fix the problem for 8.7. I believe if you checkout now the latest head from Kibana 8.7 branch and build your plugin for 8.7.x against it this problem is now fixed.

Let me know about it 🤞

@andrewthad
Copy link

I was able to use yarn build in 8.8 and target version 8.7.1. That resolved the problem I was having. Thanks!

@Karql
Copy link
Author

Karql commented May 12, 2023

@mistic still the same.

I have checkout to 8.7 with your last commit: 277e80d

After build chunk contains path in e.exports.

Tested also for search-example: searchExamples-8.7.1.zip

@mistic
Copy link
Member

mistic commented May 12, 2023

@Karql that detail in the chunk is not important is just a part of how we static link against single version dependencies we ship and bundle with Kibana using a DLL. I just tried to build the searchExample you mentioned against the latest head in 8.7 branch and everything seems to be working well as the plugins loads as expected after being built. The result of my build is attached to this comment: foo-8.7.2.zip

@Karql
Copy link
Author

Karql commented May 12, 2023

@mistic my mistake I have thought that path is the problem.

But my plugin is not working:
image

image

Here is it: elastalertKibanaPlugin-8.7.1.zip

You can use any settings e.g.:

elastalertKibanaPlugin.serverSsl: false
elastalertKibanaPlugin.serverHost: elastalert
elastalertKibanaPlugin.serverPort: 3030

to check only is pluging will loading.

Here is source code: https://github.com/Karql/elastalert-kibana-plugin/tree/build-issue

@kbujold
Copy link

kbujold commented May 15, 2023

We have similar issues in 8.7.1. This was working in 8.6.2

import { schema as configSchema } from '@kbn/config-schema';

023-05-15T22:04:47.810846298Z stdout F Created Kibana keystore in /usr/share/kibana/config/kibana.keystore
2023-05-15T22:04:52.859127983Z stdout F [2023-05-15T22:04:52.825+00:00][INFO ][node] Kibana process configured with roles: [background_tasks, ui]
2023-05-15T22:04:53.138440172Z stdout F [2023-05-15T22:04:53.127+00:00][FATAL][root] Error: Cannot find module '../../../../../../packages/kbn-config-schema'
2023-05-15T22:04:53.138461217Z stdout F Require stack:
2023-05-15T22:04:53.13846503Z stdout F - /usr/share/kibana/plugins/wind/server/lib/adapters/framework/kibana.js
2023-05-15T22:04:53.138468112Z stdout F - /usr/share/kibana/plugins/wind/server/lib/adapters/framework/index.js
2023-05-15T22:04:53.138470504Z stdout F - /usr/share/kibana/plugins/wind/server/lib/compose/kibana.js
2023-05-15T22:04:53.138476703Z stdout F - /usr/share/kibana/plugins/wind/server/plugin.js
2023-05-15T22:04:53.138481754Z stdout F - /usr/share/kibana/plugins/wind/server/index.js
2023-05-15T22:04:53.138485425Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugin.js
2023-05-15T22:04:53.138488697Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/plugins_discovery.js
2023-05-15T22:04:53.138493471Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/index.js
2023-05-15T22:04:53.138495927Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugins_service.js
2023-05-15T22:04:53.138498354Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/index.js
2023-05-15T22:04:53.138500707Z stdout F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/index.js
2023-05-15T22:04:53.138503Z stdout F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/server.js
2023-05-15T22:04:53.138505363Z stdout F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/index.js
2023-05-15T22:04:53.13850779Z stdout F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/index.js
2023-05-15T22:04:53.13851018Z stdout F - /usr/share/kibana/src/core/server/index.js
2023-05-15T22:04:53.1385125Z stdout F - /usr/share/kibana/src/cli/serve/serve.js
2023-05-15T22:04:53.138514863Z stdout F - /usr/share/kibana/src/cli/cli.js
2023-05-15T22:04:53.138517124Z stdout F - /usr/share/kibana/src/cli/dist.js
2023-05-15T22:04:53.138519426Z stdout F     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
2023-05-15T22:04:53.138522044Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:81:25)
2023-05-15T22:04:53.13852438Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/elastic-apm-node/lib/ritm.js:108:34)
2023-05-15T22:04:53.13852684Z stdout F     at require (node:internal/modules/cjs/helpers:108:18)
2023-05-15T22:04:53.138529133Z stdout F     at Object.<anonymous> (/usr/share/kibana/plugins/wind/server/lib/adapters/framework/kibana.ts:23:1)
2023-05-15T22:04:53.13853142Z stdout F     at Module._compile (node:internal/modules/cjs/loader:1191:14)
2023-05-15T22:04:53.1385337Z stdout F     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
2023-05-15T22:04:53.138535975Z stdout F     at Module.load (node:internal/modules/cjs/loader:1069:32)
2023-05-15T22:04:53.138538285Z stdout F     at Function.Module._load (node:internal/modules/cjs/loader:904:12)
2023-05-15T22:04:53.13854056Z stdout F     at Module.require (node:internal/modules/cjs/loader:1093:19)
2023-05-15T22:04:53.13854291Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.13854528Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138547538Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138549829Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138563269Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138566002Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/elastic-apm-node/lib/ritm.js:129:39)
2023-05-15T22:04:53.138568342Z stdout F     at require (node:internal/modules/cjs/helpers:108:18)
2023-05-15T22:04:53.138571134Z stdout F     at Object.<anonymous> (/usr/share/kibana/plugins/wind/server/lib/adapters/framework/index.ts:8:1)
2023-05-15T22:04:53.138573505Z stdout F     at Module._compile (node:internal/modules/cjs/loader:1191:14)
2023-05-15T22:04:53.138575865Z stdout F     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
2023-05-15T22:04:53.138578459Z stdout F     at Module.load (node:internal/modules/cjs/loader:1069:32)
2023-05-15T22:04:53.138580728Z stdout F     at Function.Module._load (node:internal/modules/cjs/loader:904:12)
2023-05-15T22:04:53.138586189Z stdout F     at Module.require (node:internal/modules/cjs/loader:1093:19)
2023-05-15T22:04:53.138589679Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138592104Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138594392Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138596704Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138599067Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138601325Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/elastic-apm-node/lib/ritm.js:129:39)
2023-05-15T22:04:53.138603574Z stdout F     at require (node:internal/modules/cjs/helpers:108:18)
2023-05-15T22:04:53.138620156Z stdout F     at Object.<anonymous> (/usr/share/kibana/plugins/wind/server/lib/compose/kibana.ts:10:1)
2023-05-15T22:04:53.138623821Z stdout F     at Module._compile (node:internal/modules/cjs/loader:1191:14)
2023-05-15T22:04:53.138626217Z stdout F     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
2023-05-15T22:04:53.138628516Z stdout F     at Module.load (node:internal/modules/cjs/loader:1069:32)
2023-05-15T22:04:53.138630989Z stdout F     at Function.Module._load (node:internal/modules/cjs/loader:904:12)
2023-05-15T22:04:53.138633279Z stdout F     at Module.require (node:internal/modules/cjs/loader:1093:19)
2023-05-15T22:04:53.13863562Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138637909Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138640247Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138642579Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138644843Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.138647152Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/elastic-apm-node/lib/ritm.js:129:39)
2023-05-15T22:04:53.138649524Z stdout F     at require (node:internal/modules/cjs/helpers:108:18)
2023-05-15T22:04:53.138651809Z stdout F     at Object.<anonymous> (/usr/share/kibana/plugins/wind/server/plugin.ts:12:1)
2023-05-15T22:04:53.138654107Z stdout F     at Module._compile (node:internal/modules/cjs/loader:1191:14)
2023-05-15T22:04:53.13866042Z stdout F     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
2023-05-15T22:04:53.138662996Z stdout F     at Module.load (node:internal/modules/cjs/loader:1069:32)
2023-05-15T22:04:53.13866531Z stdout F     at Function.Module._load (node:internal/modules/cjs/loader:904:12)
2023-05-15T22:04:53.1386676Z stdout F     at Module.require (node:internal/modules/cjs/loader:1093:19)
2023-05-15T22:04:53.138669923Z stdout F     at Module.Hook._require.Module.require (/usr/share/kibana/node_modules/require-in-the-middle/index.js:101:39)
2023-05-15T22:04:53.14110042Z stderr F
2023-05-15T22:04:53.141114913Z stderr F  FATAL  Error: Cannot find module '../../../../../../packages/kbn-config-schema'
2023-05-15T22:04:53.141118637Z stderr F Require stack:
2023-05-15T22:04:53.14112131Z stderr F - /usr/share/kibana/plugins/wind/server/lib/adapters/framework/kibana.js
2023-05-15T22:04:53.14112382Z stderr F - /usr/share/kibana/plugins/wind/server/lib/adapters/framework/index.js
2023-05-15T22:04:53.141126124Z stderr F - /usr/share/kibana/plugins/wind/server/lib/compose/kibana.js
2023-05-15T22:04:53.141128936Z stderr F - /usr/share/kibana/plugins/wind/server/plugin.js
2023-05-15T22:04:53.14113145Z stderr F - /usr/share/kibana/plugins/wind/server/index.js
2023-05-15T22:04:53.141150768Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugin.js
2023-05-15T22:04:53.141153248Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/plugins_discovery.js
2023-05-15T22:04:53.141155963Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/discovery/index.js
2023-05-15T22:04:53.141160038Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/plugins_service.js
2023-05-15T22:04:53.141162432Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/src/index.js
2023-05-15T22:04:53.141165783Z stderr F - /usr/share/kibana/node_modules/@kbn/core-plugins-server-internal/index.js
2023-05-15T22:04:53.141168245Z stderr F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/server.js
2023-05-15T22:04:53.141170628Z stderr F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/src/index.js
2023-05-15T22:04:53.141173075Z stderr F - /usr/share/kibana/node_modules/@kbn/core-root-server-internal/index.js
2023-05-15T22:04:53.141175382Z stderr F - /usr/share/kibana/src/core/server/index.js
2023-05-15T22:04:53.141177652Z stderr F - /usr/share/kibana/src/cli/serve/serve.js
2023-05-15T22:04:53.141179925Z stderr F - /usr/share/kibana/src/cli/cli.js
2023-05-15T22:04:53.141182332Z stderr F - /usr/share/kibana/src/cli/dist.js
2023-05-15T22:04:53.141184429Z stderr F

@Karql
Copy link
Author

Karql commented May 31, 2023

Hi @mistic !

Probably I have found the problem.

Problem occurs when plugin code contains properties in class.

Simplified example:

  1. generate plugin node scripts/generate_plugin foo-plugin
    generate

  2. Add sample component:

// ./public/components/bar/bar.tsx
import React, { Component  } from 'react';

export class Bar extends Component {
  private bar = "foo"; // Not working with this line :(
    
  render() {
    return (
      <div>bar component</div>
    );
  }
}
// ./public/components/bar/index.ts
export { Bar } from './bar';
  1. Use component in plugin:
// ./public/components/app.tsx
...
import { Bar } from './bar'
...

                  </EuiText>
                  <Bar></Bar>
                </EuiPageContentBody>
...
  1. Build plugin

After these steps when I try to run plugin in kibana I recieve error:

image

image

When there is no property in component - plugin launches correctly.

IMO in chunk instead of ../../node_modules/@babel/runtime/helpers/defineProperty.js should be some integer like for chunks generated for previous kibana.

When I put brake point in this export:

image

and call n(18)(2) in console I get something that looks promising:

image

Here is plugin after build: fooPlugin-8.8.0.zip

How to deal with this?

Best regards,
Mateusz

@kbujold
Copy link

kbujold commented Jun 8, 2023

We have the same issue with Kibana 8.8.0 and 8.8.1. Our build results with same error as mentioned above. @mistic Any idea on how this can fixed?

image

Thank you,
Kris

@brenoandrade-wdrv
Copy link

I'm also getting errors like those:

`Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.
core.entry.js:1 TypeError: Cannot read properties of undefined (reading 'call')
at o (kbn-ui-shared-deps-npm.dll.js:1:388)
at ../../node_modules/webpack/buildin/global.js (wind.chunk.0.js:21:121)
at webpack_require (bootstrap:63:1)
at ./node_modules/@apollo/client/utilities/globals/globals.cjs (globals.cjs:56:1)
at webpack_require (bootstrap:63:1)
at ./node_modules/@apollo/client/core/core.cjs (core.cjs:5:1)
at webpack_require (bootstrap:63:1)
at ./node_modules/@apollo/client/main.cjs (main.cjs:5:1)
at webpack_require (bootstrap:63:1)
at ./public/components/app.tsx (app.tsx:1:1)
securitySolution.chunk.17.js:3 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'includes')
at securitySolution.chunk.17.js:3:27222
at async pe (securitySolution.chunk.17.js:3:26969)
at async Object.next (securitySolution.plugin.js:2:56386)

module.exports = (webpack_require(/! dll-reference kbnSharedDeps_npm / "dll-reference kbnSharedDeps_npm"))("../../node_modules/webpack/buildin/global.js");
/
*/ }),`

@brenoandrade-wdrv
Copy link

brenoandrade-wdrv commented Jun 9, 2023

The issue is related to the NODE_ENV environment stuff.

From this change:

afb09cc#diff-e2954b558f2aa82baff0e30964490d12942e0e251c1aa56c3294de6ec67b7cf5

They've kept the packages: 'kbn-ui-shared-deps-npm' and 'kbn-ui-shared-deps-src' using bazel and they've managed the webpack modules by applying the NODE_ENV environment variable.

Not sure how to manage this, I've tried to manage on Dockerfiles before installing the plugin and it hasn't worked.

image

By reverting the webpack.config.js under those Kibana packages and building the plugin I've got the plugin working again. (i.g., I've reverted the mode to be 'production' hard-coded)

How should external plugins approach this environment in order to ship Kibana?

@mistic
Copy link
Member

mistic commented Jun 10, 2023

@brenoandrade-wdrv could you please provide an example plugin that when building with the current settings builds correctly and is then erroring out when trying to load it in production on the page? I will try to look at this next week

@brenoandrade-wdrv
Copy link

Hi @mistic
I've provided the following example in this issue I raised:
#159328

You can check out from these repositories:

https://github.com/brenoandrade-wdrv/graphql-plugin-example/tree/8.8.0 (Minimalist plugin using apollo-client / graphQL)

https://github.com/brenoandrade-wdrv/kibana-8.8.0-graphql-issue/tree/8.8.0 (Docker compose approaching production environment)

Note: There's also 8.6.2 branch that works properly by applying the same approach.

Thanks, Breno.

@mistic mistic self-assigned this Jun 12, 2023
mistic added a commit that referenced this issue Jun 14, 2023
…ode (#159630)

Closes #159328 ,
#154325,
#157440

This PR fixes a problem in the plugin helpers tasks used to build
external plugins. After changes to transpile packages differently in the
past months a bug was introduced and external plugins were being built
with the wrong shared ui deps output mode causing development form
imports to be bundled and causing problems at page load time.

---------

Co-authored-by: kibanamachine <[email protected]>
@mistic mistic closed this as completed Jun 14, 2023
kibanamachine pushed a commit that referenced this issue Jun 14, 2023
…ode (#159630)

Closes #159328 ,
#154325,
#157440

This PR fixes a problem in the plugin helpers tasks used to build
external plugins. After changes to transpile packages differently in the
past months a bug was introduced and external plugins were being built
with the wrong shared ui deps output mode causing development form
imports to be bundled and causing problems at page load time.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 7e067ec)
kibanamachine pushed a commit that referenced this issue Jun 14, 2023
…ode (#159630)

Closes #159328 ,
#154325,
#157440

This PR fixes a problem in the plugin helpers tasks used to build
external plugins. After changes to transpile packages differently in the
past months a bug was introduced and external plugins were being built
with the wrong shared ui deps output mode causing development form
imports to be bundled and causing problems at page load time.

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 7e067ec)
mistic added a commit that referenced this issue Jun 14, 2023
…tput mode (#159630) (#159760)

# Backport

This will backport the following commits from `main` to `8.7`:
- [fix(NA): build external plugins with correct bazel artifacts output
mode (#159630)](#159630)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tiago
Costa","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-14T23:43:05Z","message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","auto-backport","v8.7.2","v8.9.0","v8.8.2"],"number":159630,"url":"https://github.com/elastic/kibana/pull/159630","mergeCommit":{"message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.8"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159630","number":159630,"mergeCommit":{"message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tiago Costa <[email protected]>
mistic added a commit that referenced this issue Jun 15, 2023
…tput mode (#159630) (#159761)

# Backport

This will backport the following commits from `main` to `8.8`:
- [fix(NA): build external plugins with correct bazel artifacts output
mode (#159630)](#159630)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tiago
Costa","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-14T23:43:05Z","message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","auto-backport","v8.7.2","v8.9.0","v8.8.2"],"number":159630,"url":"https://github.com/elastic/kibana/pull/159630","mergeCommit":{"message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7"}},"sourceBranch":"main","suggestedTargetBranches":["8.7","8.8"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159630","number":159630,"mergeCommit":{"message":"fix(NA):
build external plugins with correct bazel artifacts output mode
(#159630)\n\nCloses #159328
,\r\nhttps://github.com//issues/154325,\r\nhttps://github.com//issues/157440\r\n\r\nThis
PR fixes a problem in the plugin helpers tasks used to build\r\nexternal
plugins. After changes to transpile packages differently in the\r\npast
months a bug was introduced and external plugins were being
built\r\nwith the wrong shared ui deps output mode causing development
form\r\nimports to be bundled and causing problems at page load
time.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"7e067ec47866007051be6afad2a46ab9f8438cb7"}},{"branch":"8.8","label":"v8.8.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tiago Costa <[email protected]>
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

7 participants