-
Notifications
You must be signed in to change notification settings - Fork 353
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(builder): support inline assets by file size #4563
Conversation
🦋 Changeset detectedLatest commit: de98911 The changes in this PR will be included in the next version bump. This PR includes changesets to release 253 packages
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 ReportPatch coverage has no change and project coverage change:
Additional details and impacted files@@ Coverage Diff @@
## main #4563 +/- ##
==========================================
- Coverage 57.59% 53.74% -3.86%
==========================================
Files 672 655 -17
Lines 17794 17966 +172
Branches 3876 4142 +266
==========================================
- Hits 10249 9656 -593
- Misses 6934 7652 +718
- Partials 611 658 +47 ☔ View full report in Codecov by Sentry. |
Summary
Users can inline scripts by the file size, such as inline small scripts to HTML:
🤖 Generated by Copilot at 9e9f48c
This pull request adds more flexibility and customization to the inline scripts and styles feature of the
@modern-js/builder
package. It refactors and improves the code quality of theInlineChunkHtmlPlugin
and the config merging modules. It also updates the documentation and the test cases for the feature. It exports some new types and a utility function from the@modern-js/toolkit/utils
and the@modern-js/builder
packages.Details
🤖 Generated by Copilot at 9e9f48c
isOverriddenConfigKey
to determine which config keys should use source to override target instead of merging (link)isOverriddenConfigKey
function from the@modern-js/toolkit/utils
package (link)isOverriddenConfigKey
function in themergeBuilderConfig
andmergeConfig
modules to replace the hard-coded arrays of config keys (link, link, link, link, link)InlineChunkTest
andInlineChunkHtmlPluginOptions
to define the options for theInlineChunkHtmlPlugin
(link, link)InlineChunkTest
type from the@modern-js/builder-shared
package (link)styleTests
andscriptTests
to theInlineChunkHtmlPlugin
class to store the options (link)InlineChunkHtmlPlugin
class to accept the new options and assign them to the properties (link)matchTests
to theInlineChunkHtmlPlugin
class to check if a file matches any of the tests (link)processScriptTag
andprocessStyleTag
methods of theInlineChunkHtmlPlugin
class to use thematchTests
method and add some checks and comments (link, link, link, link)inlineSchema
to validate theenableInlineScripts
andenableInlineStyles
config options (link)sharedOutputConfigSchema
variable to use theinlineSchema
for theenableInlineScripts
andenableInlineStyles
config options (link)SharedOutputConfig
andNormalizedSharedOutputConfig
interfaces to use theInlineChunkTest
type for theenableInlineScripts
andenableInlineStyles
config options (link, link, link)builderPluginInlineChunk
function to use the newstyleTests
andscriptTests
options for theInlineChunkHtmlPlugin
and replace the hard-coded regular expressions with theJS_REGEX
andCSS_REGEX
constants (link, link, link)output.enableInlineScripts
andoutput.enableInlineStyles
config options in English and Chinese to reflect the new type and usage (link, link, link, link, link, link, link, link)inline scripts by filename
feature to match theindex
file instead of themain
file (link, link)inline scripts by filename and file size
feature to use a function to match the file size and name (link)inline styles by filename
feature to match theindex
file instead of themain
file (link, link)inline styles by filename and file size
feature to use a function to match the file size and name (link)Related Issue
Checklist
pnpm run change
.