-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
Vanilla node fails to import #69
Comments
Did you install it? $ node
Welcome to Node.js v13.12.0.
Type ".help" for more information.
> require('svgdom')
{
defaults: Object [Module] {
fontSize: [Getter],
fontFamily: [Getter],
fontDir: [Getter],
fontFamilyMappings: [Getter]
},
Attr: [Function: Attr],
CharacterData: [Function: CharacterData],
Comment: [Function: Comment],
CustomEvent: [Function: CustomEvent],
DOMImplementation: {
hasFeature: [Function: hasFeature],
createDocumentType: [Function: createDocumentType],
createDocument: [Function: createDocument],
createHTMLDocument: [Function: createHTMLDocument]
},
Document: [Function: Document],
DocumentFragment: [Function: DocumentFragment],
Element: [Function: Element],
Event: [Function: Event],
EventTarget: [Function: EventTarget],
Node: [Function: Node] {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
},
NodeFilter: [Function: NodeFilter] {
FILTER_ACCEPT: 1,
FILTER_REJECT: 2,
FILTER_IGNORE: 4,
SHOW_ALL: -1,
SHOW_ELEMENT: 1,
SHOW_TEXT: 4,
SHOW_ENTITY_REFERENCE: 16,
SHOW_ENTITY: 32,
SHOW_PROCESSING_INSTRUCTION: 64,
SHOW_COMMENT: 128,
SHOW_DOCUMENT: 256,
SHOW_DOCUMENT_TYPE: 512,
SHOW_DOCUMENT_FRAGMENT: 1024,
SHOW_NOTATION: 2048
},
Text: [Function: Text],
Window: [Function: Window],
HTMLElement: [Function: HTMLElement],
HTMLImageElement: [Function: HTMLImageElement],
HTMLLinkElement: [Function: HTMLLinkElement],
HTMLParser: [Function: HTMLParser],
HTMLScriptElement: [Function: HTMLScriptElement],
elementAccess: {
getElementsByTagName: [Function: getElementsByTagName],
getElementsByTagNameNS: [Function: getElementsByTagNameNS],
getElementsByClassName: [Function: getElementsByClassName]
},
ParentNode: {
matchWithScope: [Function: matchWithScope],
query: [Function: query],
querySelectorAll: [Function: querySelectorAll],
querySelector: [Function: querySelector],
prepend: [Function: prepend],
append: [Function: append],
replaceChildren: [Function: replaceChildren]
},
SVGElement: [Function: SVGElement],
SVGGraphicsElement: [Function: SVGGraphicsElement],
matrixFactory: [Function: matrixFactory],
SVGMatrix: [Function: SVGMatrix],
SVGPathElement: [Function: SVGPathElement],
SVGPoint: [Function: SVGPoint],
SVGSVGElement: [Function: SVGSVGElement],
SVGTextContentElement: [Function: SVGTextContentElement],
setFontDir: [Function: setFontDir],
setFontFamilyMappings: [Function: setFontFamilyMappings],
preloadFonts: [Function: preloadFonts],
getConfig: [Function: getConfig],
getFonts: [Function: getFonts],
config: {
setFontDir: [Function: setFontDir],
setFontFamilyMappings: [Function: setFontFamilyMappings],
preloadFonts: [Function: preloadFonts],
getConfig: [Function: getConfig],
getFonts: [Function: getFonts]
},
createDocument: [Function: createDocument],
createHTMLDocument: [Function: createHTMLDocument],
createSVGDocument: [Function: createSVGDocument],
createWindow: [Function: createWindow],
createHTMLWindow: [Function: createHTMLWindow],
createSVGWindow: [Function: createSVGWindow]
} |
Sorry for the stressed issue report, require('./node_modules/svgdom/main-require.js') I suspect that there's a misconfiguration in |
Yes it will be quite sure the node version. However, all the stuff is backwards compatible. The |
Yeah i agree that it "should", the exports look syntactically correct comparing to the docs: But then again backwards-compatiblity "should" include the version i'm running as well - honestly I'm a bit intrigued by this issue, it shouldn't exist. |
Its strange. If you have a look at #60 you can see that the code seems to work with node 12 or even node 8. Maybe it is a bug specific to your version? Or something different is going on. |
(node: v13.2.0) When I use :
I get:
|
Same. I use typescript and while it compiles it gets an error: |
I am using svg.js with typescript right now and have no problems whatsoever. If window is not defined in your typescript you might want to run typescript with the dom lib enabled? |
as far as I can tell, svgdom does not include typescript type definitions? |
I obviously mixed up the repositories there... No, svgdom has no typescript definitions but you could just use the dom lib which typescripts provide. Its a dom after all ^^ |
the issue for me is the // @ts-ignore, https://github.com/svgdotjs/svgdom/issues/69
import {createSVGWindow} from "svgdom";
const window = createSVGWindow(); |
The text was updated successfully, but these errors were encountered: