Skip to content

feat: support output.inlineScripts#874

Merged
gaoachao merged 6 commits intomainfrom
feat/support-output-inline-scripts
May 21, 2025
Merged

feat: support output.inlineScripts#874
gaoachao merged 6 commits intomainfrom
feat/support-output-inline-scripts

Conversation

@gaoachao
Copy link
Copy Markdown
Collaborator

@gaoachao gaoachao commented May 21, 2025

Summary

#870

follow up #502

Support output.inlineScripts, which controls whether to inline scripts files when LynxEncodePlugin generates the manifest file.

Checklist

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

@gaoachao gaoachao requested a review from colinaaa as a code owner May 21, 2025 08:31
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented May 21, 2025

🦋 Changeset detected

Latest commit: a56169a

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

This PR includes changesets to release 6 packages
Name Type
@lynx-js/template-webpack-plugin Patch
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/rspeedy 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 21, 2025

Codecov Report

Attention: Patch coverage is 80.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 79.16% 5 Missing ⚠️
packages/rspeedy/plugin-react/src/entry.ts 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented May 21, 2025

CodSpeed Performance Report

Merging #874 will not alter performance

Comparing feat/support-output-inline-scripts (a56169a) with main (c84b8d3)

Summary

✅ 9 untouched benchmarks

gaoachao and others added 4 commits May 21, 2025 19:46
Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
Signed-off-by: BitterGourd <91231822+gaoachao@users.noreply.github.com>
Co-authored-by: Qingyu Wang <40660121+colinaaa@users.noreply.github.com>
Signed-off-by: BitterGourd <91231822+gaoachao@users.noreply.github.com>
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.

Are we going to support an object for output.inlineScripts (maybe in next PRs)? Since Rsbuild supports that:

type InlineScriptsTest =
  | RegExp
  | ((params: { size: number; name: string }) => boolean);

type InlineScripts =
  | boolean
  | InlineScriptsTest
  | {
      enable?: boolean | 'auto';
      test: InlineScriptsTest;
    };

If we are going to do so, I think we should not close #870 in this PR, yet.

@gaoachao gaoachao requested a review from colinaaa May 21, 2025 12:34
@gaoachao gaoachao added this pull request to the merge queue May 21, 2025
Merged via the queue into main with commit 7beb35e May 21, 2025
37 of 38 checks passed
@gaoachao gaoachao deleted the feat/support-output-inline-scripts branch May 21, 2025 13:22
colinaaa pushed a commit that referenced this pull request May 24, 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/react@0.109.0

### Minor Changes

