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(plugin-runtime): support ssr inline assets #4735

Merged
merged 4 commits into from
Oct 24, 2023

Conversation

GiveMe-A-Name
Copy link
Member

@GiveMe-A-Name GiveMe-A-Name commented Sep 27, 2023

Summary

🤖 Generated by Copilot at 20fbd9e

This pull request adds a new feature to the @modern-js/runtime package that allows inlining some script and style assets in the HTML output for SSR rendering. It modifies the SSRPluginConfig type, the ssrPlugin and renderToString functions, and the RenderToString and Render classes to support the feature. It also adds a test case for the feature in the tests/integration/ssr folder, using a fixture app with some configuration options and components. It updates the .changeset folder with a markdown file that describes the changes and the version update.

Details

🤖 Generated by Copilot at 20fbd9e

  • Add a markdown file to the .changeset folder with the changelog and version information for the @modern-js/runtime package (link)
  • Add two configuration options for enabling the inline assets feature for the style and script assets in the SSRPluginConfig type (link)
  • Destructure the configuration options from the config.output object and pass them to the renderToString function in the ssrPlugin function (link, link)
  • Declare and assign a routeManifest property to store the route assets information in the RenderToString class (link, link)
  • Change the renderToString and render methods of the RenderToString class to return promises instead of strings and add await keywords before the asynchronous function calls (link, link, link, link)
  • Pass the routeManifest property to the createLoadableCollector function in the renderToString method of the RenderToString class (link)
  • Import some modules and types for the inline assets feature and define some helper functions for filtering and checking the chunk assets in the loadable.ts file (link, link)
  • Change the effect method of the LoadableCollector class to return a promise and replace the original logic of emitting the loadable assets with two separate methods for emitting the script and style assets (link, link)
  • Add an optional parameter for extra attributes to the generateAttributes method of the LoadableCollector class (link)
  • Add an optional property for the route manifest to the LoadableCollectorOptions interface (link)
  • Change the effect method of the Collector interface and the finish method of the Render class to return promises and use Promise.all to wait for the collectors' effects in the render.ts file (link, link, link)
  • Add a fixture folder for the inline SSR test case with a configuration file, a package file, a style file, a layout component and a page component (link, link, link, link, link)
  • Add a test file for the inline SSR feature that builds, serves and asserts the app with the inline style and script elements (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 Sep 27, 2023

🦋 Changeset detected

Latest commit: ae8b99a

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

This PR includes changesets to release 258 packages
Name Type
@modern-js/runtime 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-inline 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/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/plugin-ssg Minor
@modern-js/plugin-swc Minor
@modern-js/builder-doc Minor
@modern-js/main-doc Minor
@modern-js/module-tools-docs Minor
@modern-js/devtools-kit Minor
@modern-js/new-action Minor
@modern-js/sandpack-react Minor
@modern-js-app/eslint-config Minor
@modern-js/eslint-config Minor
@modern-js/tsconfig Minor
@modern-js/babel-plugin-module-resolver Minor
@modern-js/bff-core Minor
@modern-js/bff-runtime Minor
@modern-js/server-core Minor
@modern-js/create-request 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
@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/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
@modern-js/app-tools 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/types Minor
@modern-js/upgrade Minor
@modern-js/utils Minor
@modern-js/babel-compiler Minor
@scripts/build Minor
@scripts/check-changeset Minor
@scripts/jest-config Minor
@scripts/lint-package-json Minor
@scripts/prebundle Minor
@scripts/update-codesmith Minor
@scripts/update-rsbuild Minor
@scripts/update-rspress Minor
@scripts/vitest-config Minor
tests Minor
integration-asset-prefix Minor
integration-builder-plugins Minor
integration-copy-assets Minor
esbuild-integration Minor
integration-config-async-config-test Minor
integration-basic-local-config Minor
integration-config-function-params Minor
integration-local-config-function 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
resolve-false 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
integration-module-tools 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-test-decorator-legacy Minor
swc-test-decorator Minor
swc-integration Minor
tailwindcss-integration-test Minor
@e2e/builder-cli-rspack Minor
@e2e/builder-cli-vue Minor
@e2e/builder-cli-webpack 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
@e2e/builder Minor
@e2e/garfish Minor
@modern-js/generator-common Patch
@modern-js/generator-plugin Patch
@modern-js/generator-utils Patch
@modern-js/bff-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/router-v5-generator Patch
@modern-js/rspack-generator Patch
@modern-js/ssg-generator Patch
@modern-js/storybook-generator Patch
@modern-js/test-generator Patch
@modern-js/upgrade-generator Patch
@modern-js/generator-plugin-plugin Patch
@modern-js/base-generator Patch
@modern-js/changeset-generator Patch
@modern-js/packages-generator Patch
@modern-js/repo-generator Patch
@modern-js/server-generator Patch
@modern-js/tailwindcss-generator Patch
@modern-js/generator-cases Patch

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 Sep 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (99693f0) 57.59% compared to head (962e671) 50.66%.
Report is 1296 commits behind head on main.

❗ Current head 962e671 differs from pull request most recent head ae8b99a. Consider uploading reports for the commit ae8b99a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4735      +/-   ##
==========================================
- Coverage   57.59%   50.66%   -6.94%     
==========================================
  Files         672      692      +20     
  Lines       17794    19293    +1499     
  Branches     3876     4461     +585     
==========================================
- Hits        10249     9775     -474     
- Misses       6934     8770    +1836     
- Partials      611      748     +137     

see 507 files with indirect coverage changes

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

@GiveMe-A-Name GiveMe-A-Name changed the title WIP feat(plugin-runtime): support ssr inline assets feat(plugin-runtime): support ssr inline assets Sep 28, 2023
yimingjfe
yimingjfe previously approved these changes Oct 8, 2023
@GiveMe-A-Name GiveMe-A-Name enabled auto-merge (squash) October 20, 2023 07:58
@GiveMe-A-Name GiveMe-A-Name enabled auto-merge (squash) October 23, 2023 11:54
auto-merge was automatically disabled October 24, 2023 03:18

Base branch was modified

@GiveMe-A-Name GiveMe-A-Name merged commit ce967bb into main Oct 24, 2023
7 checks passed
@GiveMe-A-Name GiveMe-A-Name deleted the feat/support-ssr-inline-assets branch October 24, 2023 06:26
Asuka109 pushed a commit that referenced this pull request Oct 24, 2023
feat: optimize github workflow config (#4826)

chore: use self host for type-checker (#4827)

feat: release action trigger rsbuild update-modern workflow (#4828)

fix: export reporter only in middlewares-context (#4562)

feat: update rspress version (#4821)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: neverland <chenjiahan.jait@bytedance.com>

chore(module-tools): add comment for resolve false in browser alias (#4818)

docs: fix broken dicebear avatar api url (#4835)

feat: add storybook framework (#4585)

fix: modify the generated routes code, compatible with loadable and swc (#4833)

chore(storybook): fix version, files and license (#4836)

fix(storybook-builder): add missing files (#4837)

feat: optimize generator bundle (#4838)

feat(plugin-runtime): support ssr inline assets (#4735)

feat: upgrade generator support handle special package (#4839)

fix(module-tools): update umd global code (#4825)

fix(plugin-testing): failed to run tests with decorators (#4840)

fix(module-pluginnode-polyfill): no bundle globals.js (#4841)
This was referenced Oct 25, 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