Update package.json and Vite config for @lezer/common compatibility
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
- Changed the version of @lezer/common in package.json to a fixed version (1.5.0) for consistency. - Updated Vite config to resolve @lezer/common directly from node_modules, ensuring compatibility with CodeMirror parsers and preventing issues with version mismatches. - Enhanced the fcTemplateLang parser to support XML overlay across Text regions, improving EJS template handling.
This commit is contained in:
parent
0b210f50cd
commit
24959ce9d8
@ -75,7 +75,7 @@
|
||||
"three": "^0.179.1",
|
||||
"tsparticles": "^3.9.1",
|
||||
"web-vitals": "^5.1.0",
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/common": "1.5.0",
|
||||
"@lezer/highlight": "^1.2.3",
|
||||
"@lezer/lr": "^1.4.8"
|
||||
},
|
||||
|
||||
@ -35,11 +35,17 @@ const fcTemplateParser = ejsParser.configure({
|
||||
})
|
||||
],
|
||||
wrap: parseMixed((node) => {
|
||||
// Mount JS inside EJS bodies
|
||||
if (node.name === 'JavascriptExpression') {
|
||||
return { parser: javascriptLanguage.parser }
|
||||
}
|
||||
if (node.name === 'Text') {
|
||||
return { parser: xmlLanguage.parser }
|
||||
// Overlay XML across all Text regions so tags that wrap EJS
|
||||
// (e.g. <Text><%= x %></Text>) stay one coherent XML tree.
|
||||
if (node.type.isTop) {
|
||||
return {
|
||||
parser: xmlLanguage.parser,
|
||||
overlay: (n) => n.name === 'Text'
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
@ -35,7 +35,9 @@ const codemirrorSingletons = {
|
||||
'@codemirror/language': esmEntry('@codemirror/language'),
|
||||
'@codemirror/commands': esmEntry('@codemirror/commands'),
|
||||
'@codemirror/autocomplete': esmEntry('@codemirror/autocomplete'),
|
||||
'@lezer/common': esmEntry('@lezer/common'),
|
||||
// Must match the @lezer/common used by @codemirror/lang-* parsers (1.5.0).
|
||||
// 1.5.2 breaks parseMixed tree walking across nested language mounts.
|
||||
'@lezer/common': path.resolve(__dirname, 'node_modules/@lezer/common/dist/index.js'),
|
||||
'@lezer/lr': esmEntry('@lezer/lr'),
|
||||
'@lezer/highlight': esmEntry('@lezer/highlight')
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user