Repository navigation
Add ignorePattern to FilesystemLoader - #977
Conversation
A file is not loaded as a page when the pattern matches at the start of its path. The path is relative to the content directory and uses forward slashes on every platform. RegExp(r'(.*/)?README\.md$') skips every README.md and RegExp(r'drafts/.*') skips the files below the top-level drafts folder. loadPageSources and addFile both apply the pattern, so a file created while serving does not become a page either. As with filterExtensions, an ignored file can still be read as a partial, and adding one invalidates the pages that read it, so they are rebuilt. Refs schultek#789
invalidateFile only acted on files that have a page source, so editing a partial excluded by filterExtensions or ignorePattern left the pages that read it stale until the next reload. It now invalidates those pages, as addFile and removeFile already do. Pages that did not read the partial are left alone. Refs schultek#789
Add the option to the FilesystemLoader entry of the route loading page, and two lines to the jaspr_content changelog. Refs schultek#789
|
To preview the documentation for this pull request, visit the following URL:
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues requiring changes to the filesystem path-filtering update.
No open issues 🎉
What changed in this PR
Adds configurable path filtering to FilesystemLoader, addressing #789 while keeping ignored files available as partials.
Changes:
- Adds
ignorePatternmatching against forward-slash relative paths during initial loading and file-add events. - Fixes dependent-page invalidation when ignored or extension-filtered partials change.
- Adds POSIX- and Windows-style tests, API documentation, and release notes.
| File | Description |
|---|---|
packages/jaspr_content/test/route_loaders/filesystem_loader_test.dart |
Tests path filtering, watcher events, and partial dependency invalidation. |
packages/jaspr_content/lib/src/route_loader/filesystem_loader.dart |
Implements ignorePattern and invalidation for partials without page sources. |
packages/jaspr_content/CHANGELOG.md |
Records the new option and partial invalidation fix. |
docs/content/concepts/route_loading.mdx |
Documents path filtering with a README exclusion example. |
Review effort: Balanced
Package Version ReportThe following packages have been updated: |
parlough
left a comment
There was a problem hiding this comment.
Thanks for tackling this! Looks good to me.
Description
Adds an
ignorePatternoption toFilesystemLoader(#789). A file is skipped when the pattern matches at the start of its path relative to the content directory, written with forward slashes (the conventionkeepSuffixPatternuses). For example,RegExp(r'(.*/)?README\.md$')skips everyREADME.md.invalidateFileonly acted on files that have a page source, so editing a partial excluded byfilterExtensionsorignorePatternleft the pages that read it stale until the next reload. It now invalidates them. It is a separate commit if you would rather split it out.Tests are new cases in
filesystem_loader_test.dart, in posix and Windows style. I ran them on Dart 3.12.2 (I don't have 3.13 here) in a trimmed workspace. On my Windows machine 8 existing tests in that file already fail on main, and 4 of my posix-style ones fail the same way, because the watcher test gets Windows-style paths. In a throwaway copy where the watcher usesp.posix, all 33 tests in the file pass. I haven't run them on Linux.Not included:
GithubLoaderhas noignorePattern.Fixes #789
Type of Change
Ready Checklist
the semantic_changelog format.
///).