-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yoga npm package version 2.0.0-beta.1 doesn't work with Webpack #1321
Comments
This is because Emscripten will output “fs” usage in a conditional when told to compile for both Node and web. I thought I had fixed that with another change, but looking at the binary we published, the issue is still there. A proper fix should come soon, but in the meantime, I think adding the following to your Webpack config might work for Webpack 5:
I think earlier versions of Webpack may polyfill these by default. |
Thanks Nick! That works great and looking forward to the fix! |
Summary: Fixes facebook#1321 Differential Revision: D47368830 fbshipit-source-id: 4a77224e3dc89c06ace3628d48c0235a3932fcfe
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: D47368830 fbshipit-source-id: 766dec6fbbf356931ecd2e044dad51b8026754e8
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: D47368830 fbshipit-source-id: f2c97198977033db4fee0fb81539276161d22607
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: D47368830 fbshipit-source-id: e253ff686bd76863a89dcd331fb86394878a1bd9
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: D47368830 fbshipit-source-id: ef75d4989245b3df8f9aefb3b313bda3949827d2
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Reviewed By: cortinico Differential Revision: D47368830 fbshipit-source-id: 4128366d749ae679b54bd15bec4c398dc08e7663
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: 889c904c062567f4166a735165bbb33e72180b61
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: dd6b9e1dc8e6b0dfe7f840f9c9d97571f6b7f8d9
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: b8d5f80eb624895c418d252a3a17a8c6c0751770
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: 9fec5c8d7a5de3ec2131ec66ce8d8bd39713b745
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Reviewed By: cortinico Differential Revision: D47368830 fbshipit-source-id: 782e7b6a0ba1f461670020b6e93883c39ad49245
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: 6ef4b6c2bb32da41cf6e8fa2732a3169c6f88026
Summary: Pull Request resolved: facebook#1325 Fixes facebook#1321 Differential Revision: https://internalfb.com/D47368830 fbshipit-source-id: 2305060e225bed8e8246772334caa580c8b03f8b
Fix has been published in |
@NickGerleman Could not find com.facebook.yoga.android:yoga-layout:2.0.0-beta.1 Could not find com.facebook.yoga.android:yoga-layout:2.0.0-beta.2 |
This issue is for the |
Report
The new yoga-layout npm package version 2.0.0-beta.1 does not work with Webpack because the compilation environment is recognized as a Node environment, and requiring Node-only modules like 'fs' and 'path' causes Webpack errors.
Issues and Steps to Reproduce
Any Webpack environment can be used, but here is an easy way to reproduce:
Create a fresh project using create-react-app:
npx create-react-app yoga-test
and then add yoga-layoutnpm install --save yoga-layout
.Simply add an import statement to a file, such as App.js:
import { loadYoga } from "yoga-layout";
and invoke loadYoga:loadYoga()
.Start the app:
npm run start
You should see a compilation error along the lines of:
Module not found: Error: Can't resolve 'fs' in '/path_to_project/node_modules/yoga-layout/binaries'
.Attempts to fix
I can fix the issue in a hacky way by simply deleting the 'if' statement that contains the require statements in
node_modules/yoga_layout/binaries/wasm-async.js
. The Yoga system does seem to work correctly when I do this, but I have not tested in-depth.I also attempted to use the
node-polyfill-webpack-plugin
, but this seems to have no effect and would probably not be a good solution anyway.What is the correct way to solve this issue?
The text was updated successfully, but these errors were encountered: