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 do not compile #157440

Closed
desean1625 opened this issue May 11, 2023 · 17 comments
Closed

Plugins do not compile #157440

desean1625 opened this issue May 11, 2023 · 17 comments
Labels
bug Fixes for quality problems that affect the customer experience Team:Operations Team label for Operations Team

Comments

@desean1625
Copy link
Contributor

Kibana version:
main branch

Describe the bug:
Plugins are not compiling correctly
Steps to reproduce:

node scripts/generate_plugin.js
? Plugin name (use camelCase) test_me
? Provide a description for your plugin. test_me
? Who is developing and maintaining this plugin? test
? Should an UI plugin be generated? Yes
? Should a server plugin be generated? Yes 
succ 🎉      
Your plugin has been created in plugins/test_me

2 yarn start --config ./config/kibana.dev.yml --no-base-path
I see my plugin [plugins-system.standard] Setting up [137] plugins: [.... testMe ...]
But the plugin is never actually compiled and I get 404 when served
GET http://localhost:55601/9007199254740991/bundles/plugin/testMe/1.0.0/testMe.plugin.js net::ERR_ABORTED 404 (Not Found)
loadScript @ bootstrap.js:81

Expected behavior:
It to work.

@desean1625 desean1625 added the bug Fixes for quality problems that affect the customer experience label May 11, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label May 11, 2023
@jsanz
Copy link
Member

jsanz commented May 12, 2023

I could reproduce this issue on main following @desean1625 steps.

image

@jsanz jsanz added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label May 12, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@botelastic botelastic bot removed the needs-team Issues missing a team label label May 12, 2023
@pgayvallet
Copy link
Contributor

@elastic/kibana-operations I'm not sure which one of our two teams the plugin generator is owned by 😅 ?

@desean1625
Copy link
Contributor Author

@elastic/kibana-operations I'm not sure which one of our two teams the plugin generator is owned by 😅 ?

It's not the plugin generation that is broken it is more the web pack configuration and serving of compiled plugins.

@desean1625
Copy link
Contributor Author

I just broke the issue down into an easily reproducible example utilizing only the documented toolset.

@mistic
Copy link
Member

mistic commented May 15, 2023

@desean1625 I believe you are missing the step to actually build your plugin https://www.elastic.co/guide/en/kibana/current/plugin-tooling.html#_run_kibana_with_your_plugin_in_dev_mode

@desean1625
Copy link
Contributor Author

@mistic yarn build is for building the distributable tar. When you run kibana in dev it sets up a watch and builds the plugins when changed. If you git checkout 8.6.2 or prior you will see that the steps to reproduce do not cause an error and the plugin is built and served correctly.

@pgayvallet
Copy link
Contributor

pgayvallet commented May 16, 2023

If it works on 8.6.x then the first potential culprit coming to mind would be #149370 (or its follow ups)

@pgayvallet
Copy link
Contributor

When you run kibana in dev it sets up a watch and builds the plugins when changed

From the doc @mistic linked:

Run Kibana with your plugin in dev mode

If your plugin isn’t server only and contains ui in order for Kibana to pick the browser bundles you need to run yarn dev --watch in the plugin root folder at a dedicated terminal.
Then, in a second terminal, run yarn start at the Kibana root folder. Make sure Kibana found and bootstrapped your plugin by:

The relevant part being: you need to run yarn dev --watch in the plugin root folder at a dedicated terminal

IIRC the 'default' dev optimizer process (launched with the server via yarn start or node script/kibana) no longer handle custom plugins, which is why the second command (yarn dev --watch from the custom plugin folder) is now necessary.

FWIW, doing exactly what's documented works on my side.

Plugin is compiled
Screenshot 2023-05-16 at 08 54 49

and loaded
Screenshot 2023-05-16 at 08 54 33

@desean1625 can you confirm that following the instructions works on your side too?

@jsanz
Copy link
Member

jsanz commented May 16, 2023

For what is worth, running yarn dev --watch on the plugin folder worked for me.

@desean1625
Copy link
Contributor Author

desean1625 commented May 16, 2023

@pgayvallet you are right. looks like 1b85815 removed the kbn-plugin-discovery that changed the default pluginScanDirs (rootDir, 'plugins') I thought that I had tried to supply the command line --pluginScanDirs option and that didn't work.

Running yarn dev --watch from the custom plugin folder works if you only have one or two plugins, but when you have more than a couple it becomes tedious.

@desean1625
Copy link
Contributor Author

desean1625 commented May 16, 2023

I would argue that since that folder is hardcoded to be watched as a plugin discovery path here it should also as a default be fed into the optimizer to be compiled. Like it used to be.

@pgayvallet
Copy link
Contributor

pgayvallet commented May 22, 2023

when you have more than a couple it becomes tedious.

True, can't deny it. OTOH, are you often developing more than one or two custom Kibana plugin at a time?

it should also as a default be fed into the optimizer to be compiled. Like it used to be.

