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

Uncaught ReferenceError: Cannot access 'languageDefinitions' before initialization #98

Closed
roamer123 opened this issue Jan 24, 2024 · 2 comments

Comments

@roamer123
Copy link

Version
"monaco-editor": "0.31.0",
"monaco-sql-languages": "0.12.0-beta.10",

The Type of SQL
SparkSQL | FlinkSQL | HiveSQL | Impala

Your Code
chainWebpack: (config) => {
config.plugin('definePlugin').use(new webpack.DefinePlugin({
'process.env.NODE_DEBUG': process.env.NODE_DEBUG,
}))
config.plugin('monaco').use(new MonacoEditorWebpckPlugin({
features: [], // 包含你所需要的 Monaco Editor 功能
languages: [], // 包含你所需要的 Monaco Editor 内置语言功能
customLanguages: [
// 包含 Monaco SQL Languages 所提供的语言功能
{
label: 'mysql',
entry: 'monaco-sql-languages/out/esm/mysql/mysql.contribution',
worker: {
id: 'monaco-sql-languages/out/esm/mysql/mySQLWorker',
entry: 'monaco-sql-languages/out/esm/mysql/mysql.worker'
}
},
{
label: 'flinksql',
entry: 'monaco-sql-languages/out/esm/flinksql/flinksql.contribution',
worker: {
id: 'monaco-sql-languages/out/esm/flinksql/flinkSQLWorker',
entry: 'monaco-sql-languages/out/esm/flinksql/flinksql.worker'
}
},
{
label: 'sparksql',
entry: 'monaco-sql-languages/out/esm/sparksql/sparksql.contribution',
worker: {
id: 'monaco-sql-languages/out/esm/sparksql/sparkSQLWorker',
entry: 'monaco-sql-languages/out/esm/sparksql/sparksql.worker'
}
},
{
label: 'hivesql',
entry: 'monaco-sql-languages/out/esm/hivesql/hivesql.contribution',
worker: {
id: 'monaco-sql-languages/out/esm/hivesql/hiveSQLWorker',
entry: 'monaco-sql-languages/out/esm/hivesql/hivesql.worker'
}
}
]
}));

// create
setupLanguageFeatures({
languageId: LanguageIdEnum.FLINK,
// completionService,
});
monaco.editor.create(editorRef.current as HTMLDivElement, {
value: 'SELECT * FROM tb_test',
theme: 'sql-dark',
language: LanguageIdEnum.FLINK,
});

Problem
Uncaught ReferenceError: Cannot access 'languageDefinitions' before initialization

@liuxy0551
Copy link
Collaborator

你好,这个问题你已经解决了吗

@liuxy0551 liuxy0551 reopened this Apr 8, 2024
@liuxy0551
Copy link
Collaborator

问题

  定位发现错误出现在 monaco-sql-languages/esm/_.contribution.jsregisterLanguage 方法,实际为未及时完成 monaco-ediotr 的加载。

解决方法

  在项目入口文件处引入:

import 'monaco-editor/esm/vs/editor/editor.api';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants