-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
How import Codemirror.Next in NextJS #277
Comments
Greetings, I did some experiments when this repository was very young and I did manage to server render CodeMirror with syntax highlighting. Here's the code if it might be useful https://github.com/datavis-tech/codemirror-6-experiments/tree/master/packages/experiments/src/pages/pad Writeup: https://medium.com/@currankelleher/codemirror-6-experiments-a3930bf03781 I'm not sure about the Next-specific details, but this may help. Good luck! |
I think this happens because Next tries to run codemirror in a Node environment, and Node.js's |
Exist one way that one project with I clone my Codemirror in one Yarn Workspace But this error appear
// inlineview.ts
export abstract class InlineView extends ContentView {
...
match(_other: InlineView) { return false } // inlineview.ts line 13
} // contentview.ts
export abstract class ContentView {
...
abstract children: ContentView[] // contentview.ts line 21
...
}
// blockview.ts
export class LineView extends ContentView implements BlockView {
children: InlineView[] = []
...
let elts = source ? source.children : [] // blockview.ts line 37
...
merge(from: number, to: number, source: BlockView | null, takeDeco: boolean): boolean {
...
// Then try to merge any mergeable nodes at the start and end of
// the changed range
while (fromI < toI && elts.length && this.children[toI - 1].match(elts[elts.length - 1])) { // blockview.ts line 82
elts.pop()
toI--
}
...
}
} That is all I collect about this error interface BlockView extends ContentView { // blockview.ts line 11
..
}
class LineView extends ContentView implements BlockView { // blockview.ts line 21
///
} |
This package only exposes ES6 modules, which you can |
But ESM support CommonJS modules, why use ESM output instead of CommonJS output? well i still for the NextJS ESM support |
vercel/next.js#9607 |
I got it working by using the const withTM = require('next-transpile-modules')([
'@codemirror/basic-setup',
'@codemirror/autocomplete',
'@codemirror/closebrackets',
'@codemirror/commands',
'@codemirror/comment',
'@codemirror/fold',
'@codemirror/gutter',
'@codemirror/highlight',
'@codemirror/history',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/matchbrackets',
'@codemirror/panel',
'@codemirror/rangeset',
'@codemirror/rectangular-selection',
'@codemirror/search',
'@codemirror/state',
'@codemirror/text',
'@codemirror/tooltip',
'@codemirror/view',
'@codemirror/lang-json',
]);
module.exports = withTM(); |
Next: https://nextjs.org/
My code
Error
Next internally use Webpack, it only support CommonJS, but the
dist
folder is ES6, exist one example how use Codemirror.Next with NextJS or Webpack?The text was updated successfully, but these errors were encountered: