Skip to content

feat(webpack-plugin): init externals-loading-webpack-plugin#1924

Merged
luhc228 merged 8 commits intolynx-family:mainfrom
luhc228:feat/init-externals-loading-webpack-plugin
Dec 15, 2025
Merged

feat(webpack-plugin): init externals-loading-webpack-plugin#1924
luhc228 merged 8 commits intolynx-family:mainfrom
luhc228:feat/init-externals-loading-webpack-plugin

Conversation

@luhc228
Copy link
Copy Markdown
Collaborator

@luhc228 luhc228 commented Nov 6, 2025

Summary by CodeRabbit

  • New Features

    • Adds an Externals Loading Webpack plugin for runtime externals loading (sync/async), deduplication, and layer-aware background vs main-thread handling; public plugin API and types included.
  • Examples

    • Adds a React externals example demonstrating bundling and runtime loading strategies.
  • Documentation

    • Adds plugin README, changelog, API report and example docs.
  • Packaging

    • Introduces a self-contained package with package metadata and build/test scripts.
  • Tests

    • New end-to-end test suite, fixtures and helpers covering async/sync loading, layer routing, and duplicate-filtering.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@luhc228 luhc228 requested a review from colinaaa as a code owner November 6, 2025 14:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 6, 2025

📝 Walkthrough

Walkthrough

Adds a new @lynx-js/externals-loading-webpack-plugin package implementing a layer-aware Webpack externals loader (TypeScript), accompanying tests, configs, docs, example integration, and updates to rspeedy externals transform and workspace TS references.

Changes

Cohort / File(s) Summary
Core Plugin Implementation
packages/webpack/externals-loading-webpack-plugin/src/index.ts
New ExternalsLoadingPlugin and nested runtime module: registers runtime module, generates layer-aware runtime code to fetch/load externals (sync & async), deduplicates by libraryName, and provides an externals resolver that maps requests to runtime global references.
Package Metadata & Build
packages/webpack/externals-loading-webpack-plugin/package.json, packages/webpack/externals-loading-webpack-plugin/api-extractor.json, packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json, packages/webpack/externals-loading-webpack-plugin/tsconfig.json, packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
New package manifest, exports map, API Extractor config, TypeScript build/project configs, and Vitest project configuration.
Docs & API Report
packages/webpack/externals-loading-webpack-plugin/README.md, packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md, packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md, .changeset/chilly-ravens-smile.md
Added README, changelog, generated API report and changeset documenting usage and public API surface.
Tests — Harness & Helpers
packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts, packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js, packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
Test entry and helpers: harness, layered entry/config creators, and a mocked lynx environment exposing fetchBundle / loadScript and a local CustomSections registry.
Tests — Cases
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/*
Adds six scenario test suites (async, sync, filter-duplicate-externals, not-overrides-existed-externals, only-background-externals, only-main-thread-externals) with rspack configs, test case configs, and assertions validating loading behavior and layering.
Test Utility Package
packages/webpack/externals-loading-webpack-plugin/test/foo/index.js, packages/webpack/externals-loading-webpack-plugin/test/foo/package.json
Local test module foo exporting add() with its own package.json used by tests.
Workspace Integration
packages/webpack/tsconfig.json
Adds a reference to the new package's tsconfig.build.json in the workspace TypeScript references.
Examples — React externals
examples/react-externals/...
New example demonstrating React/Preact externals: lynx/rslib configs, example app sources, styles, and package manifest for integration testing and docs.
Rslib externals transform
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts, packages/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md
Adds Externals types, transformExternals(externals) and updates defineExternalBundleRslibConfig to accept/merge transformed externals into output.externals.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on:
    • packages/webpack/externals-loading-webpack-plugin/src/index.ts — runtime code generation, async vs sync branches, deduplication logic, and runtime global naming.
    • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js — mocked lynx behavior and test assumptions.
    • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.tstransformExternals correctness and integration with defineExternalBundleRslibConfig.
    • Package exports / API report alignment with actual exported symbols and typings.

Possibly related PRs

Suggested labels

platform:Web

Suggested reviewers

  • colinaaa
  • upupming
  • gaoachao

Poem

🐰
I hopped through files and stitched a thread,
I fetched a bundle, put code to bed.
Main-thread hums while background sings,
Sections load on nimble springs.
A tiny rabbit cheered the wings.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: initializing a new webpack plugin for externals loading.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38c2a94 and 390d07a.

📒 Files selected for processing (1)
  • .changeset/chilly-ravens-smile.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/chilly-ravens-smile.md
🧠 Learnings (9)
📓 Common learnings
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: 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.
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: 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.
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: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.
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.
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.
📚 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:

  • .changeset/chilly-ravens-smile.md
📚 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/chilly-ravens-smile.md
📚 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:

  • .changeset/chilly-ravens-smile.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/chilly-ravens-smile.md
📚 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:

  • .changeset/chilly-ravens-smile.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/chilly-ravens-smile.md
📚 Learning: 2025-09-18T08:12:56.802Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.

Applied to files:

  • .changeset/chilly-ravens-smile.md
📚 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:

  • .changeset/chilly-ravens-smile.md
🔇 Additional comments (2)
.changeset/chilly-ravens-smile.md (2)

5-28: Changeset description and example are clear.

The description and webpack config example provide helpful context for using the new plugin. The example correctly uses camelCase property names (mainThread and background) as specified in the TypeScript interface.


1-3: Version bump should likely be "minor" for a new plugin introduction.

This is a public package (no "private": true flag), so a changeset is required. However, "patch" is semantically reserved for bug fixes and patches. Since @lynx-js/externals-loading-webpack-plugin is a new feature package being introduced, a "minor" version bump (0.0.0 → 0.1.0) would be more appropriate than "patch" (0.0.0 → 0.0.1).


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@luhc228 luhc228 marked this pull request as draft November 6, 2025 14:44
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 84.53608% with 30 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...ndle-rslib-config/src/externalBundleRslibConfig.ts 38.70% 19 Missing ⚠️
...pack/externals-loading-webpack-plugin/src/index.ts 93.25% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (6)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (3)

196-208: Document the deduplication behavior.

The plugin deduplicates externals by libraryName, keeping only the last definition when multiple externals share the same library name. This behavior might be unexpected and could lead to silent failures if users accidentally configure the same library twice with different URLs.

Consider adding a warning log when duplicates are detected, or document this deduplication behavior in the interface JSDoc comments at lines 88-126.


327-331: Simplify layer determination logic.

The nested ternary for layer determination is difficult to read and maintain.

Consider refactoring for clarity:

-      const currentLayer = contextInfo?.issuerLayer === mainThreadLayer
-        ? 'mainThread'
-        : (contextInfo?.issuerLayer === backgroundLayer
-          ? 'background'
-          : undefined);
+      let currentLayer: 'mainThread' | 'background' | undefined;
+      if (contextInfo?.issuerLayer === mainThreadLayer) {
+        currentLayer = 'mainThread';
+      } else if (contextInfo?.issuerLayer === backgroundLayer) {
+        currentLayer = 'background';
+      }

232-244: Add performance warning to the async configuration option documentation.

The code correctly implements both synchronous and asynchronous external loading paths as intentional features. However, the async option documentation (lines 102-106 in packages/webpack/externals-loading-webpack-plugin/src/index.ts) should include a warning about performance implications when set to false.

Currently, the interface documentation simply states: "Whether the source should be loaded asynchronously or not." with a default of true. Consider enhancing it to note that synchronous loading with handler.wait(timeout) blocks the JavaScript thread and can impact performance, recommending that async loading remain the default for most use cases.

/**
 * Whether the source should be loaded asynchronously or not.
 * 
 * When set to `false`, uses synchronous loading via `handler.wait(timeout)`,
 * which blocks the JavaScript thread. This can significantly impact performance
 * and responsiveness. Synchronous loading should only be used when absolutely
 * necessary; async loading is recommended for most use cases.
 *
 * @defaultValue `true`
 */
async?: boolean;
packages/webpack/externals-loading-webpack-plugin/README.md (1)

1-3: Consider expanding the README with usage examples.

The README is quite minimal. For better developer experience, consider adding:

  • Installation instructions
  • Basic usage example
  • Link to API documentation
  • Requirements (Lynx version 3.4+)
  • Configuration examples

However, the current content is acceptable for an initial release.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)

1-12: Test logic is identical to the sync case.

The test code is identical to packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js. The behavioral difference is driven by the configuration (async vs sync externals loading). This is acceptable for test clarity, though the duplication could optionally be reduced by extracting a shared test helper.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1)

20-22: Consider adding explanatory comments for test assertions.

The assertions correctly verify that when an external is configured only for mainThread, the background bundle includes the module inline (contains add(a, b)) while the mainThread bundle externalizes it (doesn't contain the code). This behavior could be non-obvious to future readers.

Consider adding a comment:

+  // background bundle should contain inline module code since mock-module is not externalized in background context
   expect(background).toContain('add' + '(a, b)');
+  // mainThread bundle should NOT contain inline module code since mock-module is externalized in mainThread context
   expect(mainThread).not.toContain('add' + '(a, b)');
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb6d94 and d9e7e94.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (32)
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/README.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1 hunks)
  • packages/webpack/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (26)
📓 Common learnings
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: 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: 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.
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.
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: 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: 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.
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.
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
📚 Learning: 2025-08-18T08:46:20.001Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1547
File: packages/rspeedy/core/src/config/loadConfig.ts:11-11
Timestamp: 2025-08-18T08:46:20.001Z
Learning: `#register` and similar imports starting with "#" are Node.js subpath imports defined in the "imports" field of package.json, not TypeScript path mapping aliases. These are natively supported by both Node.js and TypeScript without requiring additional tsconfig.json configuration like "moduleResolution" or "resolvePackageJsonImports" settings.

Applied to files:

  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
📚 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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
📚 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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to packages/**/etc/*.api.md : Always commit API extractor output after running `pnpm turbo api-extractor -- --local` (commit updated API report files)

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/test/helpers/setup-env.js
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-10-10T08:22:12.051Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts:266-266
Timestamp: 2025-10-10T08:22:12.051Z
Learning: In packages/web-platform/web-mainthread-apis, the handleUpdatedData function returned from prepareMainThreadAPIs is internal-only, used to serve web-core. It does not require public documentation, type exports, or SSR support.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
📚 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:

  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-14T12:54:51.143Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: .changeset/brave-melons-add.md:1-7
Timestamp: 2025-08-14T12:54:51.143Z
Learning: In the lynx-family/lynx-stack repository, packages use 0.x.x versioning where minor version bumps indicate breaking changes (not major bumps), following pre-1.0 semantic versioning conventions.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
📚 Learning: 2025-10-11T06:16:12.517Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1820
File: packages/web-platform/web-tests/tests/react.spec.ts:834-856
Timestamp: 2025-10-11T06:16:12.517Z
Learning: In packages/web-platform/web-tests/tests/react.spec.ts, the tests `basic-bindmouse` and `basic-mts-bindtouchstart` are NOT duplicates despite having similar test structures. They test different event types: `basic-bindmouse` validates mouse events (mousedown, mouseup, mousemove) with mouse-specific properties (button, buttons, x, y, pageX, pageY, clientX, clientY), while `basic-mts-bindtouchstart` validates touch events (touchstart) with touch arrays (touches, targetTouches, changedTouches). The similar test structure is coincidental and follows testing conventions.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
📚 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:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
🧬 Code graph analysis (15)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (5)
packages/webpack/test-tools/src/case.ts (1)
  • describeCases (98-111)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1)
  • path (7-7)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1)
  • path (9-9)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)
  • path (11-11)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1)
  • path (11-11)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)
  • ExternalsLoadingPlugin (146-352)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (2)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (4)
  • fs (6-6)
  • path (7-7)
  • background (9-12)
  • mainThread (13-16)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (4)
  • fs (8-8)
  • path (9-9)
  • background (11-14)
  • mainThread (15-18)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)
packages/webpack/chunk-loading-webpack-plugin/test/cases/chunk-loading/runtime-globals/rspack.config.js (1)
  • compiler (20-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
⏰ 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 (29)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1)

1-7: Configuration is correct and follows established patterns.

The bundlePath format 'main:main-thread.js' and 'main:background.js' is consistent with all other test configurations in the plugin test suite. The test configuration is properly typed and structured.

packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1)

1-5: LGTM!

The changelog format and content are appropriate for an initial package release.

packages/webpack/externals-loading-webpack-plugin/test/mock-module/package.json (1)

1-4: LGTM!

The mock module manifest is correctly structured for test fixtures with the private flag set appropriately.

packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1)

1-6: LGTM!

The API extractor configuration follows the established project pattern by extending the base configuration.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1)

1-7: LGTM!

The test configuration is correctly structured with appropriate bundle paths for the sync externals loading test case.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1)

1-27: LGTM!

The Rspack configuration is well-structured for the synchronous externals loading test case. The async: false setting at line 16 is intentional and aligns with the test scenario.

packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)

23-127: Verify default timeout value for production usage.

The default timeout is set to 100ms (line 122). For network-based external loading via lynx.fetchBundle, this might be too short in production scenarios with poor network conditions or large bundles.

Consider whether 100ms is sufficient for the expected use cases, or if a higher default (e.g., 5000ms) would be more appropriate. You may also want to document the timeout behavior more explicitly in the JSDoc comments.

packages/webpack/tsconfig.json (1)

17-17: LGTM!

The TypeScript project reference is correctly added following the established pattern for other webpack plugins in this monorepo.

packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)

4-6: LGTM!

Clean test fixture implementation. The simple add function is appropriate for validating externals loading behavior.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)

1-12: LGTM!

The test correctly validates synchronous externals loading. The module-level execution pattern is appropriate for webpack plugin tests, where the code runs during bundle execution and the test verifies the outcome.

packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1)

1-10: LGTM!

Standard TypeScript build configuration for a monorepo package. The composite project setup with separate src/lib directories is correct.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1)

1-27: LGTM!

The configuration properly sets up the async externals loading test with background/main-thread layer separation. The use of the createConfig helper keeps the setup clean and maintainable.

packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1)

4-11: LGTM!

Clean test suite setup using the standard describeCases pattern. The default import for node:path follows the codebase conventions.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1)

1-28: LGTM!

The test correctly verifies that the plugin doesn't override existing externals (lodash) while adding new ones (mock-module). The string concatenation pattern ('module.exports ' + '= Lodash;') is a good defensive technique to prevent the test file itself from matching the search patterns.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)

1-27: LGTM!

The test effectively validates the background-only externals scenario by verifying that the add function is not included in the background bundle but is present in the main-thread bundle. The string concatenation pattern maintains consistency with other tests to avoid false positives.

packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1)

1-8: LGTM!

The TypeScript configuration is appropriate for this package, correctly including source, test directories, and the vitest config, with noEmit enabled for type-checking.

packages/webpack/externals-loading-webpack-plugin/package.json (1)

43-45: Verify the Node.js engine requirement.

The package specifies node: ">=18", which differs from the root project's requirement of ^22 || ^24. While this may be intentional to support broader compatibility, please confirm:

  1. Whether this package truly needs to support Node.js 18-21
  2. If any features used require Node.js >=22 (as specified in the root)
  3. Whether this divergence is documented and justified

Based on learnings

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1)

1-24: LGTM!

The test configuration correctly sets up the only-background-externals scenario using the shared createConfig helper with appropriate chunk, layer, and externals settings.

packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1)

1-11: LGTM!

The Vitest configuration correctly defines the test project with an appropriate name and setup file path.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1)

5-27: LGTM!

The test correctly verifies deduplication of external loading code by checking that the pattern appears exactly once in each bundle. The string concatenation on lines 19 and 24 is intentional to avoid self-matching during webpack's code scanning.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1)

1-7: LGTM!

The test configuration correctly specifies the bundle paths for the async externals-loading test case.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1)

1-7: LGTM!

The test configuration correctly specifies the bundle paths for the not-overrides-existed-externals test case.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1)

1-7: LGTM!

The test configuration correctly specifies the bundle paths for the only-background-externals test case, consistent with other test configurations in the suite.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)

1-30: LGTM!

The configuration correctly tests that the plugin's externals coexist with rspack's native externals configuration. The structure follows the established pattern from other test cases.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1)

1-7: LGTM!

Standard test configuration following the established pattern for specifying which bundles the test should evaluate.

packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1)

1-35: LGTM!

The test environment setup correctly mocks the Lynx runtime APIs (fetchBundle, loadScript) required by the plugin. The dual wait()/then() pattern on the fetchBundle return value appropriately supports both synchronous and asynchronous external loading modes tested across the suite.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1)

1-23: LGTM!

The configuration correctly defines the external only for the mainThread context, which means mock-module will be externalized in mainThread bundles but bundled inline in background bundles. This properly exercises the layer-specific externals loading behavior.

packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (2)

11-22: LGTM!

Clean helper function that creates layer-based entry configurations. The default parameters and JSDoc annotations make it easy to use across test cases.


30-46: LGTM!

Well-structured helper that composes test configurations with the plugin. The separation of plugin options and rspack externals parameters provides good flexibility for testing different scenarios.

Comment thread packages/webpack/externals-loading-webpack-plugin/package.json
Comment thread packages/webpack/externals-loading-webpack-plugin/src/index.ts Outdated
Comment thread packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts Outdated
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 6, 2025

CodSpeed Performance Report

Merging #1924 will not alter performance

Comparing luhc228:feat/init-externals-loading-webpack-plugin (390d07a) with main (4e17b0b)

Summary

✅ 63 untouched
⏩ 3 skipped1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Nov 6, 2025

Web Explorer

#6632 Bundle Size — 372.48KiB (0%).

390d07a(current) vs 4e17b0b main#6616(baseline)

Bundle metrics  no changes
                 Current
#6632
     Baseline
#6616
No change  Initial JS 146.21KiB 146.21KiB
No change  Initial CSS 32.4KiB 32.4KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 230 230
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.97% 2.97%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6632
     Baseline
#6616
No change  JS 243.1KiB 243.1KiB
No change  Other 96.98KiB 96.98KiB
No change  CSS 32.4KiB 32.4KiB

Bundle analysis reportBranch luhc228:feat/init-externals-load...Project dashboard


Generated by RelativeCIDocumentationReport issue

@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch from d9e7e94 to 2763df2 Compare November 6, 2025 15:07
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: 390d07a

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

This PR includes changesets to release 1 package
Name Type
@lynx-js/externals-loading-webpack-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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 6, 2025

⚠️ No Changeset found

Latest commit: d9e7e94

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch 3 times, most recently from b69553a to bb89724 Compare November 7, 2025 03:00
@luhc228 luhc228 marked this pull request as ready for review November 7, 2025 04:05
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d9e7e94 and bb89724.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (34)
  • .changeset/purple-friends-mate.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/README.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1 hunks)
  • packages/webpack/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/package.json
🚧 Files skipped from review as they are similar to previous changes (23)
  • packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/purple-friends-mate.md
🧠 Learnings (16)
📓 Common learnings
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: 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: 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.
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.
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
📚 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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
📚 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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
📚 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/externals-loading-webpack-plugin/test/cases.test.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/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 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/externals-loading-webpack-plugin/test/cases.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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
📚 Learning: 2025-10-10T08:22:12.051Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts:266-266
Timestamp: 2025-10-10T08:22:12.051Z
Learning: In packages/web-platform/web-mainthread-apis, the handleUpdatedData function returned from prepareMainThreadAPIs is internal-only, used to serve web-core. It does not require public documentation, type exports, or SSR support.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-08-18T08:46:20.001Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1547
File: packages/rspeedy/core/src/config/loadConfig.ts:11-11
Timestamp: 2025-08-18T08:46:20.001Z
Learning: `#register` and similar imports starting with "#" are Node.js subpath imports defined in the "imports" field of package.json, not TypeScript path mapping aliases. These are natively supported by both Node.js and TypeScript without requiring additional tsconfig.json configuration like "moduleResolution" or "resolvePackageJsonImports" settings.

Applied to files:

  • packages/webpack/tsconfig.json
📚 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/purple-friends-mate.md
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to .changeset/*.md : For contributions, generate and commit a Changeset describing your changes

Applied to files:

  • .changeset/purple-friends-mate.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/purple-friends-mate.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/purple-friends-mate.md
🧬 Code graph analysis (6)
packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1)
packages/webpack/test-tools/src/case.ts (1)
  • describeCases (98-111)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (5)
  • consoleInfoMock (3-5)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (4)
  • fs (6-6)
  • path (7-7)
  • background (9-12)
  • mainThread (13-16)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (2)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/mock-module/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
🪛 LanguageTool
.changeset/purple-friends-mate.md

[grammar] ~1-~1: Hier könnte ein Fehler sein.
Context: --- ---

(QB_NEW_DE)

🔇 Additional comments (8)
packages/webpack/tsconfig.json (1)

17-17: LGTM!

The new project reference for externals-loading-webpack-plugin follows the existing naming conventions and placement patterns consistently. The addition is correctly positioned within the packages section and maintains proper formatting alignment with other entries.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)

1-12: LGTM!

The test correctly sets up the console spy before invoking the function and verifies the expected behavior.

packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1)

1-11: LGTM!

The test bootstrap follows the standard pattern and the copyright year has been correctly updated to 2025.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1)

1-28: LGTM!

The test correctly validates that both bundles contain the expected externals without overriding existing ones. The string concatenation pattern prevents false positives when searching the bundle code.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)

1-27: LGTM!

The test correctly validates that externals are loaded only in the background layer, with the main thread bundle containing the inline implementation.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1)

1-26: LGTM!

The test correctly validates that externals are loaded only in the main thread layer, with the background bundle containing the inline implementation. The logic correctly mirrors the opposite scenario of the only-background-externals test.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)

1-30: LGTM!

The configuration correctly defines layer-specific externals for the mock-module and includes lodash as an existing external to validate the non-override behavior.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1)

1-7: LGTM!

The test configuration correctly specifies the bundle paths for validation. The structure follows the standard pattern used across the test suite.

Comment thread .changeset/purple-friends-mate.md Outdated
Comment thread packages/webpack/externals-loading-webpack-plugin/src/index.ts Outdated
Comment thread packages/webpack/externals-loading-webpack-plugin/src/index.ts Outdated
Comment thread packages/webpack/externals-loading-webpack-plugin/src/index.ts
@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch from bb89724 to fd20b03 Compare December 1, 2025 09:53
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/webpack/externals-loading-webpack-plugin/package.json (1)

1-46: Package manifest structure looks good.

The package metadata, exports configuration, and build setup are properly structured. The local test dependency "foo": "./test/foo" at line 41 is an acceptable pattern for test-only dependencies.

Note: The missing peerDependencies for webpack/rspack has already been flagged in a previous review comment.

🧹 Nitpick comments (2)
packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1)

22-27: Mock then() doesn't return a value.

The then callback invokes the callback synchronously but doesn't return anything. If consumer code chains .then().then() or expects a return value, this mock would fail. For basic tests this works, but consider returning the callback result for more accurate Promise-like behavior.

     fetchBundle: (url) => {
       return {
         wait: () => ({ url, code: 0, err: null }),
-        then: (callback) => callback({ url, code: 0, err: null }),
+        then: (callback) => {
+          const result = callback({ url, code: 0, err: null });
+          return Promise.resolve(result);
+        },
       };
     },
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)

291-321: Consider adding timeout handling for async loading.

The createLoadExternalAsync helper doesn't use the timeout option, meaning async external loading could hang indefinitely if the fetch never resolves. While sync loading properly uses handler.wait(timeout), async relies solely on Promise resolution.

If async timeout handling is desired, consider wrapping with Promise.race:

-function createLoadExternalAsync(handler, sectionPath) {
+function createLoadExternalAsync(handler, sectionPath, timeout) {
+  const timeoutPromise = new Promise((_, reject) => {
+    setTimeout(() => reject(new Error('External loading timeout: ' + sectionPath)), timeout * 1000);
+  });
   return new Promise((resolve, reject) => {
-    handler.then((response) => {
+    Promise.race([
+      new Promise((res) => handler.then(res)),
+      timeoutPromise
+    ]).then((response) => {
       if (response.code === 0) {
         // ...existing code
       }
-    })
+    }).catch(reject);
   })
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb89724 and fd20b03.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .changeset/chilly-ravens-smile.md (1 hunks)
  • .changeset/purple-friends-mate.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/README.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1 hunks)
  • packages/webpack/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json
  • packages/webpack/externals-loading-webpack-plugin/README.md
🚧 Files skipped from review as they are similar to previous changes (17)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • .changeset/purple-friends-mate.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
🧰 Additional context used
📓 Path-based instructions (2)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/chilly-ravens-smile.md
packages/**/etc/*.api.md

📄 CodeRabbit inference engine (AGENTS.md)

Always commit API extractor output after running pnpm turbo api-extractor -- --local (commit updated API report files)

Files:

  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
🧠 Learnings (19)
📓 Common learnings
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: 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/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`.
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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:

  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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:

  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-11T06:00:04.376Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:59-61
Timestamp: 2025-08-11T06:00:04.376Z
Learning: In the lynx-family/lynx-stack repository, the `testingLibraryPlugin` in `packages/react/testing-library/src/plugins/vitest.ts` intentionally uses `process.exit` when jsdom installation fails, maintaining consistency with the previous implementation from `packages/react/testing-library/src/vitest.config.js`. This behavior should not be changed to use `this.error` despite being a Vite plugin best practice.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
📚 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/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/test/helpers/setup-env.js
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-14T12:54:51.143Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: .changeset/brave-melons-add.md:1-7
Timestamp: 2025-08-14T12:54:51.143Z
Learning: In the lynx-family/lynx-stack repository, packages use 0.x.x versioning where minor version bumps indicate breaking changes (not major bumps), following pre-1.0 semantic versioning conventions.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/package.json
🧬 Code graph analysis (5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1)
  • add (4-6)
packages/web-platform/web-tests/tests/coverage-fixture.ts (1)
  • expect (62-62)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (4)
  • fs (8-8)
  • path (9-9)
  • background (11-14)
  • mainThread (15-18)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (2)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1)
  • add (4-6)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
🔇 Additional comments (19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1)

1-7: Config shape and export look good

Type annotation plus module.exports structure and bundlePath entries are consistent with existing case configs; nothing blocking here.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1)

1-7: Config shape and values look good

The JSDoc typing and module.exports structure match the expected TConfigCaseConfig pattern, and the bundlePath entries for main-thread and background bundles look appropriate for this test case. No changes needed.

.changeset/chilly-ravens-smile.md (1)

1-28: LGTM! Changeset is well-documented.

The changeset provides a clear description of the new ExternalsLoadingPlugin feature with a helpful usage example demonstrating the main configuration options.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1)

1-23: LGTM! Test configuration is properly structured.

The test case configuration correctly uses the shared createConfig helper and defines the external 'foo' with main-thread-only scope.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)

3-12: LGTM! Test logic is correct.

The mock setup and assertions properly verify that the external module's add function is called and returns the expected result.

packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1)

1-6: LGTM! Test utility is simple and correct.

The test helper module correctly exports a simple add function used by multiple test cases.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)

1-12: LGTM! Test is well-structured.

The async test case correctly imports from 'foo', sets up mocks, and verifies the expected behavior with proper assertions.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1)

7-31: LGTM! Deduplication test is well-designed.

The test correctly verifies that duplicate externals are filtered by reading the generated bundles and checking for exactly one occurrence of the external loading pattern in each. The string concatenation technique prevents build-time replacement of the search pattern.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1)

7-28: LGTM! Test correctly verifies non-override behavior.

The test validates that the plugin doesn't override existing externals (Lodash) while adding new ones (Foo). The string concatenation in assertions prevents build-time pattern replacement.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)

1-30: LGTM!

The test configuration correctly sets up a scenario for verifying that existing externals (like lodash) are not overridden by the plugin. The configuration structure aligns with createConfig helper expectations, and the async: false setting ensures the synchronous loading path is tested.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1)

1-7: LGTM!

The test configuration correctly specifies the bundle paths for both main-thread and background chunks, enabling the test harness to validate the async externals loading behavior.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1)

1-27: LGTM!

The test configuration correctly sets up an async external loading scenario with async: true. The structure properly configures background and main-thread layers with their respective section paths.

packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1)

1-41: API report looks complete.

The generated API documentation correctly captures the public surface of ExternalsLoadingPlugin, including the class, constructor, apply method, RuntimeGlobals, and the ExternalsLoadingPluginOptions and LayerOptions interfaces. Ensure this file is kept in sync by running pnpm turbo api-extractor -- --local after any public API changes. As per coding guidelines.

packages/webpack/externals-loading-webpack-plugin/src/index.ts (6)

1-19: LGTM!

Clear license header and well-organized imports from @rspack/core.


26-174: Comprehensive documentation.

The ExternalsLoadingPluginOptions interface is thoroughly documented with clear examples for different use cases (loading in both layers vs. single layer). The libraryName documentation explaining deduplication behavior is particularly helpful.


222-227: LGTM!

Static RuntimeGlobals provides a clear, centralized reference for the webpack require extension.


272-283: Deduplication keeps last entry - verify this is intended.

When multiple externals share the same libraryName, the last entry wins. This is documented behavior, but ensure consumers understand that order matters when configuring externals with shared library names.


371-380: LGTM!

The externals configuration correctly preserves existing externals (array or single value) while appending the generated config function.


399-435: LGTM!

The externals resolver correctly handles layer detection and uses bracket notation with JSON.stringify to safely handle library names with special characters (addressing the previous review feedback).

@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch from fd20b03 to 23963a6 Compare December 1, 2025 09:56
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd20b03 and 23963a6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .changeset/chilly-ravens-smile.md (1 hunks)
  • .changeset/purple-friends-mate.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/README.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1 hunks)
  • packages/webpack/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/purple-friends-mate.md
🚧 Files skipped from review as they are similar to previous changes (24)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/foo/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/chilly-ravens-smile.md
🧠 Learnings (21)
📓 Common learnings
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: 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.
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-10-10T08:22:12.051Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1837
File: packages/web-platform/web-mainthread-apis/src/prepareMainThreadAPIs.ts:266-266
Timestamp: 2025-10-10T08:22:12.051Z
Learning: In packages/web-platform/web-mainthread-apis, the handleUpdatedData function returned from prepareMainThreadAPIs is internal-only, used to serve web-core. It does not require public documentation, type exports, or SSR support.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
📚 Learning: 2025-09-29T06:43:40.182Z
Learnt from: CR
Repo: lynx-family/lynx-stack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-29T06:43:40.182Z
Learning: Applies to packages/**/etc/*.api.md : Always commit API extractor output after running `pnpm turbo api-extractor -- --local` (commit updated API report files)

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json
📚 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:

  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/chilly-ravens-smile.md
📚 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:

  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
📚 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/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-08-14T12:54:51.143Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1370
File: .changeset/brave-melons-add.md:1-7
Timestamp: 2025-08-14T12:54:51.143Z
Learning: In the lynx-family/lynx-stack repository, packages use 0.x.x versioning where minor version bumps indicate breaking changes (not major bumps), following pre-1.0 semantic versioning conventions.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/package.json
📚 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/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/package.json
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 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/externals-loading-webpack-plugin/src/index.ts
📚 Learning: 2025-08-18T08:46:20.001Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1547
File: packages/rspeedy/core/src/config/loadConfig.ts:11-11
Timestamp: 2025-08-18T08:46:20.001Z
Learning: `#register` and similar imports starting with "#" are Node.js subpath imports defined in the "imports" field of package.json, not TypeScript path mapping aliases. These are natively supported by both Node.js and TypeScript without requiring additional tsconfig.json configuration like "moduleResolution" or "resolvePackageJsonImports" settings.

Applied to files:

  • packages/webpack/tsconfig.json
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
🧬 Code graph analysis (4)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)
  • ExternalsLoadingPlugin (230-444)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (4)
  • fs (8-8)
  • path (9-9)
  • background (11-14)
  • mainThread (15-18)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
⏰ 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). (4)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / clippy
  • GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (21)
packages/webpack/tsconfig.json (1)

17-17: Correctly adds TypeScript reference for the new package.

The addition follows the established pattern and enables the externals-loading-webpack-plugin to be included in composite builds. Syntax and placement are correct.

packages/webpack/externals-loading-webpack-plugin/package.json (2)

41-41: Clarify the purpose and naming of the "foo" test dependency.

Line 41 includes "foo": "./test/foo" which appears to be a test mock module, but the generic placeholder name suggests this may be incomplete. Rename it to something descriptive (e.g., "mock-module", "test-helper") or document its purpose.


38-42: Missing peerDependencies for webpack in public plugin package.

This public webpack plugin package lacks peerDependencies declarations. Without them, package managers won't warn users about incompatible bundler versions, leading to silent failures at runtime.

Add peerDependencies and peerDependenciesMeta:

   "devDependencies": {
     "@lynx-js/test-tools": "workspace:*",
     "@rspack/core": "catalog:rspack",
     "foo": "./test/foo"
   },
+  "peerDependencies": {
+    "webpack": "^5.0.0"
+  },
+  "peerDependenciesMeta": {
+    "webpack": {
+      "optional": true
+    }
+  },
   "engines": {
     "node": ">=18"
   }

Adjust the webpack version range to match actual compatibility requirements.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (3)

1-5: LGTM!

The imports and logging are appropriate for verifying that externals are loaded correctly.


7-18: LGTM!

The test setup correctly reads the generated bundles for verification.


20-27: LGTM!

The assertions correctly verify that both Lodash and Foo externals are present in the generated bundles for both layers.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (3)

1-7: LGTM!

The mock setup correctly captures console.info calls for verification.


9-19: LGTM!

The bundle reading logic is consistent with other test cases.


21-26: LGTM!

The assertions correctly verify that when an external is configured only for the main-thread layer, the background bundle contains the inlined code while the main-thread bundle uses the external reference.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1)

1-24: LGTM!

The configuration correctly sets up a background-only external for testing purposes.

packages/webpack/externals-loading-webpack-plugin/src/index.ts (8)

1-12: LGTM!

The package documentation clearly states the Lynx version requirement (3.5+).


26-182: LGTM!

The interface is well-documented with clear examples demonstrating single-layer and dual-layer external configurations.


184-236: LGTM!

The class structure and example usage are clear and well-documented.


237-272: LGTM!

The guard clauses properly handle edge cases and route to the appropriate layer code generation.


274-296: LGTM!

The deduplication logic correctly handles scenarios where multiple external keys map to the same library, keeping the last definition.


297-329: LGTM!

The runtime helper functions provide clear error messages and appropriate error handling for both async and sync loading paths.


331-376: LGTM!

The code generation correctly uses bracket notation with JSON.stringify to safely handle library names, addressing the property injection concern from previous reviews.


404-443: LGTM!

The externals configuration generator correctly determines the current layer and safely generates external references using bracket notation.

packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (2)

1-22: LGTM!

The createEntries helper correctly generates dual-layer entry configurations for testing.


24-46: LGTM!

The createConfig helper provides a clean abstraction for test configurations with proper webpack experiments and plugin setup.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1)

1-26: LGTM!

The synchronous loading test configuration correctly sets async: false and provides section paths for both layers.

Comment thread .changeset/chilly-ravens-smile.md
@relativeci
Copy link
Copy Markdown

relativeci bot commented Dec 1, 2025

React Example

#6472 Bundle Size — 236.9KiB (0%).

390d07a(current) vs 4e17b0b main#6456(baseline)

Bundle metrics  no changes
                 Current
#6472
     Baseline
#6456
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 162 162
No change  Duplicate Modules 65 65
No change  Duplicate Code 46.74% 46.74%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#6472
     Baseline
#6456
No change  IMG 145.76KiB 145.76KiB
No change  Other 91.14KiB 91.14KiB

Bundle analysis reportBranch luhc228:feat/init-externals-load...Project dashboard


Generated by RelativeCIDocumentationReport issue

@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch from 23963a6 to 34688bd Compare December 1, 2025 10:37
@luhc228 luhc228 force-pushed the feat/init-externals-loading-webpack-plugin branch from 34688bd to 35f58dd Compare December 1, 2025 10:41
@luhc228 luhc228 requested a review from upupming December 1, 2025 10:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)

3-7: Consider restoring the console.info spy after the case finishes

vi.spyOn(console, 'info').mockImplementation(...) at module scope will keep console.info stubbed until the environment or Vitest resets mocks. If other cases in the same runtime rely on the real console.info, they may inherit this stub. Consider adding something like afterAll(() => consoleInfoMock.mockRestore()); (or relying on a global restoreMocks: true config) to make the lifecycle explicit.

packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)

1-46: Test helpers are straightforward and match current use cases.

createEntries and createConfig give a clear two-layer (main-thread/background) setup with layers enabled and the plugin wired in, which lines up with how all the case configs consume them. If we ever need cases with non-main entry names or custom entry sources, we can extend createConfig to accept and forward those, but the current shape is sufficient for this plugin’s tests.

packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)

1-443: Consider explicitly propagating lynx.fetchBundle rejections in createLoadExternalAsync.

The generated createLoadExternalAsync helper wraps handler (from lynx.fetchBundle(...)) in a new Promise and only attaches an onFulfilled handler:

function createLoadExternalAsync(handler, sectionPath) {
  return new Promise((resolve, reject) => {
    handler.then((response) => {
      // ...
    })
  })
}

If lynx.fetchBundle is ever allowed to reject instead of resolving with a non‑zero code, that rejection would neither call resolve nor reject, leaving the wrapper promise pending forever and surfacing only as an unhandled rejection on the original handler.

If the engine’s contract guarantees that fetchBundle never rejects and always resolves with a { code, url, ... } object (and your tests rely on that), this is fine but somewhat implicit. Otherwise, you may want to adjust the template to propagate rejections, for example:

function createLoadExternalAsync(handler, sectionPath) {
  return handler.then((response) => {
    if (response.code === 0) {
      const result = lynx.loadScript(sectionPath, { bundleName: response.url });
      return result;
    }
    throw new Error(/* ...same error message as today... */);
  });
}

or by adding an explicit onRejected / .catch(reject) branch inside the existing template. That keeps behavior clear without adding extra defensive checks elsewhere in the runtime module.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23963a6 and 34688bd.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • .changeset/chilly-ravens-smile.md (1 hunks)
  • .changeset/purple-friends-mate.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/README.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts (1 hunks)
  • packages/webpack/tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/webpack/externals-loading-webpack-plugin/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (22)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js
  • packages/webpack/externals-loading-webpack-plugin/CHANGELOG.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/foo/index.js
  • packages/webpack/externals-loading-webpack-plugin/api-extractor.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/package.json
  • .changeset/purple-friends-mate.md
  • packages/webpack/externals-loading-webpack-plugin/test/foo/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases.test.ts
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

For contributions, generate and commit a Changeset describing your changes

Files:

  • .changeset/chilly-ravens-smile.md
🧠 Learnings (16)
📓 Common learnings
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: 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: 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: 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.
📚 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/externals-loading-webpack-plugin/README.md
  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.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:

  • packages/webpack/externals-loading-webpack-plugin/README.md
  • .changeset/chilly-ravens-smile.md
📚 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/externals-loading-webpack-plugin/README.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/README.md
  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/tsconfig.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js
📚 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/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
📚 Learning: 2025-08-18T08:46:20.001Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1547
File: packages/rspeedy/core/src/config/loadConfig.ts:11-11
Timestamp: 2025-08-18T08:46:20.001Z
Learning: `#register` and similar imports starting with "#" are Node.js subpath imports defined in the "imports" field of package.json, not TypeScript path mapping aliases. These are natively supported by both Node.js and TypeScript without requiring additional tsconfig.json configuration like "moduleResolution" or "resolvePackageJsonImports" settings.

