Skip to content

feat: extend inlineScripts type#883

Merged
gaoachao merged 22 commits intomainfrom
feat/extend-inlineScripts-type
Jun 27, 2025
Merged

feat: extend inlineScripts type#883
gaoachao merged 22 commits intomainfrom
feat/extend-inlineScripts-type

Conversation

@gaoachao
Copy link
Copy Markdown
Collaborator

@gaoachao gaoachao commented May 22, 2025

Summary

follow up #874
close #870

Align output.inlineScripts with Rsbuild

type InlineChunkTestFunction = (params: {
  size: number;
  name: string;
}) => boolean;

type InlineChunkTest = RegExp | InlineChunkTestFunction;

type InlineChunkConfig =
  | boolean
  | InlineChunkTest
  | { enable?: boolean | 'auto'; test: InlineChunkTest };

Related links:

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented May 22, 2025

🦋 Changeset detected

Latest commit: 4401025

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

This PR includes changesets to release 7 packages
Name Type
@lynx-js/rspeedy Patch
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/react-webpack-plugin Patch
@lynx-js/template-webpack-plugin Patch
create-rspeedy Patch
upgrade-rspeedy Patch
@lynx-js/react-alias-rsbuild-plugin 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
Copy Markdown

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 92.00000% with 6 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ck/template-webpack-plugin/src/LynxEncodePlugin.ts 90.62% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented May 22, 2025

CodSpeed Performance Report

Merging #883 will not alter performance

Comparing feat/extend-inlineScripts-type (4401025) with main (a64333e)

Summary

✅ 10 untouched benchmarks

@gaoachao gaoachao force-pushed the feat/extend-inlineScripts-type branch 2 times, most recently from 1a20548 to e8e44bf Compare May 26, 2025 08:32
@relativeci
Copy link
Copy Markdown

relativeci bot commented May 26, 2025

React Example

#2224 Bundle Size — 233.19KiB (0%).

4401025(current) vs a64333e main#2199(baseline)

Bundle metrics  no changes
                 Current
#2224
     Baseline
#2199
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 152 152
No change  Duplicate Modules 60 60
No change  Duplicate Code 45.81% 45.81%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#2224
     Baseline
#2199
No change  IMG 145.76KiB 145.76KiB
No change  Other 87.43KiB 87.43KiB

Bundle analysis reportBranch feat/extend-inlineScripts-typeProject dashboard


Generated by RelativeCIDocumentationReport issue

@gaoachao gaoachao force-pushed the feat/extend-inlineScripts-type branch from 7170f13 to 30adb2d Compare May 27, 2025 09:21
@gaoachao gaoachao marked this pull request as ready for review May 27, 2025 10:07
@gaoachao gaoachao requested a review from colinaaa as a code owner May 27, 2025 10:07
@gaoachao gaoachao requested a review from upupming May 27, 2025 10:10
@relativeci
Copy link
Copy Markdown

relativeci bot commented Jun 3, 2025

Web Explorer

#2214 Bundle Size — 258.15KiB (0%).

4401025(current) vs a64333e main#2189(baseline)

Bundle metrics  no changes
                 Current
#2214
     Baseline
#2189
No change  Initial JS 140.17KiB 140.17KiB
No change  Initial CSS 31.82KiB 31.82KiB
Change  Cache Invalidation 0% 76.84%
No change  Chunks 4 4
No change  Assets 4 4
No change  Modules 207 207
No change  Duplicate Modules 15 15
No change  Duplicate Code 3.41% 3.41%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#2214
     Baseline
#2189
No change  JS 226.33KiB 226.33KiB
No change  CSS 31.82KiB 31.82KiB

Bundle analysis reportBranch feat/extend-inlineScripts-typeProject dashboard


Generated by RelativeCIDocumentationReport issue

@gaoachao gaoachao requested a review from colinaaa June 20, 2025 09:31
@gaoachao gaoachao added this to the @lynx-js/rspeedy v0.10.0 milestone Jun 25, 2025
gaoachao added 2 commits June 27, 2025 15:30
<!--
  Thank you for submitting a pull request!

We appreciate the time and effort you have invested in making these
changes. Please ensure that you provide enough information to allow
others to review your pull request.

Upon submission, your pull request will be automatically assigned with
reviewers.

If you want to learn more about contributing to this project, please
visit:
https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md.
-->

## Summary

<!-- Can you explain the reasoning behind implementing this change? What
problem or issue does this pull request resolve? -->

<!-- It would be helpful if you could provide any relevant context, such
as GitHub issues or related discussions. -->

Remove inlinedAssets from inlinedManifest

## Checklist

<!--- Check and mark with an "x" -->

- [x] Tests updated (or not required).
- [x] Documentation updated (or not required).
@gaoachao gaoachao enabled auto-merge June 27, 2025 11:21
@gaoachao gaoachao requested a review from colinaaa June 27, 2025 11:22
Copy link
Copy Markdown
Collaborator

@colinaaa colinaaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation LGTM. But there are more to think about to make it better:

  1. We should not only apply inlineScripts to LynxEncodePlugin, the WebEncodePlugin should also support this.
    • We may want a base class and implement some common logic (e.g.: inline script, deleting inline assets)
  2. We may want to allow customize the retry and error handling of external chunks
  3. We may want to allow injecting external & inlined chunks
    • In Rsbuild Web, we have api.modifyHTMLTags that can add <script> to the HTML.

@gaoachao gaoachao added this pull request to the merge queue Jun 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 27, 2025
@gaoachao gaoachao added this pull request to the merge queue Jun 27, 2025
Merged via the queue into main with commit a7e8b5b Jun 27, 2025
42 checks passed
@gaoachao gaoachao deleted the feat/extend-inlineScripts-type branch June 27, 2025 14:29
colinaaa pushed a commit that referenced this pull request Jun 30, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/qrcode-rsbuild-plugin@0.4.0

### Minor Changes

- Support "Type to search" when switching entries and schema.
([#1115](#1115))

## @lynx-js/react@0.110.1

### Patch Changes

- Fix a memory leak when using `<list/>`.
([#1144](#1144))

## @lynx-js/rspeedy@0.9.11

### Patch Changes

- Enable fine-grained control for `output.inlineScripts`
([#883](#883))

    ```ts
    type InlineChunkTestFunction = (params: {
      size: number;
      name: string;
    }) => boolean;

    type InlineChunkTest = RegExp | InlineChunkTestFunction;

    type InlineChunkConfig =
      | boolean
      | InlineChunkTest
      | { enable?: boolean | "auto"; test: InlineChunkTest };
    ```

    ```ts
    import { defineConfig } from "@lynx-js/rspeedy";

    export default defineConfig({
      output: {
        inlineScripts: ({ name, size }) => {
          return name.includes("foo") && size < 1000;
        },
      },
    });
    ```

- docs: remove chunks: 'all' in comments
([#1168](#1168))

## @lynx-js/react-rsbuild-plugin@0.10.5

### Patch Changes

- Avoid IIFE in `main-thread.js` to resolve memory leak when using
`<list />`.
([#1176](#1176))

- Enable fine-grained control for `output.inlineScripts`
([#883](#883))

    ```ts
    type InlineChunkTestFunction = (params: {
      size: number;
      name: string;
    }) => boolean;

    type InlineChunkTest = RegExp | InlineChunkTestFunction;

    type InlineChunkConfig =
      | boolean
      | InlineChunkTest
      | { enable?: boolean | "auto"; test: InlineChunkTest };
    ```

    ```ts
    import { defineConfig } from "@lynx-js/rspeedy";

    export default defineConfig({
      output: {
        inlineScripts: ({ name, size }) => {
          return name.includes("foo") && size < 1000;
        },
      },
    });
    ```

- Updated dependencies
\[[`51cb73d`](51cb73d),
[`69fb042`](69fb042),
[`a7e8b5b`](a7e8b5b)]:
    -   @lynx-js/runtime-wrapper-webpack-plugin@0.1.2
    -   @lynx-js/template-webpack-plugin@0.8.1
    -   @lynx-js/react-webpack-plugin@0.6.17
    -   @lynx-js/react-alias-rsbuild-plugin@0.10.5
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.3
    -   @lynx-js/css-extract-webpack-plugin@0.6.0

## @lynx-js/web-constants@0.14.1

### Patch Changes

- feat: support BTS API `lynx.reportError` && `__SetSourceMapRelease`,
now you can use it and handle it in lynx-view error event.
([#1059](#1059))

- fix: in lynx-view all-on-ui mode, the input event of input and
textarea is triggered twice, and the first e.detail is a string, which
does not conform to the expected data format.
([#1179](#1179))

- fix: under the all-on-ui strategy, reload() will add two page
elements. ([#1147](#1147))

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.14.1

## @lynx-js/web-core@0.14.1

### Patch Changes

- feat: support BTS API `lynx.reportError` && `__SetSourceMapRelease`,
now you can use it and handle it in lynx-view error event.
([#1059](#1059))

- fix: under the all-on-ui strategy, reload() will add two page
elements. ([#1147](#1147))

- Updated dependencies
\[[`a64333e`](a64333e),
[`7751375`](7751375),
[`b52a924`](b52a924)]:
    -   @lynx-js/web-worker-runtime@0.14.1
    -   @lynx-js/web-constants@0.14.1
    -   @lynx-js/web-mainthread-apis@0.14.1
    -   @lynx-js/web-worker-rpc@0.14.1

## @lynx-js/web-elements@0.7.7

### Patch Changes

- fix: the param `index` of list scrollToPosition function should be
`position`.
([#1135](#1135))

- fix: in lynx-view all-on-ui mode, the input event of input and
textarea is triggered twice, and the first e.detail is a string, which
does not conform to the expected data format.
([#1179](#1179))

-   Updated dependencies \[]:
    -   @lynx-js/web-elements-template@0.7.7

## @lynx-js/web-mainthread-apis@0.14.1

### Patch Changes

- fix: under the all-on-ui strategy, reload() will add two page
elements. ([#1147](#1147))

- Updated dependencies
\[[`a64333e`](a64333e),
[`7751375`](7751375),
[`b52a924`](b52a924)]:
    -   @lynx-js/web-constants@0.14.1

## @lynx-js/web-worker-runtime@0.14.1

### Patch Changes

- feat: support BTS API `lynx.reportError` && `__SetSourceMapRelease`,
now you can use it and handle it in lynx-view error event.
([#1059](#1059))

- Updated dependencies
\[[`a64333e`](a64333e),
[`7751375`](7751375),
[`b52a924`](b52a924)]:
    -   @lynx-js/web-constants@0.14.1
    -   @lynx-js/web-mainthread-apis@0.14.1
    -   @lynx-js/web-worker-rpc@0.14.1

## @lynx-js/react-webpack-plugin@0.6.17

### Patch Changes

- Enable fine-grained control for `output.inlineScripts`
([#883](#883))

    ```ts
    type InlineChunkTestFunction = (params: {
      size: number;
      name: string;
    }) => boolean;

    type InlineChunkTest = RegExp | InlineChunkTestFunction;

    type InlineChunkConfig =
      | boolean
      | InlineChunkTest
      | { enable?: boolean | "auto"; test: InlineChunkTest };
    ```

    ```ts
    import { defineConfig } from "@lynx-js/rspeedy";

    export default defineConfig({
      output: {
        inlineScripts: ({ name, size }) => {
          return name.includes("foo") && size < 1000;
        },
      },
    });
    ```

## @lynx-js/runtime-wrapper-webpack-plugin@0.1.2

### Patch Changes

- Wrap with IIFE when `output.iife: false` to avoid naming conflict.
([#1176](#1176))

## @lynx-js/template-webpack-plugin@0.8.1

### Patch Changes

- feat: `::placeholder` will be compiled to `part(input)::placeholder`,
which means you can use pseudo-element CSS to add placeholder styles to
input and textarea.
([#1158](#1158))

        // before
<input placeholder-color='red' placeholder-font-weight='bold'
placeholder-font-size='20px'>

        // after
        <input>

        input::placeholder {
          color: red;
          font-weight: bold;
          font-size: 20px;
        }

- Enable fine-grained control for `output.inlineScripts`
([#883](#883))

    ```ts
    type InlineChunkTestFunction = (params: {
      size: number;
      name: string;
    }) => boolean;

    type InlineChunkTest = RegExp | InlineChunkTestFunction;

    type InlineChunkConfig =
      | boolean
      | InlineChunkTest
      | { enable?: boolean | "auto"; test: InlineChunkTest };
    ```

    ```ts
    import { defineConfig } from "@lynx-js/rspeedy";

    export default defineConfig({
      output: {
        inlineScripts: ({ name, size }) => {
          return name.includes("foo") && size < 1000;
        },
      },
    });
    ```

## create-rspeedy@0.9.11



## @lynx-js/react-alias-rsbuild-plugin@0.10.5



## upgrade-rspeedy@0.9.11



## @lynx-js/web-core-server@0.14.1



## @lynx-js/web-elements-template@0.7.7



## @lynx-js/web-worker-rpc@0.14.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

[Feature]: Support output.inlineScripts

2 participants