# How to package Javascript stubs / support code

**URL:** https://discuss.ocaml.org/t/how-to-package-javascript-stubs-support-code/9111
**Category:** Ecosystem
**Tags:** opam, dune, js\_of\_ocaml
**Created:** [January 6, 2022, 3:13am UTC](https://discuss.ocaml.org/t/how-to-package-javascript-stubs-support-code/9111 "2022-01-06T03:13:15Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![joelb](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/joelb/32/1996_2.png) [@joelb](https://discuss.ocaml.org/u/joelb)
#### Post date: [January 6, 2022, 5:09pm UTC](https://discuss.ocaml.org/t/how-to-package-javascript-stubs-support-code/9111/3 "2022-01-06T17:09:36Z")

</div>

Thank you @patricoferris, your answer is very helpful.

> Using a `.js` file with the `joo_global_object` approach like you pointed out

I want to make sure I understand the approach you’re taking here. JSOO outputs `index.bc.js`, which includes `require("@codemirror/view")`, `require("@codemirror/state")`, etc. You then rely on Parcel (or Webpack, etc) to link the JS. Does that sound right?

This approach sounds very appealing since it’s simple on the OCaml side. It made your Codemirror bindings possible (which I [could never figure out how to do](https://discuss.ocaml.org/t/js-of-ocaml-and-javascript-modules/7446)). More generally, it solves the problem of working with JS modules from OCaml. I see two downsides:

1. It’s an extra step for users
2. Makes it possible to link an incompatible version of the JS library (as you noted)

By the way, I noticed @jchavarri debating some of the same questions: [Should jsoo-react vendor react.js? · Issue #104 · ml-in-barcelona/jsoo-react · GitHub](https://github.com/ml-in-barcelona/jsoo-react/issues/104).

---

_[View the full topic](https://discuss.ocaml.org/t/how-to-package-javascript-stubs-support-code/9111)._
