Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak globs depending on compile configuration #39

Closed
wants to merge 2 commits into from

Conversation

alebianco
Copy link

@alebianco alebianco commented Nov 19, 2021

Generates different ignore patterns depending on the pre-compilation configuration:

When the pre-compilation is on:

  • ignores changes on the destination folder
  • triggers the tests execution on changes in the source folder

When the pre-compilation is off:

  • ignores changes in the source folder
  • triggers the tests execution on changes in the destination folder (likely caused by a manual compilation)

Fixes #33.

@novemberborn novemberborn changed the title Update ignore globs depending on compile configuration (fix #33) Tweak globs depending on compile configuration Nov 28, 2021
Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @alebianco. Sorry for the late response I've been swamped.

I've left some inline comments. Also do you think we need to add tests to cover both use cases?

@@ -142,7 +142,7 @@ export default function typescriptProvider({negotiateProtocol}) {
],
ignoredByWatcherPatterns: [
...ignoredByWatcherPatterns,
...Object.values(relativeRewritePaths).map(to => `${to}**/*.js.map`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want to keep this, it's useful if the pre-compilation step outputs source maps. And it should be harmless in case we run tsc ourselves.

index.js Outdated
@@ -115,7 +115,7 @@ export default function typescriptProvider({negotiateProtocol}) {
return false;
}

return rewritePaths.some(([from]) => filePath.startsWith(from));
return rewritePaths.some(([to, from]) => filePath.startsWith(compile === 'tsc' ? from : to));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to check compile once? Also you mixed up the "from" and "to":

Suggested change
return rewritePaths.some(([to, from]) => filePath.startsWith(compile === 'tsc' ? from : to));
return compile === 'tsc' ? rewritePaths.some(([from, to]) => filePath.startsWith(to)) : rewritePaths.some(([from]) => filePath.startsWith(from));

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol. yep, sorry

index.js Outdated
@@ -142,7 +142,7 @@ export default function typescriptProvider({negotiateProtocol}) {
],
ignoredByWatcherPatterns: [
...ignoredByWatcherPatterns,
...Object.values(relativeRewritePaths).map(to => `${to}**/*.js.map`),
...Object.entries(relativeRewritePaths).map(([to, from]) => `${compile === 'tsc' ? from : to}**`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too I think the entries are in the shape of [from, to]. And rather than ignoring all files in the directory we should only ignore those with the right extensions. Not sure right now if that should come from any configuration.

Suggested change
...Object.entries(relativeRewritePaths).map(([to, from]) => `${compile === 'tsc' ? from : to}**`),
...Object.entries(relativeRewritePaths).map(([from, to]) => `${compile === 'tsc' ? to : from}**/*.{ts,tsx}`),

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about ignoring only some file extension, for two reasons:

  • a change to a json file (as an example) might trigger tests before the compiler had the chance to run
  • depending whether the to or from folder is ignored, the extensions list would change from ts-related to js-related

for the watcher I'd rather ignore the whole folders in order to:

  • fully ignore the sources and only react when the compiler changed the output (auto compilation case)
  • fully ignore what the compiler might change and only watch the sources (external compilation case)

is there some other scenario I'm not thinking of?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but it changes the behavior compared to plain AVA. Changing a fixture file should cause tests to re-run.

But to get around that I think we'd need a way to block until compilation is complete?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, didn't think about the fixtures, I haven't used them much until now. It makes sense not to change the standard behaviour.

I'll make the change to ignore only ts,tsx files (or something along those lines) for now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ava watch does not work with pre-compile option
2 participants