Applied to files:

  • packages/webpack/tsconfig.json
📚 Learning: 2025-09-18T08:12:56.802Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.

Applied to files:

  • .changeset/chilly-ravens-smile.md
📚 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:

  • .changeset/chilly-ravens-smile.md
  • packages/webpack/externals-loading-webpack-plugin/src/index.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/externals-loading-webpack-plugin/src/index.ts
🧬 Code graph analysis (4)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (2)
packages/rspeedy/core/test/config/fixtures/custom/function.ts (1)
  • source (1-3)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)
  • ExternalsLoadingPlugin (230-444)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (3)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (4)
  • fs (8-8)
  • path (9-9)
  • background (11-14)
  • mainThread (15-18)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (13-16)
  • mainThread (17-20)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (4)
  • fs (10-10)
  • path (11-11)
  • background (12-15)
  • mainThread (16-19)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)
packages/webpack/externals-loading-webpack-plugin/test/helpers/create-config.js (1)
  • createConfig (30-46)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (4)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-main-thread-externals/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/index.js (1)
  • consoleInfoMock (3-5)
packages/webpack/externals-loading-webpack-plugin/test/foo/index.js (1)
  • add (4-6)
⏰ 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 (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (10)
packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/sync/test.config.cjs (1)

1-7: Config shape and values look good

Type annotation, CommonJS export, and bundlePath entries align with the described test harness for main/background bundles. No changes needed.

packages/webpack/externals-loading-webpack-plugin/README.md (1)

1-3: README provides appropriate introductory content for the new package.

The minimal documentation is acceptable for the initial release. The heading and one-line description clearly identify the package and its purpose.

.changeset/chilly-ravens-smile.md (1)

1-28: Changeset follows proper format and documents the plugin introduction clearly.

The entry includes correct frontmatter, a meaningful description, and a realistic usage example demonstrating the main plugin options and externals configuration. The API property naming (mainThread, background) is consistent and appropriate.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/only-background-externals/index.js (1)

9-27: Test structure and bundle assertions look solid

Asserting on the compiled main:background.js vs main:main-thread.js contents plus the runtime console.info(add(1, 2)) call gives good coverage of the “only background externals” behavior: you verify both how the plugin rewrites bundles and that the external still evaluates correctly at runtime. Reading the bundles via fs.readFileSync and matching the add('a', 'b') snippet is consistent with how other webpack plugins in this repo assert on generated runtime artifacts rather than relying on dynamic execution timing, which fits externals wiring being decided at compile time. Based on learnings, this aligns well with existing webpack runtime module test patterns.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1)

