mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This diff adds a babel plugin for the generated view configs which will inline them in the file instead of needing to check the view configs in (fb only) The way it works is: - babel reads the code - looks for type alias `CodegenNativeComponent` in `*NativeComponet.js` files - run the flow parser on the file source to create a schema - run the schema into codegen to get the view config source code - inject the generated source code back into the NativeComponent.js file - remove the original export - profit After this diff we will remove the `js1 build viewconfigs` command and the checked-in NativeViewConfig.js files Note: since this plugin is not published to open source, for now OSS will continue using the `requireNativeComponent` function Reviewed By: cpojer Differential Revision: D15516062 fbshipit-source-id: a8efb077773e04fd9753a7036682eeaae9175e09
29 lines
699 B
JavaScript
29 lines
699 B
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @emails oncall+react_native
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const FlowParser = require('../index.js');
|
|
const fixtures = require('../__test_fixtures__/fixtures.js');
|
|
jest.mock('fs', () => ({
|
|
readFileSync: filename => fixtures[filename],
|
|
}));
|
|
|
|
describe('RN Codegen Flow Parser', () => {
|
|
Object.keys(fixtures)
|
|
.sort()
|
|
.forEach(fixtureName => {
|
|
it(`can generate fixture ${fixtureName}`, () => {
|
|
expect(FlowParser.parseFile(fixtureName)).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|