Skip to content

Commit

Permalink
Remap tsconfig for builds so that only files under src are considered (
Browse files Browse the repository at this point in the history
…#212)

Co-authored-by: Luke Sheard <luke.sheard@jpmorgan.com>
  • Loading branch information
LukeSheard and Luke Sheard authored Jan 5, 2021
1 parent 72637d7 commit c5c15eb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/wet-nails-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'modular-scripts': patch
---

Fix an issue where generated files from libraries would interfere with
typescript definition generation
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('create-modular-react-app', () => {
│ │ ├─ logo.svg #1okqmlj
│ │ └─ react-app-env.d.ts #1dm2mq6
│ └─ tsconfig.json #6rw46b
├─ tsconfig.json #7rtj5f
├─ tsconfig.json #xubky9
└─ yarn.lock"
`);
expect(
Expand Down
2 changes: 1 addition & 1 deletion packages/create-modular-react-app/template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "modular-scripts/tsconfig.json",
"include": ["packages"]
"include": ["modular", "packages/*/src"]
}
5 changes: 4 additions & 1 deletion packages/modular-scripts/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ function makeTypings(directoryName: string) {
};

// then add our custom stuff
tsconfig.include = [`${packagesRoot}/${directoryName}`];

// Only include src files from the package to prevent already built
// files from interferring with the compile
tsconfig.include = [`${packagesRoot}/${directoryName}/src`];
tsconfig.compilerOptions = {
...tsconfig.compilerOptions,
declarationDir: `${packagesRoot}/${directoryName}/${outputDirectory}-types`,
Expand Down
4 changes: 2 additions & 2 deletions packages/tree-view-for-tests/src/__tests__/tree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('it can serialise a folder', () => {
├─ package.json
├─ src
│ ├─ __tests__
│ │ └─ index.test.ts #1ekksvp
│ │ └─ index.test.ts #1v8shn0
│ ├─ cli.ts #gcx3cm
│ └─ index.ts #un0l9d
└─ template
Expand All @@ -30,6 +30,6 @@ test('it can serialise a folder', () => {
│ └─ setupTests.ts #bnjknz
├─ packages
│ └─ README.md #14bthrh
└─ tsconfig.json #7rtj5f"
└─ tsconfig.json #xubky9"
`);
});

0 comments on commit c5c15eb

Please sign in to comment.