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

server render with typescript #281

Open
dcsan opened this issue Nov 19, 2023 · 0 comments
Open

server render with typescript #281

dcsan opened this issue Nov 19, 2023 · 0 comments

Comments

@dcsan
Copy link

dcsan commented Nov 19, 2023

你好👋!

I'm trying to use this with nodeJS and node-canvas and typescript

import pkg from "spritejs"
const { Scene, Sprite, ENV } = pkg

how do i access or use the polyfill?

const { polyfill } = require("../lib/platform/node-canvas")

I got as far as :

import pkg from "spritejs"
const { Scene, Sprite, ENV } = pkg

import { polyfill } from "./node-canvas-fill.js"

then in the node-canvas-fill.js I modified the import:

import pkg from "node-canvas-webgl"
const { nodeCanvasWebgl: _nodeCanvasWebgl } = pkg

but still getting these type of errors:

file:///Users/dc/dev/hacks/kbxt/server/src/services/node-canvas-fill.ts:70
  ENV.createCanvas = _nodeCanvasWebgl.createCanvas
                                      ^
TypeError: Cannot read properties of undefined (reading 'createCanvas')

Is there an example using the library with typescript style imports that will work?
even just for a plain 2D node-canvas, without the webGL effects?

Thanks!

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

1 participant