Skip to content

Commit d17ce35

Browse files
authored
fix: js-only libraries have codegen config (#758)
### Summary Fixes #754 JS-only libraries were setting the new architecture flag on. While this is not a preferable mental modal, we had some code associated with codegen that checked this flag. With this PR, JS-only libraries will set this flag to false. This is not an optimal solution but we will fully drop this flag with the deprecation of the legacy arch in the upcoming months. ### Test plan 1. Generate a JavaScript-only library 1. Make sure the `codegen` target isn't added to bob targets in `package.json` 1. Make sure there is no `codegenConfig` in `package.json` 1. Make sure `yarn prepare` works.
1 parent c1b508a commit d17ce35

File tree

2 files changed

+12
-3
lines changed
  • packages/create-react-native-library

2 files changed

+12
-3
lines changed

packages/create-react-native-library/src/template.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export function generateTemplateConfiguration({
104104
const { slug, languages, type } = answers;
105105

106106
const arch =
107-
type === 'legacy-module' || type === 'legacy-view' ? 'legacy' : 'new';
107+
type === 'legacy-module' || type === 'legacy-view' || type === 'library'
108+
? 'legacy'
109+
: 'new';
108110

109111
const project = slug.replace(/^(react-native-|@[^/]+\/)/, '');
110112
let namespace: string | undefined;

packages/create-react-native-library/templates/example-module-legacy/example/src/App.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { useState, useEffect } from 'react';
2-
import { Text, View, StyleSheet } from 'react-native';
31
import { multiply } from '<%- project.slug -%>';
2+
import { Text, View, StyleSheet } from 'react-native';
3+
<% if (project.native) { -%>
4+
import { useState, useEffect } from 'react';
45

56
export default function App() {
67
const [result, setResult] = useState<number | undefined>();
@@ -9,6 +10,12 @@ export default function App() {
910
multiply(3, 7).then(setResult);
1011
}, []);
1112

13+
<% } else { -%>
14+
15+
const result = multiply(3, 7);
16+
17+
export default function App() {
18+
<% } -%>
1219
return (
1320
<View style={styles.container}>
1421
<Text>Result: {result}</Text>

0 commit comments

Comments
 (0)