ErnstHot / TypeScript-for-Max

TypeScript for Cycling '74 Max
Other
90 stars 12 forks source link

[question] Polyfills and external dependencies #32

Open cha-king opened 1 year ago

cha-king commented 1 year ago

Heyo!

Thanks for putting this repo together. Super useful in getting Typescript up-and-running in Max.

I'm left with a couple of questions that I figure someone might have some experience with:

  1. From code running in the js object, can any code be imported from npm packages? Or does anything imported need to be local?
  2. I saw mention of polyfills in the README to enable functionality beyond ES5, but had some issues getting that working. Does anyone have any pointers or recommendations for doing so?

Thanks!

twhiston commented 1 year ago

Hi!

From code running in the js object, can any code be imported from npm packages? Or does anything imported need to be local?

Yep, local code only in the js object. If you need npm packages you need to use the node object.

I saw mention of polyfills in the README to enable functionality beyond ES5, but had some issues getting that working. Does anyone have any pointers or recommendations for doing so?

Let me know what issues you have and maybe I can help specifically. In the meantime maybe check out how I added them in my REPL project, which should give you some pointers https://github.com/twhiston/tw.gl.repl/tree/dev/javascript/src/extensions The object extension might be the most interesting example as the others are just adding functions to the prototype directly

Thanks