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

feat: support shouldRevalidate #4781

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

yimingjfe
Copy link
Member

@yimingjfe yimingjfe commented Oct 12, 2023

Summary

🤖 Generated by Copilot at 1abe730

This pull request improves the data fetching and revalidation features of Modern.js and its documentation. It updates the PrefetchLink component, the shouldRevalidate function, and the analyze module to handle more complex URL scenarios and route configurations. It also updates the documentation files for data fetching in English and Chinese, and adds and modifies tests and example apps to demonstrate the new features.

Details

🤖 Generated by Copilot at 1abe730

  • Add a markdown file to specify the version bump and changelog (link)
  • Fix a typo and add a new section to the data fetching documentation in English and Chinese (link, link, link, link)
  • Export the createShouldRevalidate function from the router runtime index file (link)
  • Modify the PrefetchLink component to use the path object instead of the pathname string, and to call the shouldRevalidate function of the matched route if it exists (link, link, link, link, link, link, link)
  • Add a new module for the shouldRevalidate function that creates a shouldRevalidate function for a given route id (link)
  • Modify the walk function of the nestedRoutes module to return the final route if it has a component but no child routes or index flag (link)
  • Modify the templates module to allow specifying the action file path as a string, to add a slash to the action file path in the query string, to import and assign the route modules to the window object, to add the shouldRevalidate property to the final route object, and to filter out the shouldRevalidate property from the react-router route object (link, link, link, link, link, link, link, link)
  • Add a new constant for the ROUTE_MODULES property name in the constants module (link)
  • Modify the example app in tests/integration/routes/src/four to remove the action function from the page component, to use the useLoaderData hook instead of the useParams hook, and to export the shouldRevalidate function that checks the query parameter (link, link)
  • Add a new profile page component and data file to the example app in tests/integration/routes/src/four that use the session storage to get and set the data (link, link)
  • Modify the layout component of the example app in tests/integration/routes/src/four to add two new links to test the shouldRevalidate function (link)
  • Add a new data file for the page component of the example app in tests/integration/routes/src/three that returns the id parameter as the data (link)
  • Modify the page component of the example app in tests/integration/routes/src/three to use the useLoaderData hook instead of the useParams hook, and to export the shouldRevalidate function that checks the query parameter (link)
  • Modify the layout component of the example app in tests/integration/routes/src/three to add three new links to test the prefetch and shouldRevalidate features (link, link)
  • Remove a commented out code and modify the expected text in the supportActionInCSR test function in the index test file (link, link)
  • Add three new test functions to the index test file to test the prefetch, shouldRevalidate, and prefetch with shouldRevalidate features in different modes (link)
  • Enable the request interception and continue the intercepted requests in the beforeEach block of the index test file (link)
  • Add six new test blocks to the index test file to describe the tests for the prefetch and shouldRevalidate features in the string, csr, and streaming modes (link, link, link)

Related Issue

Checklist

  • I have added changeset via pnpm run change.
  • I have updated the documentation.
  • I have added tests to cover my changes.

@changeset-bot
Copy link

changeset-bot bot commented Oct 12, 2023

🦋 Changeset detected

