Skip to content

Commit

Permalink
fix(expo): fix the buildable library
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi authored and AgentEnder committed Jan 9, 2023
1 parent 02d1cc8 commit 157ffed
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
18 changes: 18 additions & 0 deletions e2e/expo/src/expo.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
checkFilesExist,
cleanupProject,
expectTestsPass,
newProject,
Expand Down Expand Up @@ -47,4 +48,21 @@ describe('expo', () => {
'Export was successful. Your exported files can be found'
);
}, 1000000);

it('should build publishable library', async () => {
const libName = uniq('lib');
const componentName = uniq('component');

runCLI(
`generate @nrwl/expo:library ${libName} --buildable --publishable --importPath=${proj}/${libName}`
);
runCLI(
`generate @nrwl/expo:component ${componentName} --project=${libName} --export`
);
expect(() => {
runCLI(`build ${libName}`);
checkFilesExist(`dist/libs/${libName}/index.js`);
checkFilesExist(`dist/libs/${libName}/src/index.d.ts`);
}).not.toThrow();
});
});
16 changes: 15 additions & 1 deletion packages/expo/src/generators/library/files/lib/babel.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
{
"presets": ["babel-preset-expo"]
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": [],
"env": {
"test": {
"presets": ["babel-preset-expo"]
}
}
}
2 changes: 1 addition & 1 deletion packages/expo/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('lib', () => {
executor: '@nrwl/web:rollup',
outputs: ['{options.outputPath}'],
options: {
external: ['react/jsx-runtime'],
external: ['react/jsx-runtime', 'react-native'],
entryFile: 'libs/my-lib/src/index.ts',
outputPath: 'dist/libs/my-lib',
project: 'libs/my-lib/package.json',
Expand Down
2 changes: 1 addition & 1 deletion packages/expo/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function addProject(host: Tree, options: NormalizedSchema) {

if (options.publishable || options.buildable) {
const { libsDir } = getWorkspaceLayout(host);
const external = ['react/jsx-runtime'];
const external = ['react/jsx-runtime', 'react-native'];

targets.build = {
executor: '@nrwl/web:rollup',
Expand Down

0 comments on commit 157ffed

Please sign in to comment.