Closed wagpa closed 2 years ago
Updated to Nuxt Version 3.0.0-rc.13
but problem is still there
I tested some stuff. Maybe someone with more knowledge about JS and Node (v18.12.0) has an idea. For some reason, the DocumentClone
works as intended, while Document
is missing its functions.
Is JS dropping information about Document
when imported?
import Document from '@tiptap/extension-document';
import {Node} from "@tiptap/core";
console.log('[debug] node definition', Node.prototype, Node.prototype.configure)
console.log('[debug] document type', typeof Document, Document instanceof Node)
let testNode = Node.create({ name: 'test' })
let testNode2 = new Node({ name: 'test' })
let DocumentClone = Node.create({
name: 'doc',
topNode: true,
content: 'block+',
});
console.log('[debug] test node type', typeof testNode, testNode instanceof Node, testNode.extend)
console.log('[debug] test node 2 type', typeof testNode2, testNode2 instanceof Node, testNode2.extend)
console.log('[debug] document definition', Object.getPrototypeOf(Document), Object.getPrototypeOf(Document).configure, Document.extend)
console.log('[debug] document clone definition', Object.getPrototypeOf(DocumentClone), Object.getPrototypeOf(DocumentClone).configure, DocumentClone.extend)
with @tiptap/extension-document
defining
import { Node } from '@tiptap/core'
export const Document = Node.create({
name: 'doc',
topNode: true,
content: 'block+',
})
with
class Node {
...
static create(config = {}) {
return new Node(config);
}
}
Prints
[debug] node definition {} [Function: configure]
[debug] document type object false
[debug] test node type object true [Function: extend]
[debug] test node 2 type object true [Function: extend]
[debug] document definition [Object: null prototype] {} undefined undefined
[debug] document clone definition {} [Function: configure] [Function: extend]
I finally got it working.
After changing the import to
// not working with 'npm run build': import Document from '@tiptap/extension-document';
import { Document } from '@tiptap/extension-document';
// should also work: import * as ExtensionDocument from '@tiptap/extension-document'; const Document = ExtensionDocument.Document;
the imported object has all the class methods as expected.
As this doesn't seem to be a direct problem with nuxt, im closing this issue. But i hopes it helps someone, if they encounter a similar problem.
Environment
Windows_NT
v19.0.0
3.0.0-rc.12
0.6.0
npm@8.19.3
vite
preset
,build
,vite
,css
,purgeCSS
,typescript
,modules
,runtimeConfig
,tailwindcss
,components
@nuxtjs/tailwindcss@6.0.1
,@pinia/nuxt@0.4.3
-
Additional Packages that might be helpful to know
Reproduction
in a component setup script
Describe the bug
When calling
Document.configure(...)
on server, it throws the error[nuxt] [request error] [unhandled] [500] Document.configure is not a function
. On the client this works. When i try to output all functions of the Document (see above), i get the following outputs:In server console
In browser console (cropped)
As you can see, the expected class functions
configure
andextend
are missing in the server console printout. Calling the functions on the server gives the described error message.Additional context
I'm not sure, if this is a
nuxt 3
,vue 3
ortiptap 2
error. But as thetiptap 2
class definition seems to be pretty simple, i don't think, this is atiptap 2
issue.To complicate things, when i run the same code with
npm run dev
, it works as expected. Running it withnpm run build
and thennode .\.output\server\index.mjs
gives the error.I'm happy for any lead to the cause and will provide further information if needs be.
Logs