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
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

},

resolveTestFile(testfile) {
Expand All @@ -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.

...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 👍

],
};
},
Expand Down
2 changes: 1 addition & 1 deletion test/snapshots/protocol-ava-3.2.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ Generated by [AVA](https://avajs.dev).
],
ignoredByWatcherPatterns: [
'assets/**',
'build/**/*.js.map',
'src/**',
],
}
Binary file modified test/snapshots/protocol-ava-3.2.js.snap
Binary file not shown.