avajs / typescript

Test TypeScript projects using AVA.
MIT License
73 stars 16 forks source link

feat: monorepo support #35

Closed petermetz closed 3 years ago

petermetz commented 3 years ago

Please provide details about:

Directory structure:

packages/
├─ pkg-a/
│  ├─ dist/
│  │  ├─ lib/
│  │  │  ├─ index.js
│  ├─ src/
│  │  ├─ index.ts
├─ pkg-b/
│  ├─ src/
│  │  ├─ index.ts
│  ├─ dist/
│  │  ├─ lib/
│  │  │  ├─ index.js

Rewrite rule to capture all packages:

{
  "./packages/pkg-*/src/": "./packages/pkg-*/dist/lib/"
}
novemberborn commented 3 years ago

@petermetz could you elaborate on your proposed solution, with perhaps a sample directory layout, your desired rewrite paths configuration, and where you'd place this configuration?

petermetz commented 3 years ago

@novemberborn Updated the description with the examples.

and where you'd place this configuration?

Same as before, this would be an extension to how the rewrite paths configuration parameter is working as of right now. I'm not proposing to add new configuration files nor would it need to change the schema of the existing configuration file.

novemberborn commented 3 years ago

OK so you have ava.config.js next to packages/? And you run AVA from that root directory, which then picks up the test files for each of the packages?

Currently the path rewriting is based on prefixes:

https://github.com/avajs/typescript/blob/27650db45b4807f14056bc142d6e46a8558fd372/index.js#L127

We'd have to figure out how to express and then rewrite glob-based prefixes. I'm not sure whether a solution for that is already available.

An alternate approach may be to use an ava.config.js file that lists the directories inside packages/ and dynamically generates the rewrite configuration.

petermetz commented 3 years ago

@novemberborn

OK so you have ava.config.js next to packages/? And you run AVA from that root directory, which then picks up the test files for each of the packages?

Correct.

We'd have to figure out how to express and then rewrite glob-based prefixes. I'm not sure whether a solution for that is already available.

An alternate approach may be to use an ava.config.js file that lists the directories inside packages/ and dynamically generates the rewrite configuration.

Makes sense and thank you for the tip. For my case the dynamic config file approach is an easy enough solution that I can go with it so if no one else is interested in some out of the box convenience feature that does it fully automatically then I'd say maybe we can close this down. Thank you again for your help!