diff --git a/.changeset/cuddly-bags-push.md b/.changeset/cuddly-bags-push.md new file mode 100644 index 00000000000..4436e3a7236 --- /dev/null +++ b/.changeset/cuddly-bags-push.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/router': minor +--- + +FIX: Route loaders now redirect in their JSON response instead of using HTTP redirect diff --git a/.changeset/flat-hornets-fetch.md b/.changeset/flat-hornets-fetch.md new file mode 100644 index 00000000000..48b6df0ff66 --- /dev/null +++ b/.changeset/flat-hornets-fetch.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/router': minor +--- + +FEAT: route loaders now accept `eTag` to shortcut data retrieval when the data has not changed. See the documentation for more details on this option and how to use it. diff --git a/.changeset/fresh-loaders-update.md b/.changeset/fresh-loaders-update.md new file mode 100644 index 00000000000..45f3d36dfd5 --- /dev/null +++ b/.changeset/fresh-loaders-update.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/router': patch +--- + +fix(router): Update route loader metadata in the dev route trie when route source files change. diff --git a/.changeset/green-experts-turn.md b/.changeset/green-experts-turn.md new file mode 100644 index 00000000000..5653f1b0124 --- /dev/null +++ b/.changeset/green-experts-turn.md @@ -0,0 +1,7 @@ +--- +'@qwik.dev/router': major +--- + +BREAKING: Route loaders are now AsyncSignals. This means that `value.failed` is no longer used to indicate a loader failure. Instead, if a loader fails, the error will be stored in `error`, and reading `value` will throw that error. + +This also means that you can now pass `expires`, `poll`, and `allowStale` options to route loaders. See the documentation for more details on these options and how to use them. diff --git a/.changeset/loaders-no-action-state.md b/.changeset/loaders-no-action-state.md new file mode 100644 index 00000000000..866f411edcb --- /dev/null +++ b/.changeset/loaders-no-action-state.md @@ -0,0 +1,5 @@ +--- +'@qwik.dev/router': major +--- + +BREAKING: `routeLoader$` cannot read action state any more, so that they are cacheable and predictable. All use cases can be achieved in other ways, like reading the action signal directly in the component or having the loader read from URL-derived state that the action updates. diff --git a/.changeset/nasty-pans-tickle.md b/.changeset/nasty-pans-tickle.md new file mode 100644 index 00000000000..2ee22619ae0 --- /dev/null +++ b/.changeset/nasty-pans-tickle.md @@ -0,0 +1,13 @@ +--- +'@qwik.dev/router': major +--- + +BREAKING: Qwik Router no longer retrieves `q-data.json` files on every SPA navigation. You can remove any caching rules for these. + +Instead, Qwik Router now retrieves `q-loader-${hash}.${manifestHash}.json` for RouteLoader data. You can specify expiry for each RouteLoader individually, and it is automatically used to set browser caching headers. The `manifestHash` ensures that when you build a new version of your app, the old cached data will be invalidated and the new data will be fetched. + +The default expiry for RouteLoader data is 2 minutes, so that prefetching and caching of RouteLoader data is useful. You control this with the `expiry` option on each RouteLoader, and you can set it to `0` to disable caching. + +Furthermore, any RouteLoader that has `expiry: 0` will be generated as a file during SSG, which allows SPA navigation to work even without a server. + +Note: Be careful with caching for RouteLoaders that return user-specific data, especially regarding logout and CDN caching. Use low expiry times for these and use `eTag` to still allow caching benefits. diff --git a/.changeset/warm-deer-take.md b/.changeset/warm-deer-take.md new file mode 100644 index 00000000000..dd1d078b6fe --- /dev/null +++ b/.changeset/warm-deer-take.md @@ -0,0 +1,7 @@ +--- +'@qwik.dev/router': minor +--- + +FEAT: route loaders now accept `search` to only allow certain query parameters to trigger the loader. This means that random search parameters won't cause the loader to re-run. If you do not pass `search`, then all search parameters will be passed to the loader and will trigger it when they change. + +However, `qwikRouter` now has the option `strictLoaders` which is `true` by default, which means that if you do not specify `search` for a loader, then it will not receive any search parameters and will not re-run when the search parameters change. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cb4a467506..be499fc63d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,7 +82,7 @@ jobs: run: echo event_name=${{ github.event_name }} - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Set Dist Tag id: set_dist_tag @@ -139,7 +139,7 @@ jobs: - name: 'check cache: qwik' id: cache-qwik - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: packages/qwik/dist @@ -149,7 +149,7 @@ jobs: - run: 'echo ${{ steps.cache-qwik.outputs.cache-primary-key }} > qwik-key.txt' - name: 'check cache: rust' id: cache-rust - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: packages/optimizer/bindings @@ -157,7 +157,7 @@ jobs: - run: 'echo ${{ steps.cache-rust.outputs.cache-primary-key }} > rust-key.txt' - name: 'check cache: others' id: cache-others - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: | @@ -170,14 +170,14 @@ jobs: - run: 'echo ${{ steps.cache-others.outputs.cache-primary-key }} > others-key.txt' - name: 'check cache: docs' id: cache-docs - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: docs-build-completed.txt key: ${{ hashfiles('others-key.txt', 'packages/docs/**/*') }} - name: 'check cache: insights' id: cache-insights - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: | @@ -186,35 +186,35 @@ jobs: key: ${{ hashfiles('others-key.txt', 'packages/insights/**/*') }} - name: 'check cache: unit tests' id: cache-unit - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: unit-tests-completed.txt key: ${{ hashfiles('others-key.txt', 'packages/**/*.unit.*') }} - name: 'check cache: benchmarks' id: cache-bench - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: bench-tests-completed.txt key: ${{ hashfiles('others-key.txt', 'packages/**/*.bench.*', 'scripts/validate-bench*', 'packages/docs/**/*') }} - name: 'check cache: e2e tests' id: cache-e2e - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: e2e-tests-completed.txt key: ${{ hashfiles('others-key.txt', 'starters/**/*') }} - name: 'check cache: cli e2e tests' id: cache-cli-e2e - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: cli-e2e-tests-completed.txt key: ${{ hashfiles('others-key.txt', 'e2e/**/*') }} - name: 'check cache: docs e2e tests' id: cache-docs-e2e - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: lookup-only: true path: docs-e2e-tests-completed.txt @@ -248,13 +248,13 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 if: needs.changes.outputs.build-qwik == 'true' - name: Setup Node if: needs.changes.outputs.build-qwik == 'true' - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' @@ -293,7 +293,7 @@ jobs: - name: Restore qwik cache if: needs.changes.outputs.build-qwik != 'true' - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: fail-on-cache-miss: true path: packages/qwik/dist @@ -305,13 +305,13 @@ jobs: - name: Save qwik cache if: needs.changes.outputs.build-qwik == 'true' - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-qwik }} path: packages/qwik/dist - name: Upload Qwik artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-qwik include-hidden-files: true @@ -342,16 +342,16 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: clippy,rustfmt - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' @@ -389,7 +389,7 @@ jobs: run: ls -lR packages/optimizer/bindings/ - name: Upload Platform Binding Artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-bindings-${{ matrix.settings.target }} include-hidden-files: true @@ -413,7 +413,7 @@ jobs: run: exit 1 - name: Restore artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Rust Artifacts if: needs.changes.outputs.build-rust == 'true' @@ -431,13 +431,13 @@ jobs: - name: Save rust cache if: needs.changes.outputs.build-rust == 'true' - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-rust }} path: packages/optimizer/ - name: Upload optimizer artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-optimizer include-hidden-files: true @@ -475,26 +475,26 @@ jobs: - name: Checkout if: needs.changes.outputs.build-others == 'true' - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 if: needs.changes.outputs.build-others == 'true' - name: Setup Node if: needs.changes.outputs.build-others == 'true' - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Restore Qwik artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: artifact-qwik path: packages/qwik/dist/ - name: Restore Optimizer artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: artifact-optimizer path: packages/optimizer/ @@ -508,7 +508,7 @@ jobs: run: pnpm build --tsc --api --qwikrouter --cli --qwikreact --eslint --set-dist-tag="${{ needs.changes.outputs.disttag }}" - name: Save others cache if: needs.changes.outputs.build-others == 'true' - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-others }} path: | @@ -519,7 +519,7 @@ jobs: - name: 'restore: qwik-router & others' if: needs.changes.outputs.build-others != 'true' - uses: actions/cache/restore@v4 + uses: actions/cache/restore@v5 with: path: | packages/qwik-router/lib @@ -532,7 +532,7 @@ jobs: run: tree -a packages/qwik-router/lib/ - name: Upload QwikRouter Build Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-qwikrouter include-hidden-files: true @@ -543,7 +543,7 @@ jobs: run: tree -a packages/qwik-react/lib/ - name: Upload qwik-react Build Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-qwikreact include-hidden-files: true @@ -555,7 +555,7 @@ jobs: run: tree -a packages/create-qwik/dist/ - name: Upload Create Qwik CLI Build Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-create-qwik include-hidden-files: true @@ -566,7 +566,7 @@ jobs: run: tree -a packages/eslint-plugin-qwik/dist/ - name: Upload Eslint rules Build Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-eslint-plugin-qwik include-hidden-files: true @@ -592,18 +592,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -613,7 +613,7 @@ jobs: run: pnpm run build.packages.insights - name: Save Insights Cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-insights }} path: | @@ -639,18 +639,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -660,7 +660,7 @@ jobs: run: pnpm build --tsc-docs && pnpm run build.packages.docs && echo ok > docs-build-completed.txt - name: Save Docs Artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: artifact-docs include-hidden-files: true @@ -669,7 +669,7 @@ jobs: packages/docs/server - name: Save Docs Cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-docs }} path: docs-build-completed.txt @@ -696,18 +696,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -721,13 +721,13 @@ jobs: run: pnpm run test.e2e.docs && echo ok > docs-e2e-tests-completed.txt - name: Save Docs E2E Tests Cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-docs-e2e }} path: docs-e2e-tests-completed.txt - name: Upload Playwright Trace - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 if: failure() with: name: docs-playwright-report @@ -759,18 +759,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -801,7 +801,7 @@ jobs: run: echo ok > unit-tests-completed.txt - name: Save unit tests cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-unit }} path: unit-tests-completed.txt @@ -830,18 +830,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -875,7 +875,7 @@ jobs: run: echo ok > bench-tests-completed.txt - name: Save benchmarks cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-bench }} path: bench-tests-completed.txt @@ -921,18 +921,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION_E2E }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -946,7 +946,7 @@ jobs: run: pnpm run test.e2e.${{ matrix.settings.browser }} - name: Upload Playwright Trace - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 if: failure() # only when tests fail with: name: playwright-report @@ -1016,18 +1016,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION_E2E }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts @@ -1080,7 +1080,7 @@ jobs: run: echo ok > e2e-tests-completed.txt - name: Save e2e tests cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-e2e }} path: e2e-tests-completed.txt @@ -1106,7 +1106,7 @@ jobs: run: echo ok > cli-e2e-tests-completed.txt - name: Save cli-e2e tests cache - uses: actions/cache/save@v4 + uses: actions/cache/save@v5 with: key: ${{ needs.changes.outputs.hash-cli-e2e }} path: cli-e2e-tests-completed.txt @@ -1117,11 +1117,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' @@ -1195,18 +1195,18 @@ jobs: run: exit 1 - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@v5 - name: Setup Node - uses: actions/setup-node@v5 + uses: actions/setup-node@v6 with: node-version: ${{ env.CI_NODE_VERSION }} cache: 'pnpm' registry-url: https://registry.npmjs.org/ - name: Download Build Artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 - name: Move Distribution Artifacts run: pnpm ci.restore-artifacts diff --git a/.gitignore b/.gitignore index 9482e9335a0..676be2365ad 100644 --- a/.gitignore +++ b/.gitignore @@ -18,11 +18,11 @@ node_modules # Artifacts tsc-out dist -dist-dev +/dist-dev external lib tsdoc-metadata.json -target +/target # IDE and local environment .idea @@ -48,4 +48,4 @@ sandbox # Vitest coverage packages/coverage/* visualizer.html -**/lib-types/**/* \ No newline at end of file +**/lib-types/**/* diff --git a/e2e/qwik-e2e/apps/qwikrouter-ssg-snapshot/expected.ssg.html b/e2e/qwik-e2e/apps/qwikrouter-ssg-snapshot/expected.ssg.html index 2ffadd3e233..bebf2fd46ac 100644 --- a/e2e/qwik-e2e/apps/qwikrouter-ssg-snapshot/expected.ssg.html +++ b/e2e/qwik-e2e/apps/qwikrouter-ssg-snapshot/expected.ssg.html @@ -1,3 +1,3 @@