Fixup TypeScript with export maps (#1284)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1284 This makes TypeScript resolution play nicely with export maps, and converts the entrypoints to TypeScript. We remove the non-export-map fallbacks as well, so the export maps are always followed. Tests are moved to load yoga from its external export, testing the entrypoints. This moves the only untyped bit to the binary wrapper, which another diff will move. Reviewed By: yungsters Differential Revision: D45713689 fbshipit-source-id: 228e6f2c9d53520230707a81e76c3c35fcd46de5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
104646d8ca
commit
af89315fd4
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const wrapAsm = require('../wrapAsm');
|
||||
|
||||
module.exports = loadAsm => ({
|
||||
loadYoga: () => loadAsm().then(wrapAsm),
|
||||
...require('../generated/YGEnums'),
|
||||
});
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const wrapAsm = require('../wrapAsm');
|
||||
module.exports = asm => wrapAsm(asm());
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const asm = require('../build/asmjs-async');
|
||||
module.exports = require('./_entryAsync')(asm);
|
26
javascript/src/entrypoint/asmjs-async.ts
Normal file
26
javascript/src/entrypoint/asmjs-async.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import wrapAssembly from '../wrapAssembly';
|
||||
import type {Yoga} from '../wrapAssembly';
|
||||
|
||||
export * from '../generated/YGEnums';
|
||||
export type {
|
||||
Config,
|
||||
DirtiedFunction,
|
||||
MeasureFunction,
|
||||
Node,
|
||||
Yoga,
|
||||
} from '../wrapAssembly';
|
||||
|
||||
const loadAssembly = require('../../binaries/asmjs-async');
|
||||
|
||||
export async function loadYoga(): Promise<Yoga> {
|
||||
return wrapAssembly(await loadAssembly());
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const asm = require('../build/asmjs-sync');
|
||||
module.exports = require('./_entrySync')(asm);
|
23
javascript/src/entrypoint/asmjs-sync.ts
Normal file
23
javascript/src/entrypoint/asmjs-sync.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import wrapAssembly from '../wrapAssembly';
|
||||
|
||||
export * from '../generated/YGEnums';
|
||||
export type {
|
||||
Config,
|
||||
DirtiedFunction,
|
||||
MeasureFunction,
|
||||
Node,
|
||||
Yoga,
|
||||
} from '../wrapAssembly';
|
||||
|
||||
const loadAssembly = require('../../binaries/asmjs-sync');
|
||||
const Yoga = wrapAssembly(loadAssembly());
|
||||
export default Yoga;
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const asm = require('../build/wasm-async');
|
||||
module.exports = require('./_entryAsync')(asm);
|
26
javascript/src/entrypoint/wasm-async.ts
Normal file
26
javascript/src/entrypoint/wasm-async.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import wrapAssembly from '../wrapAssembly';
|
||||
import type {Yoga} from '../wrapAssembly';
|
||||
|
||||
export * from '../generated/YGEnums';
|
||||
export type {
|
||||
Config,
|
||||
DirtiedFunction,
|
||||
MeasureFunction,
|
||||
Node,
|
||||
Yoga,
|
||||
} from '../wrapAssembly';
|
||||
|
||||
const loadAssembly = require('../../binaries/wasm-async');
|
||||
|
||||
export async function loadYoga(): Promise<Yoga> {
|
||||
return wrapAssembly(await loadAssembly());
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const asm = require('../build/wasm-sync');
|
||||
module.exports = require('./_entrySync')(asm);
|
23
javascript/src/entrypoint/wasm-sync.ts
Normal file
23
javascript/src/entrypoint/wasm-sync.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import wrapAssembly from '../wrapAssembly';
|
||||
|
||||
export * from '../generated/YGEnums';
|
||||
export type {
|
||||
Config,
|
||||
DirtiedFunction,
|
||||
MeasureFunction,
|
||||
Node,
|
||||
Yoga,
|
||||
} from '../wrapAssembly';
|
||||
|
||||
const loadAssembly = require('../../binaries/wasm-sync');
|
||||
const Yoga = wrapAssembly(loadAssembly());
|
||||
export default Yoga;
|
15
javascript/src/index.d.ts
vendored
15
javascript/src/index.d.ts
vendored
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
export function loadYoga(): Promise<Yoga>;
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require('./entrypoint/asmjs-async');
|
16
javascript/src/sync.d.ts
vendored
16
javascript/src/sync.d.ts
vendored
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
declare const yoga: Yoga;
|
||||
export default yoga;
|
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require('./entrypoint/asmjs-sync');
|
@@ -187,5 +187,5 @@ export type Yoga = {
|
||||
};
|
||||
} & typeof YGEnums;
|
||||
|
||||
declare const wrapAsm: () => Yoga;
|
||||
declare const wrapAsm: (assembly: unknown) => Yoga;
|
||||
export default wrapAsm;
|
Reference in New Issue
Block a user