- Support MTS functions running on the first screen.
([#840](#840))

### Patch Changes

- Fix type error when using `Suspense` with `"jsx": "react-jsx"`.
([#854](#854))

- Support lazy bundle in ReactLynx testing library.
([#869](#869))

- Fix a bug in HMR that snapshots are always updated because the same
unique ID check is not performed correctly.
([#869](#869))

- Fix missing types of `key` on components when using `"jsx":
"react-jsx"`.
([#872](#872))

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

### Minor Changes

- **BREAKING CHANGE**: Remove the unused `jsx` option.
([#903](#903))

### Patch Changes

- Support `output.inlineScripts`, which controls whether to inline
scripts into Lynx bundle (`.lynx.bundle`).
([#874](#874))

Only background thread scripts can remain non-inlined, whereas the main
thread script is always inlined.

    example:

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

    export default defineConfig({
      output: {
        inlineScripts: false,
      },
    });
    ```

- Support `@lynx-js/react` v0.109.0.
([#840](#840))

- Use `WebEncodePlugin` instead of `WebWebpackPlugin`.
([#904](#904))

- Updated dependencies
\[[`7beb35e`](7beb35e),
[`b6e27da`](b6e27da),
[`5ddec12`](5ddec12),
[`77524bc`](77524bc),
[`fdab5dc`](fdab5dc),
[`ff63b58`](ff63b58),
[`fdab5dc`](fdab5dc),
[`2b83934`](2b83934),
[`3520031`](3520031)]:
    -   @lynx-js/template-webpack-plugin@0.7.0
    -   @lynx-js/css-extract-webpack-plugin@0.5.4
    -   @lynx-js/react-refresh-webpack-plugin@0.3.3
    -   @lynx-js/react-webpack-plugin@0.6.14
    -   @lynx-js/react-alias-rsbuild-plugin@0.10.0

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

### Minor Changes

- Rename `lepus` to `mainThreadAssets` in `beforeEmit` hook.
([#901](#901))

- Remove the unused `encodeBinary` option of `LynxEncodePlugin`.
([#880](#880))

### Patch Changes

- Support `output.inlineScripts`, which controls whether to inline
scripts into Lynx bundle (`.lynx.bundle`).
([#874](#874))

Only background thread scripts can remain non-inlined, whereas the main
thread script is always inlined.

    example:

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

    export default defineConfig({
      output: {
        inlineScripts: false,
      },
    });
    ```

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- Add `WebEncodePlugin`.
([#904](#904))

This is previously known as `WebWebpackPlugin` from
`@lynx-js/web-webpack-plugin`.

- Fix a bug that the `lepus` arg of `beforeEmit` hook does not contains
the `root` main chunk of the main thread.
([#898](#898))

## @lynx-js/rspeedy@0.9.6

### Patch Changes

- Support `output.inlineScripts`, which controls whether to inline
scripts into Lynx bundle (`.lynx.bundle`).
([#874](#874))

Only background thread scripts can remain non-inlined, whereas the main
thread script is always inlined.

    example:

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

    export default defineConfig({
      output: {
        inlineScripts: false,
      },
    });
    ```

- Bump Rsbuild v1.3.21 with Rspack v1.3.11.
([#863](#863))

- Updated dependencies
\[[`5b67bde`](5b67bde)]:
    -   @lynx-js/chunk-loading-webpack-plugin@0.2.1

## @lynx-js/offscreen-document@0.0.4

### Patch Changes

- fix: remove all children after the innerHTML setter is called
([#850](#850))

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- perf: improve dom operation performance
([#881](#881))

    -   code clean for offscreen-document, cut down inheritance levels
- add `appendChild` method for OffscreenElement, improve performance for
append one node
    -   bypass some JS getter for dumping SSR string

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

### Patch Changes

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

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

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

### Patch Changes

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- perf: improve dom operation performance
([#881](#881))

    -   code clean for offscreen-document, cut down inheritance levels
- add `appendChild` method for OffscreenElement, improve performance for
append one node
    -   bypass some JS getter for dumping SSR string

- fix: worker not released when backgroundWorkerContextCount != 1
([#845](#845))

- Updated dependencies
\[[`bb1f9d8`](bb1f9d8),
[`b6e27da`](b6e27da),
[`3d716d7`](3d716d7)]:
    -   @lynx-js/offscreen-document@0.0.4
    -   @lynx-js/web-mainthread-apis@0.13.3
    -   @lynx-js/web-worker-runtime@0.13.3
    -   @lynx-js/web-constants@0.13.3
    -   @lynx-js/web-worker-rpc@0.13.3

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

### Patch Changes

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- feat: support to dump ssrEncode string
([#876](#876))

- perf: improve dom operation performance
([#881](#881))

    -   code clean for offscreen-document, cut down inheritance levels
- add `appendChild` method for OffscreenElement, improve performance for
append one node
    -   bypass some JS getter for dumping SSR string

- feat: dump dehydrate string with shadow root template
([#838](#838))

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

### Patch Changes

- refactor: allow elements to be rendered before :defined
([#855](#855))

Before this commit, we don't allow developers to render these elements
before they're defined.

    In this commit, we will remove these restrictions.

- fix: remove the style `contain: content` of x-foldview-ng, otherwise
it will cause the `position: fixed` elements to be positioned
incorrectly after scrolling.
([#878](#878))

- fix: x-list should observe property list-type change.
([#862](#862))

    Before this commit, list-type only works when it was first assigned.

use `requestAnimationFrame` instead of `queueMicrotask` to
layoutListItem, this is because it may cause crashes in webkit.

- fix: list-item should support linear layout.
([#859](#859))

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

## @lynx-js/web-explorer@0.0.9

### Patch Changes

- chore: update dependencies:
([#868](#868))

    -   @lynx-js/web-elements@0.7.2
    -   @lynx-js/web-core@0.13.2

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

### Patch Changes

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- perf: improve dom operation performance
([#881](#881))

    -   code clean for offscreen-document, cut down inheritance levels
- add `appendChild` method for OffscreenElement, improve performance for
append one node
    -   bypass some JS getter for dumping SSR string

- Updated dependencies
\[[`b6e27da`](b6e27da)]:
    -   @lynx-js/web-constants@0.13.3

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

### Patch Changes

- refactor: code clean
([#897](#897))

    rename many internal apis to make logic be clear:

multi-thread: startMainWorker -> prepareMainThreadAPIs ->
startMainThread -> createMainThreadContext(new MainThreadRuntime)
all-on-ui: prepareMainThreadAPIs -> startMainThread ->
createMainThreadContext(new MainThreadRuntime)

- Updated dependencies
\[[`bb1f9d8`](bb1f9d8),
[`b6e27da`](b6e27da),
[`3d716d7`](3d716d7)]:
    -   @lynx-js/offscreen-document@0.0.4
    -   @lynx-js/web-mainthread-apis@0.13.3
    -   @lynx-js/web-constants@0.13.3
    -   @lynx-js/web-worker-rpc@0.13.3

## @lynx-js/chunk-loading-webpack-plugin@0.2.1

### Patch Changes

- Add `StartupChunkDependenciesRuntimeModule` to fix
`RuntimeGlobals.ensureChunkHandler` not found when using chunk splitting
([#798](#798))

## @lynx-js/css-extract-webpack-plugin@0.5.4

### Patch Changes

- Support `@lynx-js/template-webpack-plugin` v0.7.0.
([#880](#880))

- Support Rspack v1.3.11.
([#866](#866))

## @lynx-js/react-refresh-webpack-plugin@0.3.3

### Patch Changes

- Support `@lynx-js/template-webpack-plugin` v0.7.0.
([#880](#880))

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

### Patch Changes

- Support `@lynx-js/template-webpack-plugin` v0.7.0.
([#880](#880))

- Support `@lynx-js/react` v0.109.0.
([#840](#840))

## create-rspeedy@0.9.6



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



## upgrade-rspeedy@0.9.6



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



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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
colinaaa added a commit that referenced this pull request May 26, 2025
…910)

## Summary

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

Fix a regression of #874.

We should set `output.inlineScripts` to Rsbuild, so that:

- The default value of `environment.config.output.inlineScripts` could
be `true`
- The `output.inlineScripts` could be set in `lynx.config.js`

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

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
colinaaa added a commit to colinaaa/lynx-stack that referenced this pull request May 26, 2025
…ynx-family#910)

## Summary

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

Fix a regression of lynx-family#874.

We should set `output.inlineScripts` to Rsbuild, so that:

- The default value of `environment.config.output.inlineScripts` could
be `true`
- The `output.inlineScripts` could be set in `lynx.config.js`

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

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
colinaaa added a commit that referenced this pull request May 26, 2025
…915)

## Summary

This is a cherry-pick of #910 to `release/rspeedy-0-9-7`.

Fix a regression of #874.

We should set `output.inlineScripts` to Rsbuild, so that:

- The default value of `environment.config.output.inlineScripts` could
be `true`
- The `output.inlineScripts` could be set in `lynx.config.js`

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

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
github-merge-queue bot pushed a commit that referenced this pull request May 26, 2025
….6 (#914)

## Summary

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

Fix a regression of #874.

The `@lynx-js/react-rsbuild-plugin` should be compatible with
`@lynx-js/rspeedy` <= 0.9.6, where the default value of
`output.inlineScripts` is `undefined`.

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

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
colinaaa pushed a commit that referenced this pull request May 26, 2025
….6 (#923)

<!--
  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. -->

This is a cherry-pick of
#914 to
release/rspeedy-0-9-7.

Fix a regression of #874.

The @lynx-js/react-rsbuild-plugin should be compatible with
@lynx-js/rspeedy <= 0.9.6, where the default value of
output.inlineScripts is undefined.

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
@gaoachao gaoachao mentioned this pull request May 27, 2025
2 tasks
github-merge-queue bot pushed a commit that referenced this pull request Jun 27, 2025
<!--
  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. -->
follow up #874
close #870

Align `output.inlineScripts` with Rsbuild

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

type InlineChunkTest = RegExp | InlineChunkTestFunction;

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

Related links:
- https://rsbuild.dev/config/output/inline-scripts#outputinlinescripts

## Checklist

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

- [x] Tests updated (or not required).
- [x] Documentation updated (or not required).

---------

Signed-off-by: BitterGourd <91231822+gaoachao@users.noreply.github.com>
Co-authored-by: Qingyu Wang <40660121+colinaaa@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.

3 participants