1-28: Assertions correctly validate coexistence of regular externals and lynx_ex-based externals.

This test exercises both background and main-thread bundles, confirming that the existing lodash external (Lodash) is preserved while the plugin-provided Foo external is exposed via __webpack_require__.lynx_ex["Foo"]. The dynamic node:fs / node:path usage is consistent with the other externals-loading case fixtures.

packages/webpack/tsconfig.json (1)

17-17: New tsconfig reference for the plugin looks correct.

Including ./externals-loading-webpack-plugin/tsconfig.build.json here keeps the webpack composite project aware of the new plugin’s build, consistent with how other webpack plugins are wired.

packages/webpack/externals-loading-webpack-plugin/tsconfig.build.json (1)

1-10: Build tsconfig matches expected per-package pattern.

Extending the root config with composite: true, rootDir: "./src", outDir: "./lib", and including only src is a clean setup for emitting the plugin’s build artifacts.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/index.js (1)

1-12: Async externals test aligns with other cases and assertions are precise.

Spying on console.info and invoking console.info(add(1, 2)) at module evaluation time gives a simple, deterministic way to assert that the async external is wired and executed exactly once with value 3, consistent with the other externals-loading case patterns.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/rspack.config.js (1)

1-30: Configuration cleanly models the “do not override existing externals” scenario.

Using createConfig for the plugin options focused on foo while passing a separate externals map (lodash: 'Lodash') correctly expresses that lodash should remain a regular external, which matches what the paired test asserts.

packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/async/rspack.config.js (1)

1-27: Async rspack config is minimal and focused on the plugin behavior.

This keeps the configuration scoped to the plugin-managed foo external with async: true and symmetric background/mainThread layer/sectionPath wiring, which is ideal for the async test case.

