Skip to content

Commit 7e38824

Browse files
authored
fix(react): add files entry for publishable libraries (#29277)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent d2564c6 commit 7e38824

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

packages/react/src/generators/library/library.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,5 +1188,43 @@ module.exports = withNx(
11881188
"
11891189
`);
11901190
});
1191+
1192+
it('should configure files for publishable library', async () => {
1193+
await libraryGenerator(tree, {
1194+
...defaultSchema,
1195+
bundler: 'rollup',
1196+
publishable: true,
1197+
importPath: '@acme/mylib',
1198+
unitTestRunner: 'none',
1199+
directory: 'mylib',
1200+
name: 'mylib',
1201+
});
1202+
1203+
expect(readJson(tree, 'mylib/package.json')).toMatchInlineSnapshot(`
1204+
{
1205+
"exports": {
1206+
".": {
1207+
"import": "./dist/index.esm.js",
1208+
"types": "./dist/index.esm.d.ts",
1209+
},
1210+
"./package.json": "./package.json",
1211+
},
1212+
"files": [
1213+
"dist",
1214+
"!**/*.tsbuildinfo",
1215+
],
1216+
"main": "./dist/index.esm.js",
1217+
"module": "./dist/index.esm.js",
1218+
"name": "@acme/mylib",
1219+
"nx": {
1220+
"name": "mylib",
1221+
"projectType": "library",
1222+
"sourceRoot": "mylib/src",
1223+
},
1224+
"type": "module",
1225+
"types": "./dist/index.esm.d.ts",
1226+
}
1227+
`);
1228+
});
11911229
});
11921230
});

packages/react/src/generators/library/library.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export async function libraryGeneratorInternal(host: Tree, schema: Schema) {
8484
sourceRoot: `${options.projectRoot}/src`,
8585
tags: options.parsedTags?.length ? options.parsedTags : undefined,
8686
},
87+
files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
8788
});
8889
} else {
8990
addProjectConfiguration(host, options.name, {

0 commit comments

Comments
 (0)