New Platform Plugin - disallowed syntax found

Hello everyone, in legacy plugins I was able to run the following import:
import EditorJs from 'react-editor-js';

In the new platform (v7.8.2) I can no longer do that import.
This generates the following errors (when using node scripts/build_kibana_platform_plugins), is there a workaround? my plugin is not used by other plugins.

$ node scripts/build_kibana_platform_plugins
 info initialized, 99 bundles cached
 info starting worker [1 bundles, ? modules]
ERROR webpack compile errors
   β”‚ERROR [myPlugin] build
       β”‚ERROR Optimizations failure.
       β”‚         186 modules
       β”‚          
       β”‚          ERROR in ./node_modules/@editorjs/editorjs/dist/editor.js
       β”‚          Module parse failed: disallowed syntax found in file /home/tosti/Tosti_/kibana_7.8.2/kibana/plugins/myPlugin/node_modules/@editorjs/editorjs/dist/editor.js:
       β”‚            - [es2015] ...spread
       β”‚            - [es2015] let/const variable declaration
       β”‚            - [es2015] arrow function expression
       β”‚            - [es2015] class
       β”‚            - [es2015] destructuring
       β”‚          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
       β”‚          Error: disallowed syntax found in file /home/tosti/Tosti_/kibana_7.8.2/kibana/plugins/myPlugin/node_modules/@editorjs/editorjs/dist/editor.js:
       β”‚            - [es2015] ...spread
       β”‚            - [es2015] let/const variable declaration
       β”‚            - [es2015] arrow function expression
       β”‚            - [es2015] class
       β”‚            - [es2015] destructuring
       β”‚              at parser.hooks.program.tap.program (/home/tosti/Tosti_/kibana_7.8.2/kibana/packages/kbn-optimizer/src/common/disallowed_syntax_plugin/disallowed_syntax_plugin.ts:64:17)
       β”‚              at SyncBailHook.eval (eval at create (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:16)
       β”‚              at Parser.parse (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/webpack/lib/Parser.js:2280:26)
       β”‚              at doBuild.err (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/webpack/lib/NormalModule.js:482:32)
       β”‚              at runLoaders (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/webpack/lib/NormalModule.js:358:12)
       β”‚              at /home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/loader-runner/lib/LoaderRunner.js:373:3
       β”‚              at iterateNormalLoaders (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
       β”‚              at Array.<anonymous> (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
       β”‚              at Storage.finished (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
       β”‚              at provider (/home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9)
       β”‚              at /home/tosti/Tosti_/kibana_7.8.2/kibana/node_modules/graceful-fs/graceful-fs.js:115:16
       β”‚              at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
       β”‚           @ ./node_modules/react-editor-js/dist/react-editor-js.umd.js 2:110-139
       β”‚           @ ./public/components/editor/main.js
       β”‚           @ ./public/components/editor/index.js
       β”‚           @ ./public/containers/editor.js
       β”‚           @ ./public/containers/index.js
       β”‚           @ ./public/components/app.tsx
       β”‚           @ ./public/application.tsx
       β”‚           @ ./public/plugin.ts
       β”‚           @ ./public/index.ts

Hello @AndreaTosti

I think your plugin needs to be built before node scripts/build_kibana_platform_plugins can be run. There are some sample plugins in the kibana repo that might help, including this one - https://github.com/elastic/kibana/tree/master/test/plugin_functional/plugins/management_test_plugin Take a look at the package.json file. As you can see, the typescript compiler is run.

You can also try the plugin generator - node scripts/generate_plugin.js [name]

Hi, first of all thanks for the help, i tried to follow your advice but i was not successful.

I solved the problem using a local version of EditorJS, in particular I had to use Babel to switch to a code written in ES5 (more details here)

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.