Add babel processing to browser build to remove references to node builtins

Summary:
Currently the nbind asm.js output generates boilerplate code which can conditionally load node's `fs` and `path` modules. If this output is run directly in the browser there are no issues but if you run it through a bundler the build step will fail trying to resolve the node builtins.

Workarounds currently exist for bundlers like webpack (mentioned in #444) but this is not a safe assumption to make (for example such workarounds don't exist for `metro-bundler`).

I am by no means suggesting that this is the perfect solution but this might provide a stop-gap fix for people who are currently blocked by this issue (like I am).
Closes https://github.com/facebook/yoga/pull/585

Differential Revision: D5388660

Pulled By: emilsjolander

fbshipit-source-id: d3a51eb852df35e3d0610158fe7d9f5754e4e684
This commit is contained in:
vincentriemer
2017-07-10 11:52:23 -07:00
committed by Facebook Github Bot
parent 7640cd667f
commit 7c688cea68
3 changed files with 345 additions and 24 deletions

11
javascript/.babelrc Normal file
View File

@@ -0,0 +1,11 @@
{
"plugins": [
[
"replace-require",
{
"fs": "{}",
"path": "{}"
}
]
]
}