forked from facebook/yoga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate JavaScript Flavors (facebook#1433)
Summary: Fixes facebook#1417 This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers. This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution. As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS). Pull Request resolved: facebook#1433 Test Plan: 1. `yarn test` 2. `yarn lint` 3. `yarn tsc` 4. `yarn benchmark` 5. `yarn build` website-next 6. `yarn lint` website-next 7. Locally test website-next 8. Examine package artifact created by GitHub 9. All Automation passes Reviewed By: yungsters Differential Revision: D50453324 Pulled By: NickGerleman fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
- Loading branch information
1 parent
b19a07c
commit ef1d772
Showing
68 changed files
with
853 additions
and
2,394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
module.exports = { | ||
root: true, | ||
ignorePatterns: [ | ||
'/website', | ||
'**/binaries/**', | ||
'**/build/**', | ||
'**/generated/**', | ||
], | ||
overrides: [ | ||
// Catch-all | ||
{ | ||
files: ['**/*.?(m|c){j,t}s?(x)'], | ||
extends: ['eslint:recommended', 'plugin:prettier/recommended'], | ||
plugins: ['prettier'], | ||
rules: { | ||
'no-unused-vars': ['error', {argsIgnorePattern: '^_'}], | ||
'no-var': 'error', | ||
'prefer-arrow-callback': 'error', | ||
'prefer-const': 'error', | ||
'prefer-object-spread': 'error', | ||
'prefer-spread': 'error', | ||
'require-await': 'error', | ||
}, | ||
env: { | ||
es2020: true, | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
}, | ||
}, | ||
// ES Modules | ||
{ | ||
files: ['**/*.?(m){j,t}s?(x)'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
}, | ||
}, | ||
// CommonJS Modules | ||
{ | ||
files: ['**/*.c{j,t}s?(x)'], | ||
env: { | ||
commonjs: true, | ||
}, | ||
parserOptions: { | ||
sourceType: 'commonjs', | ||
}, | ||
}, | ||
// TypeScript | ||
{ | ||
files: ['**/*.?(m|c)ts?(x)'], | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: true, | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{argsIgnorePattern: '^_'}, | ||
], | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}, | ||
// Node | ||
{ | ||
files: ['**/.*rc.(c){j,t}s', '**/*.config.?(c){j,t}s'], | ||
env: { | ||
node: true, | ||
}, | ||
}, | ||
// Jest | ||
{ | ||
files: ['**/tests/**'], | ||
extends: ['plugin:jest/recommended'], | ||
}, | ||
], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
module.exports = api => ({ | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: [ | ||
'maintained node versions', | ||
'> 0.5%, last 2 versions, Firefox ESR, not dead', | ||
], | ||
// Do not transform to another module system | ||
modules: false, | ||
}, | ||
], | ||
[ | ||
'@babel/preset-typescript', | ||
{ | ||
rewriteImportExtensions: api.env('dist'), | ||
}, | ||
], | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.