@luhc228
Copy link
Copy Markdown
Collaborator Author

luhc228 commented Dec 3, 2025

@upupming @colinaaa PTAL~

@luhc228 luhc228 requested a review from upupming December 11, 2025 02:34
luhc228 and others added 3 commits December 11, 2025 10:34
* feat: add react externals example

* feat: use globalThis & lynxCoreInject.tt to share between bundles

* feat: simplify externals in defineExternalBundleRslibConfig
@luhc228 luhc228 enabled auto-merge (squash) December 12, 2025 11:43
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
examples/react-externals/lynx.config.js (2)

6-8: Make bundle-analysis env parsing explicit (optional).

!!process.env.RSPEEDY_BUNDLE_ANALYSIS will enable on "0". Consider checking === '1' / === 'true' if that matters.


19-82: Consider normalizing EXTERNAL_BUNDLE_PREFIX to avoid double slashes.

Today ${EXTERNAL_BUNDLE_PREFIX}/react.lynx.bundle becomes //react.lynx.bundle if the prefix already ends with /.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35f58dd and 5ffc6ea.

⛔ Files ignored due to path filters (4)
  • examples/react-externals/src/assets/arrow.png is excluded by !**/*.png
  • examples/react-externals/src/assets/lynx-logo.png is excluded by !**/*.png
  • examples/react-externals/src/assets/react-logo.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (14)
  • examples/react-externals/README.md (1 hunks)
  • examples/react-externals/external-bundle/CompLib.tsx (1 hunks)
  • examples/react-externals/external-bundle/ReactLynx.ts (1 hunks)
  • examples/react-externals/lynx.config.js (1 hunks)
  • examples/react-externals/package.json (1 hunks)
  • examples/react-externals/rslib-comp-lib.config.ts (1 hunks)
  • examples/react-externals/rslib-reactlynx.config.ts (1 hunks)
  • examples/react-externals/src/App.css (1 hunks)
  • examples/react-externals/src/App.tsx (1 hunks)
  • examples/react-externals/src/index.tsx (1 hunks)
  • examples/react-externals/src/rspeedy-env.d.ts (1 hunks)
  • examples/react-externals/tsconfig.json (1 hunks)
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2 hunks)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • examples/react-externals/src/App.css
  • examples/react-externals/tsconfig.json
  • examples/react-externals/src/rspeedy-env.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
🧰 Additional context used
🧠 Learnings (17)
📓 Common learnings
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: 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.
📚 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:

  • examples/react-externals/src/App.tsx
  • examples/react-externals/lynx.config.js
  • examples/react-externals/src/index.tsx
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/src/App.tsx
  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/src/index.tsx
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • examples/react-externals/README.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/README.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/src/index.tsx
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/src/index.tsx
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/src/index.tsx
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/lynx.config.js
  • examples/react-externals/package.json
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/package.json
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • examples/react-externals/package.json
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/package.json
📚 Learning: 2025-07-18T04:27:18.291Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1238
File: packages/react/runtime/src/debug/component-stack.ts:70-90
Timestamp: 2025-07-18T04:27:18.291Z
Learning: The component-stack.ts file in packages/react/runtime/src/debug/component-stack.ts is a direct fork from https://github.com/preactjs/preact/blob/main/debug/src/component-stack.js. The team prefers to keep it aligned with the upstream Preact version and may contribute improvements back to Preact in the future.

Applied to files:

  • examples/react-externals/src/index.tsx
  • examples/react-externals/external-bundle/ReactLynx.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:

  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.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:

  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/external-bundle/ReactLynx.ts
  • examples/react-externals/README.md
🧬 Code graph analysis (5)
examples/react-externals/src/App.tsx (3)
examples/react-externals/external-bundle/CompLib.tsx (1)
  • App (1-1)
packages/react/transform/src/wasm.js (1)
  • view (24-28)
packages/web-platform/web-tests/tests/react/basic-event-trigger/index.jsx (1)
  • text (6-6)
examples/react-externals/lynx.config.js (3)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (1)
  • ExternalsLoadingPlugin (258-483)
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (1)
  • LAYERS (32-35)
packages/rspeedy/plugin-qrcode/src/index.ts (1)
  • pluginQRCode (91-155)
examples/react-externals/rslib-comp-lib.config.ts (2)
packages/react/testing-library/src/vitest.config.js (1)
  • preactDir (37-41)
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2)
  • defineExternalBundleRslibConfig (187-210)
  • LAYERS (32-35)
examples/react-externals/src/index.tsx (2)
examples/react-externals/external-bundle/CompLib.tsx (1)
  • App (1-1)
examples/react-externals/src/App.tsx (1)
  • App (8-52)
examples/react-externals/rslib-reactlynx.config.ts (2)
packages/react/testing-library/src/vitest.config.js (1)
  • preactDir (37-41)
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2)
  • defineExternalBundleRslibConfig (187-210)
  • LAYERS (32-35)
🪛 LanguageTool
examples/react-externals/README.md

