fix(expo): fix the buildable library (#14142)

This commit is contained in:
Emily Xiong 2023-01-09 11:37:38 -05:00 committed by GitHub
parent 02d1cc85ca
commit 74d8a4830e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import {
checkFilesExist,
cleanupProject,
expectTestsPass,
newProject,
@ -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();
});
});

View File

@ -1,3 +1,17 @@
{
"presets": [
[
"@nrwl/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": [],
"env": {
"test": {
"presets": ["babel-preset-expo"]
}
}
}

View File

@ -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',

View File

@ -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',