es6 compatable enums #1229

Closed
jeetiss wants to merge 2 commits from es6-enums into main
jeetiss commented 2023-02-20 01:31:44 -08:00 (Migrated from github.com)

I wanna repeat the constants export in yoga-wasm-web, to achieve

import { ALIGN_CENTER } from "yoga-layout";

And I failed. it is impossible because rollup and other tools can't transform commonjs module.exports = { WHATEVER: 1 } into ECMAScript modules. however, they can work with separate exports like exports.WHATEVER = 1 and this PR transforms yoga constants into this convertible format

This doesn't change anything for the yoga package, but it makes it possible to reexport constants without any modification and hacks, like this

export * from "./javascript/src_js/generated/YGEnums.js";

discussion in yoga-layout-wasm

I wanna repeat the constants export in `yoga-wasm-web`, to achieve ```js import { ALIGN_CENTER } from "yoga-layout"; ``` And I failed. it is impossible because `rollup` and other tools can't transform commonjs `module.exports = { WHATEVER: 1 }` into ECMAScript modules. however, they can work with separate exports like `exports.WHATEVER = 1` and this PR transforms yoga constants into this convertible format This doesn't change anything for the yoga package, but it makes it possible to reexport constants without any modification and hacks, like this ```js export * from "./javascript/src_js/generated/YGEnums.js"; ``` [discussion in yoga-layout-wasm](https://github.com/shuding/yoga-wasm-web/pull/15)
facebook-github-bot commented 2023-02-20 05:23:16 -08:00 (Migrated from github.com)

@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@rshest has imported this pull request. If you are a Meta employee, you can view this diff [on Phabricator](https://www.internalfb.com/diff/D43437177).
rshest (Migrated from github.com) approved these changes 2023-02-20 05:23:56 -08:00
facebook-github-bot commented 2023-02-20 19:57:29 -08:00 (Migrated from github.com)

@rshest merged this pull request in facebook/yoga@13eacf8858.

@rshest merged this pull request in facebook/yoga@13eacf88588694eca86647a8e55389f416396d89.

Pull request closed

Sign in to join this conversation.
No description provided.