I lack the history behind that change unfortunatly, as it was driven by another team. @elastic/kibana-operations does anyone remember why this change was performed?

@desean1625
Copy link
Contributor Author

are you often developing more than one or two custom Kibana plugin at a time?

Our projects are structured similar to x-pack. Some of our plugins have dependencies on other plugins.

@pgayvallet pgayvallet added Team:Operations Team label for Operations Team and removed Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels May 30, 2023
@pgayvallet
Copy link
Contributor

reassigning to @elastic/kibana-operations given the question / change request is on their side.

@kbujold
Copy link

kbujold commented May 30, 2023

We are running into this issue as well after upgrading our plugin from Kibana 8.6.2 to 8.8.0.

We get this error with 'yarn dev --watch'

yarn dev --watch --debug --verbose
yarn run v1.22.19
$ yarn plugin-helpers dev --watch --debug --verbose
$ node ../../scripts/plugin_helpers dev --watch --debug --verbose
debg KIBANA_CI_STATS_CONFIG environment variable not found, disabling CiStatsReporter
info deleting the target folder
info running @kbn/optimizer in watch mode (use CTRL+C to quit)
│ERROR Using kebab-case for css properties in objects is not supported. Did you mean paddingInline?
│ERROR Optimizer failure: Failed to compile with webpack:
│ Hash: 125f5d429b4417e0aa15
│ Version: webpack 4.46.0
│ Time: 5268ms
│ Built at: 2023-05-30 2:31:25 p.m.
│ Asset Size Chunks Chunk Names
│ b6943c77b7fdef864cf90d27187aa0bb.svg 210 KiB
│ wind.chunk.0.js 1.56 MiB 0
│ wind.chunk.0.js.map 1.38 MiB 0 [dev]
│ wind.plugin.js 64.4 KiB wind wind
│ wind.plugin.js.map 45.9 KiB wind [dev] wind
│ Entrypoint wind = wind.plugin.js wind.plugin.js.map
│ [../../node_modules/css-loader/dist/cjs.js?!../../node_modules/postcss-loader/dist/cjs.js?!../../node_modules/sass-loader/dist/cjs.js?!./public/index.scss?v8dark] /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-0-1!/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/postcss-loader/dist/cjs.js??ref--6-oneOf-0-2!/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-0-3!./public/index.scss?v8dark 8.24 KiB {wind} [built]
│ [../../node_modules/css-loader/dist/cjs.js?!../../node_modules/postcss-loader/dist/cjs.js?!../../node_modules/sass-loader/dist/cjs.js?!./public/index.scss?v8light] /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/css-loader/dist/cjs.js??ref--6-oneOf-1-1!/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/postcss-loader/dist/cjs.js??ref--6-oneOf-1-2!/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-1-3!./public/index.scss?v8light 8.24 KiB {wind} [built]
│ [../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js] /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js 6.67 KiB {wind} [built]
│ [../../node_modules/val-loader/dist/cjs.js?key=wind!../../packages/kbn-ui-shared-deps-npm/src/public_path_module_creator.js] /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/node_modules/val-loader/dist/cjs.js?key=wind!/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/packages/kbn-ui-shared-deps-npm/src/public_path_module_creator.js 58 bytes {wind} [not cacheable] [built]
│ [../../packages/kbn-optimizer/src/worker/entry_point_creator.ts] /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/packages/kbn-optimizer/src/worker/entry_point_creator.ts 367 bytes {wind} [not cacheable] [built]
│ [./common/constants/index.ts] 3.63 KiB {wind} [built]
│ [./public/application.tsx] 586 bytes {0} [built]
│ [./public/assets/WR_Favicon.svg] 82 bytes {wind} [built]
│ [./public/components/app.tsx] 2.38 KiB {0} [built]
│ [./public/index.scss] 159 bytes {wind} [built]
│ [./public/index.scss?v8dark] 688 bytes {wind} [built]
│ [./public/index.scss?v8light] 689 bytes {wind} [built]
│ [./public/index.ts] 223 bytes {wind} [built]
│ [./public/plugin.ts] 1.21 KiB {wind} [built]
│ [@kbn/i18n] external "kbnSharedDeps.KbnI18n" 42 bytes {wind} [built]
│ + 205 hidden modules

│ ERROR in /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/packages/kbn-optimizer/src/worker/entry_point_creator.ts
│ Module not found: Error: Can't resolve '../../../../plugins/wind/common' in '/localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/packages/kbn-optimizer/src/worker'
│ @ /localdisk/designer/kbujold/starlingx-0-wra2/cgcs-root/wrs/analytics/git/elastic/kibana/packages/kbn-optimizer/src/worker/entry_point_creator.ts 2:65-115

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]>
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]>
@mistic
Copy link
Member

mistic commented Jun 20, 2023

The building problem reported on this issue was solved at #159630.

For the improvement when working at multiple plugins at the same time I've opened #160018.

Closing this one.

@mistic mistic closed this as completed Jun 20, 2023
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

6 participants