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:
committed by
Facebook Github Bot
parent
7640cd667f
commit
7c688cea68
@@ -4,8 +4,8 @@
|
||||
"description": "Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API many designers are familiar with, and opening it up to developers across different platforms.",
|
||||
"license": "BSD-3-Clause",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:facebook/yoga.git"
|
||||
"type": "git",
|
||||
"url": "git@github.com:facebook/yoga.git"
|
||||
},
|
||||
|
||||
"main": "./sources/entry-node",
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
"build:node": "npm -- run copy-sources && npm -- run node-gyp configure build",
|
||||
"build:browser": "npm -- run copy-sources && npm -- run node-gyp configure build --asmjs=1",
|
||||
"postbuild:browser": "babel build/Release/nbind.js --out-file build/Release/nbind.js",
|
||||
"build:standalone": "webpack",
|
||||
"build:all": "npm -- run build:node && npm -- run build:browser && npm -- run build:standalone",
|
||||
"build": "cross-env \"npm --if-present -- run build:$npm_package_config_platform\"",
|
||||
@@ -54,6 +55,9 @@
|
||||
|
||||
"devDependencies": {
|
||||
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-core": "^6.25.0",
|
||||
"babel-plugin-replace-require": "^0.0.4",
|
||||
"cross-env": "^4.0.0",
|
||||
"mocha": "^3.2.0",
|
||||
"webpack": "^2.2.0-rc.2"
|
||||
|
Reference in New Issue
Block a user