1

I'm trying to deploy functions created with bucklescript to google functions but the deploy won't run without this error :

Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module 'bs-platform/lib/js/js_json.js'

I'm using the gcloud beta functions deploy utility. My code is using the Js.Json module, which produce var Js_json = require("bs-platform/lib/js/js_json.js"); in the outputed js code. My package.json contains the bs-platform package.

Is there a way to setup bucklescript or the gcloud utility to make my code acceptable?

glennsl
  • 28,186
  • 12
  • 57
  • 75
Parasithe
  • 25
  • 5
  • I'm not familiar with `gcloud`, but you might have to use a bundler like webpack or rollup to bundle it up into a single file. The `require` call is standard commonjs, nothing bucklescript-specific. – glennsl Oct 15 '17 at 18:24
  • You can also configure `bsb` to emit es6 or amdjs instead of commonjs modules, if that works better. – glennsl Oct 15 '17 at 18:27
  • @glennsl in the end I used rollup to bundle deps and it did the trick. If you wish you can give an answer and I'll be able to approve it. – Parasithe Oct 18 '17 at 23:04
  • Done. Thanks for coming back to confirm that it worked. – glennsl Oct 19 '17 at 00:29

1 Answers1

1

BuckleScript's requires are just standard CommonJS requires, and can be bundled up into a single file using a bundler like webpack. You can also configure bsb to emit es6 modules (see the package-specs property of the bsconfig.json schema) and bundle them up using rollup.

glennsl
  • 28,186
  • 12
  • 57
  • 75