Latest commit: bd28c37

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 257 packages
Name Type
@modern-js/runtime Minor
@modern-js/app-tools Minor
@modern-js/utils Minor
@modern-js/plugin-bff Minor
@modern-js/plugin-storybook Minor
@modern-js/plugin-tailwindcss Minor
@modern-js/devtools-client Minor
@modern-js/devtools-mount Minor
@modern-js/plugin-devtools Minor
@modern-js/plugin-garfish Minor
@modern-js/plugin-router-v5 Minor
@modern-js/plugin-testing Minor
@integration-test/alias-set Minor
api-service-koa Minor
app-docmuent Minor
async-entry-test Minor
tmp Minor
bff-express Minor
bff-koa Minor
integration-clean-dist-path Minor
integration-compatibility Minor
integration-custom-dist-path Minor
integration-custom-render Minor
integration-custom-template Minor
dev-server Minor
@integration-test/devtools Minor
integration-disable-html Minor
esbuild-transform-and-minify Minor
main-entry-name Minor
nonce Minor
routes Minor
file-based-router Minor
use-loader Minor
select-mul-entry-test Minor
select-one-entry-test Minor
server-config Minor
server-middleware Minor
server-hook-reqeust Minor
server-hook-response Minor
server-hook-router Minor
@integration-test/server-hook-reqeust Minor
server-prod Minor
@source-code-build/app-ts-loader Minor
@source-code-build/app Minor
ssg-fixtures-nested-routes Minor
ssg-fixtures-simple Minor
ssg-fixtures-web-server Minor
ssr-base-json-test Minor
ssr-base-test Minor
ssr-base-fallback-test Minor
init Minor
ssr-preload Minor
ssr-streaming-test Minor
swc-minify-css Minor
swc-minify-js Minor
transform-fail Minor
integration-tailwindcss-v2 Minor
integration-tailwindcss-v3-js-config Minor
integration-tailwindcss-v3-merge-config Minor
integration-tailwindcss-v3-ts-config Minor
integration-tailwindcss-v3 Minor
twin-macro-v2 Minor
twin-macro-v3 Minor
tmp-dir Minor
write-to-dist Minor
@e2e/garfish-dashboard-router-v6 Minor
@e2e/garfish-dashboard Minor
@e2e/garfish-main-router-v6 Minor
@e2e/garfish-main Minor
@e2e/garfish-table Minor
@modern-js/plugin-ssg Minor
@modern-js/plugin-swc Minor
@modern-js/devtools-kit Minor
@modern-js/plugin-express Minor
@modern-js/plugin-koa Minor
@modern-js/plugin-polyfill Minor
@modern-js/plugin-server Minor
@modern-js/plugin-worker Minor
tests Minor
integration-asset-prefix Minor
integration-builder-plugins Minor
integration-copy-assets Minor
integration-config-async-config-test Minor
integration-basic-local-config Minor
integration-config-function-params Minor
integration-local-config-function Minor
swc-test-decorator-legacy Minor
swc-test-decorator Minor
@modern-js/babel-preset-app Minor
@modern-js/babel-preset-base Minor
@modern-js/core Minor
@modern-js/doc-plugin-auto-sidebar Minor
@modern-js/plugin-changeset Minor
@modern-js/plugin-data-loader Minor
@modern-js/plugin-i18n Minor
@modern-js/plugin-lint Minor
@modern-js/plugin-proxy Minor
@modern-js/generator-common Patch
@modern-js/generator-plugin Patch
@modern-js/generator-utils Patch
@modern-js/new-action Minor
@modern-js/sandpack-react Minor
@modern-js/base-generator Patch
@modern-js/bff-generator Patch
@modern-js/changeset-generator Patch
@modern-js/dependence-generator Patch
@modern-js/entry-generator Patch
@modern-js/generator-generator Patch
@modern-js/module-generator Patch
@modern-js/module-test-generator Patch
@modern-js/monorepo-generator Patch
@modern-js/mwa-generator Patch
@modern-js/packages-generator Patch
@modern-js/repo-generator Patch
@modern-js/router-v5-generator Patch
@modern-js/rspack-generator Patch
@modern-js/server-generator Patch
@modern-js/ssg-generator Patch
@modern-js/storybook-generator Patch
@modern-js/tailwindcss-generator Patch
@modern-js/test-generator Patch
@modern-js/upgrade-generator Patch
@modern-js/generator-plugin-plugin Patch
@modern-js/bff-core Minor
@modern-js/server-core Minor
@modern-js/create-request Minor
@modern-js/prod-server Minor
@modern-js/server Minor
@modern-js/server-utils Minor
@modern-js/builder-cli Minor
@modern-js/builder-rspack-provider Minor
@modern-js/builder-shared Minor
@modern-js/builder-webpack-provider Minor
@modern-js/builder Minor
@modern-js/builder-plugin-esbuild Minor
@modern-js/builder-plugin-image-compress Minor
@modern-js/builder-plugin-node-polyfill Minor
@modern-js/builder-plugin-stylus Minor
@modern-js/builder-plugin-swc Minor
@modern-js/builder-plugin-vue Minor
@modern-js/builder-plugin-vue2 Minor
@modern-js/module-tools Minor
@modern-js/monorepo-tools Minor
@modern-js/create Minor
@modern-js/e2e Minor
@modern-js/node-bundle-require Minor
@modern-js/plugin Minor
@modern-js/runtime-utils Minor
@modern-js/upgrade Minor
@modern-js/babel-compiler Minor
@e2e/builder Minor
@e2e/garfish Minor
@modern-js-app/eslint-config Minor
@modern-js/main-doc Minor
@modern-js/module-tools-docs Minor
@scripts/update-codesmith Minor
@e2e/builder-cli-rspack Minor
@e2e/builder-cli-vue Minor
@e2e/builder-cli-webpack Minor
@modern-js/plugin-module-babel Minor
@modern-js/plugin-module-banner Minor
@modern-js/plugin-module-import Minor
@modern-js/plugin-module-node-polyfill Minor
@modern-js/plugin-module-polyfill Minor
integration-module-tools Minor
@modern-js/eslint-config Minor
@modern-js/generator-cases Patch
@modern-js/builder-doc Minor
@modern-js/tsconfig Minor
@modern-js/babel-plugin-module-resolver Minor
@modern-js/bff-runtime Minor
@modern-js/types Minor
@scripts/build Minor
@scripts/check-changeset Minor
@scripts/jest-config Minor
@scripts/lint-package-json Minor
@scripts/prebundle Minor
@scripts/update-rspress Minor
@scripts/vitest-config Minor
esbuild-integration Minor
integration-load-config Minor
alias-js-test Minor
alias-ts-test Minor
asset-limit-test Minor
asset-path-test Minor
asset-publicPath-test Minor
svgr-test Minor
auto-external-test Minor
banner-footer-test Minor
build-type-test Minor
copy-test Minor
decorator-test Minor
global-vars-js-test Minor
global-vars-ts-test Minor
dts-test Minor
esbuild-options-test Minor
external-test Minor
format-cjs-test Minor
format-esm-test Minor
format-iife-test Minor
format-umd-test Minor
entry-test Minor
jsx-test Minor
metafile-test Minor
minify-test Minor
platform-test Minor
redirect-test Minor
data-url-test Minor
ndoe-protocol-test Minor
lib1 Minor
lib2 Minor
lib3 Minor
condition-exports-test Minor
js-extensions-test Minor
main-fields-test Minor
module-tools-side-effects-test Minor
source-dir-test Minor
sourcemap-test Minor
splitting-test Minor
css-test Minor
less-test Minor
style-test Minor
postcss-test Minor
sass-test Minor
tailwindcss-test Minor
target-test Minor
transform-import Minor
transform-lodash Minor
tsconfig-test Minor
umdGlobals-test Minor
get-module-id-test Minor
dev-test Minor
build-platform-test Minor
build-preset-error-test Minor
build-preset-function-test Minor
build-preset-test Minor
build-preset-string-test Minor
plugin-babel Minor
plugin-node-polyfill Minor
plugin-polyfill Minor
runtime Minor
entry Minor
@source-code-build/common Minor
@source-code-build/components Minor
@source-code-build/utils Minor
ssg Minor
ssr Minor
swc-integration Minor
tailwindcss-integration-test Minor
@e2e/webpack-builder-import-antd-v4 Minor
@e2e/webpack-builder-import-antd-v5 Minor
@e2e/webpack-builder-import-arco Minor
@e2e/webpack-builder-test-moment Minor
@e2e/builder-remove-prop-types Minor
@e2e/webpack-builder-source-map Minor
@e2e/builder-vue3 Minor
@e2e/builder-vue2 Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (99693f0) 57.59% compared to head (bd28c37) 51.19%.
Report is 1254 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4781      +/-   ##
==========================================
- Coverage   57.59%   51.19%   -6.41%     
==========================================
  Files         672      681       +9     
  Lines       17794    18991    +1197     
  Branches     3876     4391     +515     
==========================================
- Hits        10249     9722     -527     
- Misses       6934     8539    +1605     
- Partials      611      730     +119     

see 499 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yimingjfe yimingjfe merged commit ce0a14e into web-infra-dev:main Oct 13, 2023
10 checks passed
@caohuilin caohuilin mentioned this pull request Oct 18, 2023
9aoy pushed a commit that referenced this pull request Oct 23, 2023
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.

None yet

2 participants