Skip to content

feat: initial commit for web-core-server#772

Merged
PupilTong merged 6 commits intolynx-family:mainfrom
PupilTong:p/hw/ssr-initial-commit
May 12, 2025
Merged

feat: initial commit for web-core-server#772
PupilTong merged 6 commits intolynx-family:mainfrom
PupilTong:p/hw/ssr-initial-commit

Conversation

@PupilTong
Copy link
Copy Markdown
Collaborator

web-core-server is the server-side package for web-core

It's mainly designed for SSR. We'll consider the server-side bts in the future.

#52

web-core-server is the server-side package for web-core

It's mainly designed for SSR. We'll consider the server-side bts in the future.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented May 12, 2025

🦋 Changeset detected

Latest commit: 0e3f903

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/web-worker-runtime Patch
@lynx-js/offscreen-document Patch
@lynx-js/web-core Patch
@lynx-js/web-constants Patch
@lynx-js/web-mainthread-apis Patch
@lynx-js/web-worker-rpc 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 12, 2025

Bundle Report

Changes will increase total bundle size by 3.69kB (0.58%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@lynx-js/web-explorer-web-array-push 320.62kB 341 bytes (0.11%) ⬆️
@lynx-js/example-react-lynx-cjs 321.14kB 3.35kB (1.05%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: @lynx-js/example-react-lynx-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
main.lynx.bundle 1.74kB 89.87kB 1.97%
.rspeedy/main/main-thread.js 744 bytes 40.8kB 1.86%
.rspeedy/main/background.*.js 864 bytes 39.91kB 2.21%
view changes for bundle: @lynx-js/web-explorer-web-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/js/async/45.js 341 bytes 58.43kB 0.59%

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented May 12, 2025

CodSpeed Performance Report

Merging #772 will not alter performance

Comparing PupilTong:p/hw/ssr-initial-commit (0e3f903) with main (088e057)

Summary

✅ 1 untouched benchmarks
🆕 1 new benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
🆕 basic-performance-div-10000 N/A 1.3 s N/A

@codecov
Copy link
Copy Markdown

codecov bot commented May 12, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2654 2 2652 46
View the top 2 failed test(s) by shortest run time
packages/webpack/css-extract-webpack-plugin/test/cases.test.ts > css-extract > css-extract/esm/css-id-module-concatenation > css-extract/esm/css-id-module-concatenation > css-extract/esm/css-id-module-concatenation - rspack > css-extract/esm/css-id-module-concatenation - rspack should run sync
Stack Traces | 0.00241s run time
Error: ENOENT: no such file or directory, open '.../esm/css-id-module-concatenation/rspack.bundle.js'RspeedyNormalRunner.getFile ../../../node_modules/.pnpm/@rspack+test-tools@1.3.9_@rspack+core@1.3.9_@swc+helpers@0.5.17_/node_modules/@.../runner/runner/basic.js:83:44
 ❯ ../../../node_modules/.pnpm/@rspack+test-tools@1.3.9_@rspack+core@1.3.9_@swc+helpers@0.5.17_/node_modules/@.../runner/runner/esm.js:52:31
 ❯ ../../../node_modules/.pnpm/@rspack+test-tools@1.3.9_@rspack+core@1.3.9_@swc+helpers@0.5.17_/node_modules/@.../runner/runner/basic.js:56:20RspeedyNormalRunner.run ../../../node_modules/.pnpm/@rspack+test-tools@1.3.9_@rspack+core@1.3.9_@swc+helpers@0.5.17_/node_modules/@.../runner/runner/basic.js:44:38
RspeedyNormalRunner.run ...../test-tools/src/suite.ts:188:29NormalProcessor.run ../../../node_modules/.pnpm/@rspack+test-tools@1.3.9_@rspack+core@1.3.9_@swc+helpers@0.5.17_/node_modules/@.../dist/processor/basic.js:78:32
 ❯ ...../test-tools/src/suite.ts:131:28

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'open', path: '.../esm/css-id-module-concatenation/rspack.bundle.js' }
packages/webpack/css-extract-webpack-plugin/test/cases.test.ts > css-extract > css-extract/esm/css-id-module-concatenation > css-extract/esm/css-id-module-concatenation > css-extract/esm/css-id-module-concatenation - rspack > should compile
Stack Traces | 50s run time
Error: Test timed out in 50000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
 ❯ run ...../test-tools/src/suite.ts:118:5
 ❯ ...../test-tools/src/case.ts:77:9

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@PupilTong PupilTong requested review from Sherry-hue and colinaaa May 12, 2025 09:39
@PupilTong PupilTong marked this pull request as ready for review May 12, 2025 09:39
@PupilTong PupilTong requested a review from Copilot May 12, 2025 11:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the initial implementation of the web-core-server package that supports SSR through leveraging web workers and establishes testing and benchmarking configurations for the web platform.

  • Updated the web-worker-runtime to use globalThis for event handling.
  • Added several testing configurations (Vitest, Playwright, benchmark workflows) and package references for integration.
  • Introduced the web-core-server package with template loading, main thread polyfills, and SSR view creation.

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/web-platform/web-worker-runtime/src/index.ts Changed the event handling from self.onmessage to globalThis.onmessage.
packages/web-platform/web-tests/vitest.config.ts Configured Vitest with custom inclusion, exclusion, and benchmark settings.
packages/web-platform/web-tests/tsconfig.json Added project references for improved project structure and dependency management.
packages/web-platform/web-tests/tests/* Added test files for server rendering and benchmarks.
packages/web-platform/web-core-server/* Introduced the main package implementation for SSR with helper utilities and polyfills.
packages/web-platform/offscreen-document/* Exported and refactored symbols to support innerHTML extraction.
.github/workflows/workflow-bench.yml Tweaked benchmark workflow command to include workspace concurrency.

@PupilTong PupilTong added this pull request to the merge queue May 12, 2025
Merged via the queue into lynx-family:main with commit 6d3d852 May 12, 2025
37 checks passed
@PupilTong PupilTong deleted the p/hw/ssr-initial-commit branch May 12, 2025 14:12
colinaaa pushed a commit that referenced this pull request May 16, 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/runtime-wrapper-webpack-plugin@0.1.0

### Minor Changes

- Add parameter forwarding for Browser Object Model (BOM) APIs.
([#787](#787))

This allows direct access to APIs like `fetch`, `requestAnimationFrame`.

## @lynx-js/react@0.108.1

### Patch Changes

- Bump swc_core v23.2.0.
([#827](#827))

## @lynx-js/rspeedy@0.9.5

### Patch Changes

- Support `source.preEntry`.
([#750](#750))

Add a script before the entry file of each page. This script will be
executed before the page code.
It can be used to execute global logics, such as injecting polyfills,
setting global styles, etc.

    example:

    ```js
    import { defineConfig } from "@lynx-js/rspeedy";
    export default defineConfig({
      source: {
        preEntry: "./src/polyfill.ts",
      },
    });
    ```

- Bump Rsbuild v1.3.20 with Rspack v1.3.10.
([#799](#799))

- Add `callerName` option to `createRspeedy`.
([#757](#757))

It can be accessed by Rsbuild plugins through
[`api.context.callerName`](https://rsbuild.dev/api/javascript-api/instance#contextcallername),
and execute different logic based on this identifier.

    ```js
    export const myPlugin = {
      name: "my-plugin",
      setup(api) {
        const { callerName } = api.context;

        if (callerName === "rslib") {
          // ...
        } else if (callerName === "rspeedy") {
          // ...
        }
      },
    };
    ```

- Support `performance.buildCache`.
([#766](#766))

- Updated dependencies
\[[`fbc4fbb`](fbc4fbb)]:
    -   @lynx-js/webpack-dev-transport@0.1.3

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

### Patch Changes

- Updated dependencies
\[[`e599635`](e599635),
[`c38c737`](c38c737),
[`d16522e`](d16522e)]:
    -   @lynx-js/template-webpack-plugin@0.6.11
    -   @lynx-js/web-webpack-plugin@0.6.7
    -   @lynx-js/runtime-wrapper-webpack-plugin@0.1.0
    -   @lynx-js/react-alias-rsbuild-plugin@0.9.10
    -   @lynx-js/react-refresh-webpack-plugin@0.3.2
    -   @lynx-js/react-webpack-plugin@0.6.13
    -   @lynx-js/css-extract-webpack-plugin@0.5.3

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

### Patch Changes

- feat: support OffscreenDocument.innerHTML
([#772](#772))

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

### Patch Changes

- fix: corrupt mainthread module cache
([#806](#806))

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

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

### Patch Changes

- feat: allow lynx code to get JS engine provided properties on
globalThis ([#786](#786))

        globalThis.Reflect; // this will be the Reflect Object

    Note that `assigning to the globalThis` is still not allowed.

- perf: use v8 hint for generated javascript file
([#807](#807))

    <https://v8.dev/blog/explicit-compile-hints>

- feat: add new property `inject-style-rules` for LynxView
([#785](#785))

This property allows developer to inject some style rules into the
shadowroot.

It's a wrapper of
<https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/insertRule>

- fix: corrupt mainthread module cache
([#806](#806))

- Updated dependencies
\[[`03a5f64`](03a5f64),
[`6d3d852`](6d3d852),
[`8cdd288`](8cdd288),
[`6d3d852`](6d3d852)]:
    -   @lynx-js/web-mainthread-apis@0.13.2
    -   @lynx-js/web-worker-runtime@0.13.2
    -   @lynx-js/web-constants@0.13.2
    -   @lynx-js/offscreen-document@0.0.3
    -   @lynx-js/web-worker-rpc@0.13.2

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

### Patch Changes

- perf: use v8 hint for generated javascript file
([#807](#807))

    <https://v8.dev/blog/explicit-compile-hints>

- fix: corrupt mainthread module cache
([#806](#806))

- feat: improve template js loading
([#807](#807))

now we will create temp js file based on the new `templateName`
argument.

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

### Patch Changes

- refactor: split shadowroot templates into a package
([#811](#811))

We're going to implement Lynx Web Platform's SSR based on the
`shadowrootmode`.


`https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/shadowRootMode`

    (chrome 111, firefox 123, safari 16.4)

This means those modern browsers are able to show the correct layout
before the web components are defined.

To make this work, we have to split the shadowroot template string into
a new package `@lynx-js/web-elements-template`.

    No features affected.

- Updated dependencies
\[[`ae9652a`](ae9652a),
[`ae9652a`](ae9652a)]:
    -   @lynx-js/web-elements-template@0.7.2
    -   @lynx-js/web-elements-reactive@0.2.2

## @lynx-js/web-elements-reactive@0.2.2

### Patch Changes

- feat: do not create shadowroot if there already have one
([#811](#811))

    the shadowroot may already be created by


<https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/shadowRootMode>

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

### Patch Changes

- refactor: split shadowroot templates into a package
([#811](#811))

We're going to implement Lynx Web Platform's SSR based on the
`shadowrootmode`.


`https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement/shadowRootMode`

    (chrome 111, firefox 123, safari 16.4)

This means those modern browsers are able to show the correct layout
before the web components are defined.

To make this work, we have to split the shadowroot template string into
a new package `@lynx-js/web-elements-template`.

    No features affected.

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

### Patch Changes

- chore: import qr-scanner from unpkg
([#815](#815))

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

### Patch Changes

- feat: allow lynx code to get JS engine provided properties on
globalThis ([#786](#786))

        globalThis.Reflect; // this will be the Reflect Object

    Note that `assigning to the globalThis` is still not allowed.

- fix: corrupt mainthread module cache
([#806](#806))

- Updated dependencies
\[[`8cdd288`](8cdd288)]:
    -   @lynx-js/web-constants@0.13.2

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

### Patch Changes

- feat: allow lynx code to get JS engine provided properties on
globalThis ([#786](#786))

        globalThis.Reflect; // this will be the Reflect Object

    Note that `assigning to the globalThis` is still not allowed.

- feat: return the offscreenDocument instance for startMainThread()
([#772](#772))

- Updated dependencies
\[[`03a5f64`](03a5f64),
[`8cdd288`](8cdd288),
[`6d3d852`](6d3d852)]:
    -   @lynx-js/web-mainthread-apis@0.13.2
    -   @lynx-js/web-constants@0.13.2
    -   @lynx-js/offscreen-document@0.0.3
    -   @lynx-js/web-worker-rpc@0.13.2

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

### Patch Changes

- Be compatible with rspack-manifest-plugin.
([#812](#812))

Now only the `[name].lynx.bundle` and `[name].web.bundle` would exist in
`manifest.json`.

See
[#763](#763)
for details.

- Avoid CSS encode crash on Web platform.
([#814](#814))

## @lynx-js/web-webpack-plugin@0.6.7

### Patch Changes

- Be compatible with rspack-manifest-plugin.
([#812](#812))

Now only the `[name].lynx.bundle` and `[name].web.bundle` would exist in
`manifest.json`.

See
[#763](#763)
for details.

## @lynx-js/webpack-dev-transport@0.1.3

### Patch Changes

- Fix live-reload not working on Lynx 3.3
([#795](#795))

## create-rspeedy@0.9.5



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



## upgrade-rspeedy@0.9.5



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

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants