feat: polyfill lynx.requireModuleAsync to allow cache same parallel requests#2108
feat: polyfill lynx.requireModuleAsync to allow cache same parallel requests#2108
lynx.requireModuleAsync to allow cache same parallel requests#2108Conversation
🦋 Changeset detectedLatest commit: 12a75f2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
📝 WalkthroughWalkthroughA changeset entry and polyfill implementation for caching consecutive module loads in lynx.requireModuleAsync are introduced. The polyfill is integrated into the app-service script generation, with comprehensive tests verifying caching behavior and syntax validity. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4431929 to
134f666
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging this PR will degrade performance by 5.51%Comparing Summary
Performance Changes
Footnotes
|
Web Explorer#7173 Bundle Size — 383.59KiB (0%).12a75f2(current) vs 9de99b0 main#7166(baseline) Bundle metrics
Bundle size by type
|
| Current #7173 |
Baseline #7166 |
|
|---|---|---|
251.56KiB |
251.56KiB |
|
96.98KiB |
96.98KiB |
|
35.05KiB |
35.05KiB |
Bundle analysis report Branch feat/requireModuleAsyncCache Project dashboard
Generated by RelativeCI Documentation Report issue
134f666 to
4f78262
Compare
lynx.requireModuleAsync to allow cache same parallel requests
4f78262 to
197cf7b
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.js (1)
34-37: Nestedit()block is invalid test structure.Same issue as in
inline-object/index.js— this innerit()is nested inside the outerit()starting at line 15 and will not execute properly.🐛 Proposed fix: inline the eval without nested it
- it('inlined scripts should not have syntax error', () => { - eval(manifest['/app-service.js']); - eval(manifest['/foo.js']); - }); + // Verify inlined scripts have no syntax errors + eval(manifest['/app-service.js']); + eval(manifest['/foo.js']);
🤖 Fix all issues with AI agents
In
`@packages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.js`:
- Around line 54-56: The nested it() inside the existing test is invalid; remove
the inner it('inlined scripts should not have syntax error', ...) wrapper and
move the eval(manifest['/app-service.js']); call directly into the outer test
body (the outer it that currently contains the nested it), so the eval runs as
part of the existing test rather than as a nested test.
In
`@packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.js`:
- Around line 71-73: The nested it('inlined scripts should not have syntax
error') inside the outer it('should generate correct bar template') must be
removed; instead, inline the assertion in the outer test or move it to a new
top-level test. Replace the inner it block with a direct assertion such as
expect(() => eval(manifest['/app-service.js'])).not.toThrow() (or simply call
eval(manifest['/app-service.js']) directly) so the syntax-check runs during the
outer test, or extract that expect(...) into its own top-level it(...) with the
name 'inlined scripts should not have syntax error'.
In
`@packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.js`:
- Around line 71-73: The test contains a nested it() call inside another it()
which is invalid; remove the inner it('inlined scripts should not have syntax
error', ...) wrapper and instead execute eval(manifest['/app-service.js'])
directly inside the outer test (or lift the inner it block to a separate
top-level test); update the block referencing manifest['/app-service.js'] so the
eval is run inline rather than wrapped in a nested it().
In
`@packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.js`:
- Around line 71-73: The test contains a nested it() — specifically the inner
it('inlined scripts should not have syntax error') that calls
eval(manifest['/app-service.js']) is placed inside the outer it('should generate
correct bar template') and will be ignored; fix by removing the nested it and
either inline the assertion (call eval(manifest['/app-service.js']) directly
inside the outer it) or move the inner it to be a sibling test at the top level
so that eval(manifest['/app-service.js']) runs as its own test.
In
`@packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.js`:
- Around line 43-45: The test contains a nested it() call ("inlined scripts
should not have syntax error") inside the outer it("should generate correct foo
template"), which Vitest ignores; remove the inner it() wrapper and inline its
assertion into the outer test body by replacing the nested block with a direct
call to eval(manifest['/app-service.js']); so the syntax check runs as part of
the "should generate correct foo template" test.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/src/LynxEncodePlugin.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.tspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.js
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{js,ts,tsx}: Follow eslint rules as configured in eslint.config.js including React and TypeScript specific rules
Follow code formatting rules specified in .dprint.jsonc and biome.jsonc
Files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.jspackages/webpack/template-webpack-plugin/src/LynxEncodePlugin.tspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with the configuration specified in tsconfig.json
Files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.tspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
🧠 Learnings (31)
📓 Common learnings
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/template-webpack-plugin/src/LynxCacheEventsSetupListRuntimeModule.ts:21-25
Timestamp: 2025-08-19T12:49:05.875Z
Learning: In the Lynx cache events system, there are two separate runtime modules with distinct responsibilities: `LynxCacheEventsSetupListRuntimeModule` is only responsible for initializing the setup list with the setup functions, while `LynxCacheEventsRuntimeModule` guarantees the initialization of `loaded` and `cachedActions` properties. The modules have a dependency relationship where `lynxCacheEventsSetupList` is required by `lynxCacheEvents`.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1834
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createChunkLoading.ts:162-171
Timestamp: 2025-09-25T14:03:25.576Z
Learning: In the lynx-stack codebase, for loadScriptAsync implementations in createChunkLoading.ts, unhandled promise rejections from readScriptAsync are intentionally not caught - the caller is expected to handle errors rather than the loadScriptAsync method itself invoking the callback with error messages.
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/rspeedy/plugin-react/src/entry.ts:237-240
Timestamp: 2025-08-12T09:32:01.512Z
Learning: The events-cache.js functionality for caching events until background threads are ready is manually tested due to the complexity of constructing automated runtime test cases that involve timing, chunk loading, and browser runtime behavior.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.
📚 Learning: 2025-08-27T12:42:01.095Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1616
File: packages/webpack/cache-events-webpack-plugin/test/cases/not-cache-events/lazy-bundle/index.js:3-3
Timestamp: 2025-08-27T12:42:01.095Z
Learning: In webpack, properties like __webpack_require__.lynx_ce are injected during compilation/build time when webpack processes modules and generates bundles, not at runtime when dynamic imports execute. Tests for such properties don't need to wait for dynamic imports to complete.
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.jspackages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Use Playwright for all E2E and functional tests with standard assertions like `expect(locator).toBeVisible()`, `expect(locator).toHaveCSS()`, and `diffScreenShot` for screenshot comparisons
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.jspackages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : When a component makes external requests (e.g., via `iframe` or `fetch`), mock them using `page.route` in Playwright tests to ensure tests are hermetic and fast
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-08-21T08:46:54.494Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/cache-events-webpack-plugin/src/LynxCacheEventsRuntimeModule.ts:23-27
Timestamp: 2025-08-21T08:46:54.494Z
Learning: In Lynx webpack runtime modules, the team prioritizes performance and simplicity over defensive runtime error handling. They prefer relying on compile-time type safety (TypeScript) rather than adding runtime checks like try-catch blocks or type validation, especially for performance-critical code like cache event setup/cleanup functions.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, private packages (marked with "private": true in package.json) like lynx-js/react-transform don't require meaningful changeset entries even when their public APIs change, since they are not published externally and only affect internal development.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-11-06T01:19:23.670Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1917
File: packages/mcp-servers/devtool-mcp-server/tsconfig.json:8-8
Timestamp: 2025-11-06T01:19:23.670Z
Learning: The lynx-js/devtool-mcp-server package in lynx-family/lynx-stack targets Node.js >=18.19 (specified in its package.json engines), which is different from the root project's requirement of Node.js ^22 || ^24. The package uses "lib": ["ES2024.Promise"] in its tsconfig.json because it manually includes polyfills for Promise.withResolvers while maintaining compatibility with Node.js v18.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-08-07T04:00:59.645Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1454
File: pnpm-workspace.yaml:46-46
Timestamp: 2025-08-07T04:00:59.645Z
Learning: In the lynx-family/lynx-stack repository, the webpack patch (patches/webpack5.101.0.patch) was created to fix issues with webpack5.99.9 but only takes effect on webpack5.100.0 and later versions. The patchedDependencies entry should use "webpack@^5.100.0" to ensure the patch applies to the correct version range.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Applies to packages/react/components/**/*.{ts,tsx} : Optimize component library in packages/react/components/ using ReactLynx syntax
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-08-13T11:46:43.737Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:5-6
Timestamp: 2025-08-13T11:46:43.737Z
Learning: In the lynx-stack codebase, default imports are consistently used for Node.js built-in modules (e.g., `import os from 'node:os'`, `import fs from 'node:fs'`). The TypeScript configuration supports esModuleInterop and allowSyntheticDefaultImports, making default imports the preferred pattern over namespace imports for Node.js built-ins.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-09-18T04:43:54.426Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1771
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_component_with_static_sibling.js:2-2
Timestamp: 2025-09-18T04:43:54.426Z
Learning: In the lynx-family/lynx-stack repository, the `add_pure_comment` function in packages/react/transform/src/swc_plugin_compat/mod.rs (around lines 478-482) is specifically for `wrapWithLynxComponent` calls, not `createSnapshot` calls. The PURE comment injection for `createSnapshot` is handled separately in swc_plugin_snapshot/mod.rs.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts
📚 Learning: 2025-08-12T16:09:32.413Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1497
File: packages/react/transform/tests/__swc_snapshots__/src/swc_plugin_snapshot/mod.rs/basic_full_static.js:9-10
Timestamp: 2025-08-12T16:09:32.413Z
Learning: In the Lynx stack, functions prefixed with `__` that are called in transformed code may be injected globally by the Lynx Engine at runtime rather than exported from the React runtime package. For example, `__CreateFrame` is injected globally by the Lynx Engine, not exported from lynx-js/react.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.tspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-08-13T11:36:12.075Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1523
File: vitest.config.ts:52-72
Timestamp: 2025-08-13T11:36:12.075Z
Learning: The lynx-stack project requires Node.js >=22 as specified in package.json engines, so Node.js compatibility fallbacks for features introduced before v22 are unnecessary.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-09-25T14:03:25.576Z
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1834
File: packages/web-platform/web-worker-runtime/src/backgroundThread/background-apis/createChunkLoading.ts:162-171
Timestamp: 2025-09-25T14:03:25.576Z
Learning: In the lynx-stack codebase, for loadScriptAsync implementations in createChunkLoading.ts, unhandled promise rejections from readScriptAsync are intentionally not caught - the caller is expected to handle errors rather than the loadScriptAsync method itself invoking the callback with error messages.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts.changeset/silent-actors-marry.mdpackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-08-27T08:10:09.932Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1612
File: packages/rspeedy/create-rspeedy/template-react-vitest-rltl-ts/src/tsconfig.json:3-13
Timestamp: 2025-08-27T08:10:09.932Z
Learning: In the lynx-family/lynx-stack repository, Rspeedy templates use `lynx-js/rspeedy/client` types via `rspeedy-env.d.ts` instead of `vite/client` types. Rspeedy provides its own client-side environment type definitions and doesn't require direct Vite type references.
Applied to files:
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts
📚 Learning: 2025-09-12T09:43:04.847Z
Learnt from: gaoachao
Repo: lynx-family/lynx-stack PR: 1736
File: .changeset/spotty-experts-smoke.md:1-3
Timestamp: 2025-09-12T09:43:04.847Z
Learning: In the lynx-family/lynx-stack repository, empty changeset files (containing only `---\n\n---`) are used for internal changes that modify src/** files but don't require meaningful release notes, such as private package changes or testing-only modifications. This satisfies CI requirements without generating user-facing release notes.
Applied to files:
.changeset/silent-actors-marry.md
📚 Learning: 2025-07-22T09:26:16.722Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:26:16.722Z
Learning: In the lynx-family/lynx-stack repository, CI checks require changesets when files matching the pattern "src/**" are modified (as configured in .changeset/config.json). For internal changes that don't need meaningful changesets, an empty changeset file is used to satisfy the CI requirement while not generating any release notes.
Applied to files:
.changeset/silent-actors-marry.md
📚 Learning: 2025-07-22T09:23:07.797Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1330
File: .changeset/olive-animals-attend.md:1-3
Timestamp: 2025-07-22T09:23:07.797Z
Learning: In the lynx-family/lynx-stack repository, changesets are only required for meaningful changes to end-users such as bugfixes and features. Internal/development changes like chores, refactoring, or removing debug info do not need changeset entries.
Applied to files:
.changeset/silent-actors-marry.md
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Use changeset tool with `pnpm changeset` to document changes before contribution
Applied to files:
.changeset/silent-actors-marry.md
📚 Learning: 2025-09-23T08:53:56.927Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/src/loader.ts:244-251
Timestamp: 2025-09-23T08:53:56.927Z
Learning: In webpack CSS extraction plugins, when storing per-module dependencies in a compiler-scoped map like cssModuleId2Deps, the map should not be reset at compilation start because in incremental compilation (watch mode/HMR), only changed files pass through the loader. Unchanged modules need their dependency information to persist between compilations so the plugin can access all modules' dependencies when generating CSS output.
Applied to files:
.changeset/silent-actors-marry.md
📚 Learning: 2025-09-23T08:54:39.966Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1670
File: packages/webpack/css-extract-webpack-plugin/test/hotCases/hot/hot-update-json/dual-thread/__snapshot__/index.css:6-8
Timestamp: 2025-09-23T08:54:39.966Z
Learning: In the lynx-stack CSS extract webpack plugin tests, many test fixture CSS files intentionally use invalid CSS syntax like `color: 'red';` with quoted values. The snapshots correctly reflect this invalid CSS from the source fixtures. To fix CSS validation issues, the source fixture files should be updated first, then snapshots regenerated, rather than manually editing snapshots.
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.jspackages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Applies to packages/web-platform/web-tests/**/*.{ts,tsx,js} : Use Playwright for E2E tests in packages/web-platform/web-tests/
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.jspackages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.jspackages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-08-14T06:51:39.827Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts:160-171
Timestamp: 2025-08-14T06:51:39.827Z
Learning: In the LynxEncodePlugin for events-cache.js functionality, when iterating through entrypoints to find background scripts, any entry .js file that exists in the manifest is guaranteed to be the background.js needed by design. The manifest generation logic ensures only background scripts from entrypoints are included, making the simple "first .js file in manifest" selection approach correct and reliable.
Applied to files:
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.js
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/tests/**/*.spec.ts : Create a separate spec file for new components (e.g., `tests/x-webview.spec.ts`) instead of adding to the monolithic `web-elements.spec.ts`
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-10-29T10:28:27.519Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/lib.rs/should_static_extract_dynamic_inline_style.js:20-24
Timestamp: 2025-10-29T10:28:27.519Z
Learning: Files inside packages/react/transform/crates/swc_plugin_snapshot/tests/__swc_snapshots__/ are auto-generated test snapshot files and should not be manually updated. Any issues with the generated code should be addressed in the code generator/transform logic, not in the snapshots themselves.
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Applies to **/__test__/**/*.{ts,tsx,js} : Use vitest-based unit tests as configured in vitest.config.ts
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-12-29T11:26:09.502Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: packages/web-platform/web-elements/AGENTS.md:0-0
Timestamp: 2025-12-29T11:26:09.502Z
Learning: Applies to packages/web-platform/web-elements/src/elements/all.ts : Export new components in `src/elements/all.ts` and add export configuration to `package.json` under `exports` for both types and default
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-12-26T05:10:01.608Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-26T05:10:01.608Z
Learning: Applies to packages/rspeedy/plugin-*/**/*.{ts,tsx,js} : Configure build plugins using the plugin architecture in packages/rspeedy/plugin-*/
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-08-19T12:49:05.875Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/webpack/template-webpack-plugin/src/LynxCacheEventsSetupListRuntimeModule.ts:21-25
Timestamp: 2025-08-19T12:49:05.875Z
Learning: In the Lynx cache events system, there are two separate runtime modules with distinct responsibilities: `LynxCacheEventsSetupListRuntimeModule` is only responsible for initializing the setup list with the setup functions, while `LynxCacheEventsRuntimeModule` guarantees the initialization of `loaded` and `cachedActions` properties. The modules have a dependency relationship where `lynxCacheEventsSetupList` is required by `lynxCacheEvents`.
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.tspackages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts
📚 Learning: 2025-08-12T09:32:01.512Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: packages/rspeedy/plugin-react/src/entry.ts:237-240
Timestamp: 2025-08-12T09:32:01.512Z
Learning: The events-cache.js functionality for caching events until background threads are ready is manually tested due to the complexity of constructing automated runtime test cases that involve timing, chunk loading, and browser runtime behavior.
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
📚 Learning: 2025-08-11T05:57:18.212Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/testing-library/testing-environment/src/index.ts:255-258
Timestamp: 2025-08-11T05:57:18.212Z
Learning: In the ReactLynx testing environment (`packages/testing-library/testing-environment/src/index.ts`), the dual assignment pattern `target.console.method = console.method = () => {}` is required for rstest compatibility. This is because rstest provides `console` in an IIFE (Immediately Invoked Function Expression), and both the target and global console need to have these methods defined for proper test execution.
Applied to files:
packages/webpack/template-webpack-plugin/test/basic.test.ts
🧬 Code graph analysis (3)
packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts (1)
packages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts (1)
getRequireModuleAsyncCachePolyfill(19-51)
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.js (1)
packages/web-platform/playwright-fixtures/src/coverage-fixture.ts (1)
expect(76-76)
packages/webpack/template-webpack-plugin/test/basic.test.ts (1)
packages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts (1)
getRequireModuleAsyncCachePolyfill(19-51)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build / Build (Windows)
- GitHub Check: build / Build (Ubuntu)
- GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (13)
packages/webpack/template-webpack-plugin/src/polyfill/requireModuleAsync.ts (1)
19-51: LGTM! Clean polyfill implementation.The caching logic correctly handles:
- Immediate return for completed requests (status 2)
- Queuing callbacks for in-progress requests (status 1)
- Clearing callbacks after completion to prevent memory leaks
The use of
varis appropriate for runtime injection compatibility.packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.js (1)
63-64: Good assertion for polyfill presence.This correctly verifies that the requireModuleAsyncCache polyfill is injected into the app-service manifest.
.changeset/silent-actors-marry.md (1)
1-5: LGTM!Changeset is correctly formatted with an appropriate patch-level bump. The description accurately summarizes the new polyfill functionality.
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-partial/index.js (1)
28-29: Good assertion for polyfill presence.Correctly verifies the requireModuleAsyncCache polyfill is included in the manifest.
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.js (1)
43-44: Good assertion for polyfill presence.Correctly verifies the requireModuleAsyncCache polyfill is included when external assets are present.
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.js (1)
63-64: LGTM!The assertion correctly validates that the polyfill containing
moduleCacheinitialization is present in the generated app-service script.packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.js (1)
63-64: LGTM!Polyfill presence assertion is correctly added.
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.js (1)
33-36: LGTM!The assertion correctly validates that the polyfill is not present when there are no external assets (all chunks are inlined). This aligns with the logic in
LynxEncodePlugin.tsthat only injects the polyfill whenexternalKeys.length > 0.packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts (2)
8-8: LGTM!Import correctly added for the polyfill function.
256-258: LGTM!The polyfill is correctly injected only when there are external assets (
externalKeys.length > 0), and it's placed before therequireModuleAsynccalls to ensure the caching wrapper is in place before any module requests. The implementation aligns with the PR objective of caching identical parallel requests.packages/webpack/template-webpack-plugin/test/basic.test.ts (3)
10-10: LGTM!Import correctly added for the polyfill function to test it directly.
75-113: LGTM!The test setup creates a well-designed mock of
lynx.requireModuleAsyncthat:
- Simulates async module loading with
setTimeout- Tracks evaluation counts per module
- Includes both success and error test cases
The type assertion for the function with a
cacheproperty is a pragmatic approach for testing.
115-148: Comprehensive test coverage for the polyfill behavior.The tests correctly verify:
- Default behavior without polyfill (parallel calls trigger multiple evaluations)
- With polyfill applied, parallel calls for the same module only evaluate once
- Error handling propagates to all callbacks
One minor observation: the
setTimeout(resolve, 0)pattern relies on macrotask timing, which should work reliably for this simple case. If flakiness occurs in CI, consider usingvi.useFakeTimers()for deterministic timing control.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/external/index.js
Show resolved
Hide resolved
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-fn/index.js
Show resolved
Hide resolved
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-object/index.js
Show resolved
Hide resolved
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline-regex/index.js
Show resolved
Hide resolved
packages/webpack/template-webpack-plugin/test/cases/inline-scripts/inline/index.js
Show resolved
Hide resolved
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.116.0 ### Minor Changes - **BREAKING CHANGE**: Bump Preact from [10.24.0](preactjs/preact@1807173) to [10.28.0](preactjs/preact@f7693b7), see diffs at [hzy/preact#6](hzy/preact#6). ([#2042](#2042)) ### Patch Changes - Add safety checks for compilation macros to prevent runtime errors when they are undefined. ([#2110](#2110)) Replaces direct usage of `__PROFILE__`, `__MAIN_THREAD__`, `__BACKGROUND__` with `typeof` checks. This improves robustness by checking variable existence before access, preventing runtime errors in environments where compilation macros are not defined. ## @lynx-js/lynx-bundle-rslib-config@0.2.0 ### Minor Changes - Use `LAYERS` exposed by DSL plugins ([#2114](#2114)) ## @lynx-js/gesture-runtime@2.1.2 ### Patch Changes - Fix an issue that `NativeGesture` does not get correct types in callback ([#2130](#2130)) ## @lynx-js/rspeedy@0.13.1 ### Patch Changes - Updated dependencies \[]: - @lynx-js/web-rsbuild-server-middleware@0.19.6 ## @lynx-js/react-rsbuild-plugin@0.12.6 ### Patch Changes - Support using `pluginReactLynx` in Rslib. ([#2114](#2114)) - Updated dependencies \[[`4cd7182`](4cd7182)]: - @lynx-js/template-webpack-plugin@0.10.2 - @lynx-js/react-alias-rsbuild-plugin@0.12.6 - @lynx-js/use-sync-external-store@1.5.0 - @lynx-js/react-refresh-webpack-plugin@0.3.4 - @lynx-js/react-webpack-plugin@0.7.3 - @lynx-js/css-extract-webpack-plugin@0.7.0 ## upgrade-rspeedy@0.13.1 ### Patch Changes - Fix the issue `rslib-runtime.js` was not published in dist folder. ([#2122](#2122)) ## @lynx-js/testing-environment@0.1.10 ### Patch Changes - Fix the error "lynxTestingEnv is not defined" ([#2118](#2118)) ## @lynx-js/web-constants@0.19.6 ### Patch Changes - feat: add main-thread API: \_\_QuerySelector ([#2115](#2115)) - fix: when a list-item is deleted from list, the deleted list-item is still showed incorrectly. ([#1092](#1092)) This is because the `enqueueComponent` method does not delete the node from the Element Tree. It is only to maintain the display node on RL, and lynx web needs to delete the dom additionally. - feat: support main thread invoke ui method ([#2104](#2104)) - feat: support lynx.reload() ([#2127](#2127)) - Updated dependencies \[[`f7133c1`](f7133c1)]: - @lynx-js/web-worker-rpc@0.19.6 ## @lynx-js/web-core@0.19.6 ### Patch Changes - fix: avoid crash on CPUs that do not support SIMD ([#2133](#2133)) - feat: support lynx.reload() ([#2127](#2127)) - Updated dependencies \[[`179f984`](179f984), [`f7133c1`](f7133c1), [`6c2b51a`](6c2b51a), [`556fe9f`](556fe9f), [`5b589ab`](5b589ab)]: - @lynx-js/web-constants@0.19.6 - @lynx-js/web-mainthread-apis@0.19.6 - @lynx-js/web-worker-rpc@0.19.6 - @lynx-js/web-worker-runtime@0.19.6 ## @lynx-js/web-core-wasm@0.0.1 ### Patch Changes - Updated dependencies \[[`f7133c1`](f7133c1)]: - @lynx-js/web-worker-rpc@0.19.6 ## @lynx-js/web-mainthread-apis@0.19.6 ### Patch Changes - feat: add main-thread API: \_\_QuerySelector ([#2115](#2115)) - fix: when a list-item is deleted from list, the deleted list-item is still showed incorrectly. ([#1092](#1092)) This is because the `enqueueComponent` method does not delete the node from the Element Tree. It is only to maintain the display node on RL, and lynx web needs to delete the dom additionally. - feat: support main thread invoke ui method ([#2104](#2104)) - fix: mts && bts events can be binded both ([#2121](#2121)) - Updated dependencies \[[`179f984`](179f984), [`f7133c1`](f7133c1), [`6c2b51a`](6c2b51a), [`5b589ab`](5b589ab)]: - @lynx-js/web-constants@0.19.6 ## @lynx-js/web-worker-rpc@0.19.6 ### Patch Changes - fix: when a list-item is deleted from list, the deleted list-item is still showed incorrectly. ([#1092](#1092)) This is because the `enqueueComponent` method does not delete the node from the Element Tree. It is only to maintain the display node on RL, and lynx web needs to delete the dom additionally. ## @lynx-js/web-worker-runtime@0.19.6 ### Patch Changes - feat: support lynx.reload() ([#2127](#2127)) - Updated dependencies \[[`179f984`](179f984), [`f7133c1`](f7133c1), [`6c2b51a`](6c2b51a), [`556fe9f`](556fe9f), [`5b589ab`](5b589ab)]: - @lynx-js/web-constants@0.19.6 - @lynx-js/web-mainthread-apis@0.19.6 - @lynx-js/web-worker-rpc@0.19.6 ## @lynx-js/template-webpack-plugin@0.10.2 ### Patch Changes - Polyfill `lynx.requireModuleAsync` to allow cache same parallel requests. ([#2108](#2108)) ## create-rspeedy@0.13.1 ## @lynx-js/react-alias-rsbuild-plugin@0.12.6 ## @lynx-js/web-core-server@0.19.6 ## @lynx-js/web-rsbuild-server-middleware@0.19.6 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This is a polyfill for
lynx.requireModuleAsynctemporarily to make sure it can cache PARALLEL request. The final resolution is thatlynx.requireModuleAsyncshould support it by default.It is a very important feature for chunk splitting. Without this, the
lynx.requireModuleAsyncwill execute twice for the same request. For example, when chunk splitting is enabled, we will generate the following output:"/app-service.js":"/.rspeedy/main/background.js":In this example,
/app-service.jsand/.rspeedy/main/background.jswill both calllynx.requireModuleAsync(\"http://x.x.x.x:3000/static/js/lib-preact.js\"). Our original goal is to fetchlib-preact.jsas soon asapp-service.jsloads and reuse it in background.js, but as they are parallel andapp-service.jsdoes not finish its loading before background.js,lynx.requireModuleAsyncfails to use cache now.Let's see trace before and after this fix:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.
Checklist