[style] ~7-~7: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...nt library to a separate Lynx bundle. - Use `@lynx-js/externals-loading-webpack-plu...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

⏰ 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 (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
🔇 Additional comments (11)
examples/react-externals/src/index.tsx (3)

4-4: Keep ./App.js import only if it’s required for externals matching.

lynx.config.js externalizes './App.js', so changing this specifier can silently break externalization. If TS complains, fix via typings/config rather than changing the request string.


15-17: Verify import.meta.webpackHot is typed in this repo.

Without a global augmentation for ImportMeta, TS will fail typecheck here.


6-10: Avoid double-importing App.css (it’s also imported in App.tsx).

Pick one import location to prevent duplicated style injection / ordering surprises.

⛔ Skipped due to learnings
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.
Learnt from: PupilTong
Repo: lynx-family/lynx-stack PR: 1029
File: packages/web-platform/web-core/src/uiThread/createRenderAllOnUI.ts:95-99
Timestamp: 2025-07-16T06:28:26.463Z
Learning: In the lynx-stack codebase, CSS selectors in SSR hydration are generated by their own packages, ensuring a predictable format that makes simple string manipulation safe and preferable over regex for performance reasons.
examples/react-externals/rslib-reactlynx.config.ts (1)

49-54: Verify reactpreactDir aliasing is sufficient for your imports.

If any code resolves react/jsx-runtime / react-dom-like entrypoints, aliasing to the package root may not behave like preact/compat.

examples/react-externals/src/App.tsx (1)

15-18: Clarify whether 'background-only' is an intentional directive.

If it’s not consumed by tooling as a directive-prologue marker, it’s dead code and should be removed.

examples/react-externals/lynx.config.js (1)

13-16: Verify chunk names match the actual emitted chunk names.

If entry naming changes, externals loading will silently stop injecting runtime code (plugin gates by this.chunk.name).

packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (1)

90-115: Externals transform looks coherent; verify the global roots are correct for both layers.

Main-thread uses globalThis.lynx_ex...; background uses lynxCoreInject.tt.lynx_ex.... If either root can differ by runtime/SDK version, this will be a hard-to-debug runtime failure.

examples/react-externals/rslib-comp-lib.config.ts (2)

1-16: Config setup looks consistent (and Node built-in import style matches repo convention).

Based on learnings, default imports for Node built-ins are preferred in this repo.


57-80: Externals mapping matches new transformExternals expectations.

examples/react-externals/package.json (2)

2-5: Package manifest looks consistent for a private example app.
private: true, type: module, and workspace-managed Lynx deps make sense for an in-repo example.

Also applies to: 13-26


8-10: Both rslib config files exist at the expected paths in examples/react-externals/, so the build commands will not fail due to missing configuration.

Comment thread examples/react-externals/external-bundle/CompLib.tsx
Comment thread examples/react-externals/external-bundle/ReactLynx.ts
Comment thread examples/react-externals/package.json
Comment thread examples/react-externals/README.md
Comment thread examples/react-externals/rslib-reactlynx.config.ts
Comment thread examples/react-externals/src/App.tsx
Comment thread packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
packages/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md (1)

17-21: Resolve ae-forgotten-export for ExternalBundleLibConfig by re-exporting it from the entry

API Extractor is still warning that ExternalBundleLibConfig is referenced in the public signature of defineExternalBundleRslibConfig but not exported by the package entry (index.d.ts). This means consumers can’t name the type cleanly even though it’s part of the API surface.

To fix this:

  • Explicitly re-export ExternalBundleLibConfig (and any other relevant helper types such as Externals / OutputConfig if desired) from your entry module, e.g.:
// in packages/rspeedy/lynx-bundle-rslib-config/src/index.ts
export type { ExternalBundleLibConfig } from './externalBundleRslibConfig.js';
  • Then re-run pnpm turbo api-extractor -- --local and commit the updated .api.md so this warning disappears, per the repo’s API report guideline.

After adding the re-export, please rerun API Extractor and verify that the ae-forgotten-export warning is gone from this file.

🧹 Nitpick comments (4)
examples/react-externals/README.md (1)

5-7: Reduce repetition of "Use" at sentence start.

Lines 5–7 each begin with "Use," creating repetitive structure. Consider rewording one or two bullets for better flow.

- Use `@lynx-js/lynx-bundle-rslib-config` to bundle ReactLynx runtime to a separate Lynx bundle.
- Use `@lynx-js/lynx-bundle-rslib-config` to bundle a simple ReactLynx component library to a separate Lynx bundle.
- Use `@lynx-js/externals-loading-webpack-plugin` to load ReactLynx runtime (sync) and component bundle (async).
+ Bundle ReactLynx runtime to a separate Lynx bundle using `@lynx-js/lynx-bundle-rslib-config`.
+ Bundle a simple ReactLynx component library to a separate Lynx bundle with `@lynx-js/lynx-bundle-rslib-config`.
+ Load ReactLynx runtime (sync) and component bundle (async) via `@lynx-js/externals-loading-webpack-plugin`.
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (3)

78-89: New exported config types look structurally sound and align the public API

Exporting Externals, LibOutputConfig, OutputConfig, and ExternalBundleLibConfig here makes the defineExternalBundleRslibConfig signature properly modelled and fixes the previous “internal-only type in public API” issue at the source-file level. The ExternalBundleLibConfig extension is backward-compatible (no new required fields) and keeps output optional while enriching it with externals.

No change requested here; just make sure ExternalBundleLibConfig is also re‑exported from the package entry (see API report comment) so consumers can reference it directly.

If you want stronger discoverability, you could also explicitly re-export these types from the top-level index.ts (even if you already wildcard-export this module) to make them more visible in editors and docs. Please double‑check how your current entry barrel is set up.


90-115: transformExternals logic is reasonable; consider clearer typing and “no externals” behavior

The layer-aware mapping logic and callback usage look correct:

  • Returns early when request is missing or unmapped.
  • Distinguishes MAIN_THREAD vs background via contextInfo?.issuerLayer and builds the expected global path arrays.
  • Ensures callback is invoked at most once per call.

Two small follow-ups you might consider:

  1. Explicit typing for the externals function parameters – Right now ({ request, contextInfo }, callback) is untyped. Depending on your TS config, this may become any. Importing and using the appropriate Rspack/webpack externals function type (or at least a minimal structural type for contextInfo / callback) would improve safety.

  2. Return value when externals is undefinedtransformExternals(undefined) currently returns {}. If the underlying externals type allows undefined, returning undefined instead would preserve the “no externals configured” state and avoid forcing an empty externals object. If Required<LibOutputConfig>['externals'] excludes undefined, you may want to widen the return type so you can distinguish those two cases.

Please verify against @rslib/core / Rspack typings that (a) your externals function shape matches what LibOutputConfig['externals'] expects, and (b) whether undefined is a legal value there; if so, adjusting the return type to include undefined would be cleaner.


188-188: Config merge correctly injects transformed externals; watch the “always set externals” behavior

Wiring ExternalBundleLibConfig into defineExternalBundleRslibConfig and feeding userLibConfig.output?.externals through transformExternals before merging via rsbuild.mergeRsbuildConfig is a good shape and keeps the higher-level API focused on a simple Record of externals.

One subtle semantic change: even when the user doesn’t provide output?.externals, this block will set externals to {} (via transformExternals(undefined)). That’s probably harmless and matches your intention (“no externals”), but it does mean we no longer distinguish between “no externals key at all” and “explicit empty externals object”.

If you care about that distinction, you could special-case undefined:

const userExternals = userLibConfig.output?.externals;
output: {
  ...userLibConfig.output,
  ...(userExternals !== undefined && {
    externals: transformExternals(userExternals),
  }),
}

Otherwise, the merge structure looks fine and should preserve defaults from defaultExternalBundleLibConfig while layering user config + transformed externals on top.

Please confirm that rsbuild.mergeRsbuildConfig indeed deep-merges output objects as expected so that overriding it here with a partial (plus externals) doesn’t drop any defaults you rely on.

Also applies to: 196-202

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ffc6ea and 3e1aefe.

📒 Files selected for processing (9)
  • examples/react-externals/README.md (1 hunks)
  • examples/react-externals/package.json (1 hunks)
  • examples/react-externals/rslib-reactlynx.config.ts (1 hunks)
  • packages/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md (1 hunks)
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2 hunks)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js (1 hunks)
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/webpack/externals-loading-webpack-plugin/etc/externals-loading-webpack-plugin.api.md
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/not-overrides-existed-externals/index.js
  • examples/react-externals/rslib-reactlynx.config.ts
  • examples/react-externals/package.json
  • packages/webpack/externals-loading-webpack-plugin/test/cases/externals-loading/filter-duplicate-externals/index.js
🧰 Additional context used
📓 Path-based instructions (1)
packages/**/etc/*.api.md

📄 CodeRabbit inference engine (AGENTS.md)

Always commit API extractor output after running pnpm turbo api-extractor -- --local (commit updated API report files)

Files:

  • packages/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md
🧠 Learnings (10)
📓 Common learnings
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.
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: 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: 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.
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: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.
📚 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/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • examples/react-externals/README.md
📚 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/rspeedy/lynx-bundle-rslib-config/etc/lynx-bundle-rslib-config.api.md
  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
  • examples/react-externals/README.md
📚 Learning: 2025-11-04T10:15:14.965Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1899
File: packages/react/runtime/__test__/snapshotPatch.test.jsx:725-749
Timestamp: 2025-11-04T10:15:14.965Z
Learning: In packages/react/runtime/src/snapshot.ts, the snapshotCreatorMap type signature uses `Record<string, (uniqId: string) => string>` (returning string) rather than void for backward compatibility. Old lazy bundles still use the pattern `const snapshot_xxx = createSnapshot(...)` directly, which requires createSnapshot to return a value. The snapshotCreatorMap creators that wrap createSnapshot calls must maintain the same return type to support these legacy bundles.

Applied to files:

  • packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts
📚 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:

  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/README.md
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • examples/react-externals/README.md
📚 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:

  • examples/react-externals/README.md
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • examples/react-externals/README.md
🪛 LanguageTool
examples/react-externals/README.md

[style] ~7-~7: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...nt library to a separate Lynx bundle. - Use `@lynx-js/externals-loading-webpack-plu...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

⏰ 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). (4)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
  • GitHub Check: test-rust / clippy
🔇 Additional comments (1)
examples/react-externals/README.md (1)

11-16: Great job fixing the URL syntax.

The EXTERNAL_BUNDLE_PREFIX example has been corrected to use valid host:port syntax (http://${YOUR_IP_HERE}:8080). Well done resolving the prior review feedback.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/react-externals/rslib-reactlynx.config.ts (1)

20-31: Consider consistent property ordering across rules.

The first rule has test → issuerLayer → loader while the second has issuerLayer → test → loader. Aligning the property order improves readability.

           {
-            issuerLayer: LAYERS.MAIN_THREAD,
             test: /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
+            issuerLayer: LAYERS.MAIN_THREAD,
             loader: ReactWebpackPlugin.loaders.MAIN_THREAD,
           },
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e1aefe and 38c2a94.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • examples/react-externals/package.json (1 hunks)
  • examples/react-externals/rslib-comp-lib.config.ts (1 hunks)
  • examples/react-externals/rslib-reactlynx.config.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/react-externals/package.json
🧰 Additional context used
🧠 Learnings (19)
📓 Common learnings
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: 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.
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: 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: 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.
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/rspeedy/create-rspeedy/template-react-vitest-rltl-js/vitest.config.js` is a template file for scaffolding new Rspeedy projects, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-08-06T13:28:57.182Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1453
File: vitest.config.ts:49-61
Timestamp: 2025-08-06T13:28:57.182Z
Learning: In the lynx-family/lynx-stack repository, the file `packages/react/testing-library/src/vitest.config.js` is source code for the testing library that gets exported for users, not a test configuration that should be included in the main vitest projects array.

Applied to files:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.ts
📚 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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-comp-lib.config.ts
  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-08-19T11:25:36.127Z
Learnt from: colinaaa
Repo: lynx-family/lynx-stack PR: 1558
File: .changeset/solid-squids-fall.md:2-2
Timestamp: 2025-08-19T11:25:36.127Z
Learning: In the lynx-family/lynx-stack repository, changesets should use the exact package name from package.json#name, not generic or unscoped names. Each package has its own specific scoped name (e.g., "lynx-js/react-transform" for packages/react/transform).

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-08-11T05:59:28.530Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:4-6
Timestamp: 2025-08-11T05:59:28.530Z
Learning: In the lynx-family/lynx-stack repository, the `packages/react/testing-library` package does not have `vite` as a direct dependency. It relies on `vitest` being available from the monorepo root and accesses Vite types through re-exports from `vitest/node`. Direct imports from `vite` should not be suggested for this package.

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-09-18T08:12:56.802Z
Learnt from: Sherry-hue
Repo: lynx-family/lynx-stack PR: 1770
File: packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts:316-318
Timestamp: 2025-09-18T08:12:56.802Z
Learning: In packages/web-platform/web-mainthread-apis/src/utils/processStyleInfo.ts, the current implementation uses cardStyleElement.textContent += for lazy component styles. While this could theoretically invalidate rule indices by reparsing the stylesheet, Sherry-hue indicated that UIDs don't repeat for the same element, making this approach acceptable for now. A future optimization to use separate style elements per entry was discussed but deferred to a separate PR to keep the current lazy bundle PR focused.

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-08-21T07:21:51.621Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1562
File: packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs:261-283
Timestamp: 2025-08-21T07:21:51.621Z
Learning: In packages/react/transform/src/swc_plugin_snapshot/jsx_helpers.rs, the team prefers to keep the original unreachable! logic for JSXSpreadChild in jsx_is_children_full_dynamic function rather than implementing defensive error handling.

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.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:

  • examples/react-externals/rslib-reactlynx.config.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 packages/react/transform/src/swc_plugin_compat/mod.rs, the `add_pure_comment` function at 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. These are two distinct code paths that should be treated differently.

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.ts
📚 Learning: 2025-08-11T06:00:04.376Z
Learnt from: upupming
Repo: lynx-family/lynx-stack PR: 1305
File: packages/react/testing-library/src/plugins/vitest.ts:59-61
Timestamp: 2025-08-11T06:00:04.376Z
Learning: In the lynx-family/lynx-stack repository, the `testingLibraryPlugin` in `packages/react/testing-library/src/plugins/vitest.ts` intentionally uses `process.exit` when jsdom installation fails, maintaining consistency with the previous implementation from `packages/react/testing-library/src/vitest.config.js`. This behavior should not be changed to use `this.error` despite being a Vite plugin best practice.

Applied to files:

  • examples/react-externals/rslib-reactlynx.config.ts
📚 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:

  • examples/react-externals/rslib-reactlynx.config.ts
🧬 Code graph analysis (2)
examples/react-externals/rslib-comp-lib.config.ts (2)
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2)
  • defineExternalBundleRslibConfig (187-210)
  • LAYERS (32-35)
packages/rspeedy/plugin-react-alias/src/index.ts (1)
  • pluginReactAlias (23-214)
examples/react-externals/rslib-reactlynx.config.ts (2)
packages/rspeedy/lynx-bundle-rslib-config/src/externalBundleRslibConfig.ts (2)
  • defineExternalBundleRslibConfig (187-210)
  • LAYERS (32-35)
packages/rspeedy/plugin-react-alias/src/index.ts (1)
  • pluginReactAlias (23-214)
⏰ 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). (4)
  • GitHub Check: build / Build (Ubuntu)
  • GitHub Check: build / Build (Windows)
  • GitHub Check: test-rust / Test (Ubuntu)
  • GitHub Check: test-rust / clippy
🔇 Additional comments (7)
examples/react-externals/rslib-reactlynx.config.ts (3)

1-14: LGTM on imports and module resolution setup.

The imports follow the codebase convention of using default imports for Node.js built-in modules. The createRequire pattern for resolving the @lynx-js/react package directory is idiomatic for ESM.


35-47: LGTM on source configuration.

The entry point and define constants are properly configured. The string-wrapped boolean values ('false') are correct for the DefinePlugin pattern.


48-57: LGTM on plugins and output configuration.

The pluginReactAlias usage correctly passes LAYERS and rootPath matching its expected signature. Disabling cleanDistPath and minify is reasonable for external bundle builds.

examples/react-externals/rslib-comp-lib.config.ts (4)

1-9: LGTM!

Imports follow codebase conventions: default imports for Node.js built-ins and proper usage of the @lynx-js package APIs. Based on learnings, the default import pattern for Node.js modules is the preferred style in this repository.


11-14: LGTM!

Standard ESM pattern for resolving the @lynx-js/react package location using createRequire with import.meta.url.


16-54: LGTM!

Configuration is well-structured:

  • Module rules correctly apply layer-specific loaders using LAYERS.BACKGROUND and LAYERS.MAIN_THREAD
  • Production-appropriate define values for the bundle
  • pluginReactAlias configured with required LAYERS and rootPath options

55-78: LGTM!

Output configuration is appropriate for an external bundle:

  • dataUriLimit: Number.POSITIVE_INFINITY ensures assets are inlined
  • Comprehensive externals mapping for the Lynx React ecosystem modules to the ReactLynx global namespace
  • minify: false is reasonable since downstream consumers can handle minification

upupming
upupming previously approved these changes Dec 15, 2025
@luhc228 luhc228 merged commit 40b3006 into lynx-family:main Dec 15, 2025
81 of 86 checks passed
@luhc228 luhc228 deleted the feat/init-externals-loading-webpack-plugin branch December 16, 2025 08:20
f0rdream pushed a commit to f0rdream/lynx-stack that referenced this pull request Dec 18, 2025
…ily#1924)

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

<!-- The AI summary below will be auto-generated - feel free to replace
it with your own. -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## New Features

* **Externals Loading Plugin for Webpack**: Introduced a new Webpack
plugin enabling dynamic external module loading for Lynx applications.
The plugin provides support for both asynchronous and synchronous
loading modes, automatically handles deduplication of external libraries
by name, and offers flexible layer-based configuration for
differentiating loading behavior between background and main-thread
execution contexts.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

## Checklist

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

- [ ] Tests updated (or not required).
- [ ] Documentation updated (or not required).
- [ ] Changeset added, and when a BREAKING CHANGE occurs, it needs to be
clearly marked (or not required).

---------

Co-authored-by: Yiming Li <yimingli.cs@gmail.com>
colinaaa pushed a commit that referenced this pull request Dec 22, 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/gesture-runtime@2.1.0

### Minor Changes

- Initialize `'@lynx-js/gesture-runtime`
([#1984](#1984))

## @lynx-js/rspeedy@0.12.3

### Patch Changes

- Support environment variants to enable multiple configurations for the
same targets.
([#1969](#1969))

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.2

## @lynx-js/lynx-bundle-rslib-config@0.0.2

### Patch Changes

- Introduce `@lynx-js/externals-loading-webpack-plugin`. It will help
you to load externals built by `@lynx-js/lynx-bundle-rslib-config`.
([#1924](#1924))

    ```js
    // webpack.config.js
import { ExternalsLoadingPlugin } from
"@lynx-js/externals-loading-webpack-plugin";

    export default {
      plugins: [
        new ExternalsLoadingPlugin({
          mainThreadLayer: "main-thread",
          backgroundLayer: "background",
          externals: {
            lodash: {
              url: "http://lodash.lynx.bundle",
              background: { sectionPath: "background" },
              mainThread: { sectionPath: "main-thread" },
            },
          },
        }),
      ],
    };
    ```

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

### Patch Changes

- Support environment variants to enable multiple configurations for the
same targets.
([#1969](#1969))

-   Updated dependencies \[]:
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.2

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

### Patch Changes

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

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

### Patch Changes

- chore: mark the "multi-thread" deprecated
([#2030](#2030))

    **NOTICE This will be a breaking change in the future**

    mark the thread strategy "multi-thread" as deprecated.

Please use "all-on-ui" instead. If you still want to use multi-thread
mode, please try to use a cross-origin isolated iframe.

A console warning will be printed if `thread-strategy` is set to
`multi-thread`.

- fix csp issue for mts realm
([#1998](#1998))

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.2
    -   @lynx-js/web-mainthread-apis@0.19.2
    -   @lynx-js/web-worker-rpc@0.19.2
    -   @lynx-js/web-worker-runtime@0.19.2

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

### Patch Changes

- fix: web-explorer needs to actively send an iframeReady message to the
parent, the parent uses `iframe load` listener cannot guarantee that the
`message-listener` will complete execution.
([#2001](#2001))

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.2

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

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.2
    -   @lynx-js/web-mainthread-apis@0.19.2
    -   @lynx-js/web-worker-rpc@0.19.2

## @lynx-js/externals-loading-webpack-plugin@0.0.1

### Patch Changes

- Introduce `@lynx-js/externals-loading-webpack-plugin`. It will help
you to load externals built by `@lynx-js/lynx-bundle-rslib-config`.
([#1924](#1924))

    ```js
    // webpack.config.js
import { ExternalsLoadingPlugin } from
"@lynx-js/externals-loading-webpack-plugin";

    export default {
      plugins: [
        new ExternalsLoadingPlugin({
          mainThreadLayer: "main-thread",
          backgroundLayer: "background",
          externals: {
            lodash: {
              url: "http://lodash.lynx.bundle",
              background: { sectionPath: "background" },
              mainThread: { sectionPath: "main-thread" },
            },
          },
        }),
      ],
    };
    ```

## create-rspeedy@0.12.3



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



## upgrade-rspeedy@0.12.3



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



## @lynx-js/web-rsbuild-server-middleware@0.19.2



## @lynx-js/web-worker-rpc@0.19.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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants