Skip to content

feat: support bundle and load css in external bundle#2143

Open
upupming wants to merge 20 commits intomainfrom
feat/rslib-css
Open

feat: support bundle and load css in external bundle#2143
upupming wants to merge 20 commits intomainfrom
feat/rslib-css

Conversation

@upupming
Copy link
Collaborator

@upupming upupming commented Jan 27, 2026

Summary by CodeRabbit

  • New Features

    • Support for bundling and loading CSS in external bundles, including main-thread stylesheet adoption and flush handling
    • Example updated to ensure external CSS loads reliably; CSS handling now applied unconditionally
  • Bug Fixes

    • Improved error logging for external bundle load failures
  • Tests

    • Added tests and fixtures to verify CSS is included and decoded in external bundles
  • Chores

    • Dependency updates to support CSS serialization and parsing

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

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: a80ede6

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

This PR includes changesets to release 5 packages
Name Type
@lynx-js/externals-loading-webpack-plugin Patch
@lynx-js/lynx-bundle-rslib-config Patch
@lynx-js/react-rsbuild-plugin Patch
@lynx-js/external-bundle-rsbuild-plugin Patch
@lynx-js/react-alias-rsbuild-plugin Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds CSS extraction, serialization, and runtime loading for external bundles: encoder emits CSS custom-sections, React plugin loader behavior updated, externals runtime loads/adopts styles on main-thread, and deps/tests/examples updated to cover CSS in external bundles.

Changes

Cohort / File(s) Summary
Changeset
/.changeset/thick-needles-rest.md
Adds a changeset declaring patch releases for three packages with note "Support bundle and load css in external bundle".
Examples
examples/react-externals/src/index.css, examples/react-externals/src/index.tsx
Adds minimal CSS to trigger engine load and switches the example import to the new CSS file.
Dependencies
packages/rspeedy/lynx-bundle-rslib-config/package.json, packages/webpack/template-webpack-plugin/package.json
Adds @lynx-js/css-serializer and bumps @lynx-js/tasm to 0.0.26.
External bundle encoder
packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts
Encodes extracted CSS into :CSS custom-sections (uses cssChunksToMap → ruleList) and enables CSS-related compiler options.
Tests & fixtures
packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts, packages/rspeedy/lynx-bundle-rslib-config/test/fixtures/css-lib/*
Adds css-lib fixture (CSS + TS) and a test asserting external bundle includes index, index:CSS, and index__main-thread.
React plugin CSS handling
packages/rspeedy/plugin-react/src/css.ts, packages/rspeedy/plugin-react/src/pluginReactLynx.ts
Removes built-in ignore-css loader, ensures MiniCssExtract is registered earlier, reorders custom loader insertion, and calls applyCSS unconditionally.
Externals runtime & test env
packages/webpack/externals-loading-webpack-plugin/src/index.ts, packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
Adds main-thread layer detection and runtime calls to load/adopt/flush styles; improves error logging and stubs __LoadStyleSheet, __AdoptStyleSheet, __FlushElementTree in test env.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested reviewers

  • colinaaa
  • luhc228

Poem

🐇 I nibbled bytes and patched a seam,
Wove tiny rules into the bundle's dream,
Main-thread wakes the styled parade,
Leaves of CSS in a cozy braid,
Hop — the app dons a brand-new theme. 🎨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'feat: support bundle and load css in external bundle' clearly and specifically describes the main feature being added across the changeset—enabling CSS bundling and loading in external bundles.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/rslib-css

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.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 27, 2026

Merging this PR will improve performance by 7.69%

⚡ 2 improved benchmarks
✅ 70 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
basic-performance-nest-level-100 7.4 ms 6.9 ms +7.69%
transform 1000 view elements 44.9 ms 42.1 ms +6.5%

Comparing feat/rslib-css (a80ede6) with main (6cbe5d8)

Open in CodSpeed

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

relativeci bot commented Jan 27, 2026

Web Explorer

#7943 Bundle Size — 383.53KiB (0%).

a80ede6(current) vs 6cbe5d8 main#7929(baseline)

Bundle metrics  Change 1 change
                 Current
#7943
     Baseline
#7929
No change  Initial JS 154.63KiB 154.63KiB
No change  Initial CSS 35.1KiB 35.1KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
Change  Modules 238(-0.42%) 239
No change  Duplicate Modules 16 16
No change  Duplicate Code 2.99% 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#7943
     Baseline
#7929
No change  JS 252.58KiB 252.58KiB
No change  Other 95.85KiB 95.85KiB
No change  CSS 35.1KiB 35.1KiB

Bundle analysis reportBranch feat/rslib-cssProject dashboard


Generated by RelativeCIDocumentationReport issue

@upupming upupming changed the base branch from main to feat/cssChunksToMap February 24, 2026 11:38
@upupming upupming marked this pull request as ready for review February 24, 2026 11:38
upupming added a commit that referenced this pull request Feb 25, 2026
…r` (#2269)

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

## Release Notes

* **Bug Fixes**
* Patched @lynx-js/template-webpack-plugin and @lynx-js/css-serializer.

* **New Features**
  * Exposed CSS namespace directly from @lynx-js/css-serializer.
  * Added CSSPlugins export with parserPlugins property.
* Made cssChunksToMap available as a public export from
@lynx-js/css-serializer.

* **Chores**
* Updated test imports and configuration for improved module resolution.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

In #2143, we need to use `cssChunksToMap` in
`@lynx-js/lynx-bundle-rslib-config` package.

To avoid repeating ourselves, we extract the `cssChunksToMap` API from
`@lynx-js/template-webpack-plugin` to `@lynx-js/css-serializer`.

## Checklist

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

- [x] Tests updated (or not required).
- [ ] Documentation updated (or not required).
- [x] Changeset added, and when a BREAKING CHANGE occurs, it needs to be
clearly marked (or not required).
Base automatically changed from feat/cssChunksToMap to main February 25, 2026 09:03
Copy link
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

♻️ Duplicate comments (1)
packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md (1)

19-24: No direct edit needed in generated API report.

This warning is a downstream artifact from packages/webpack/template-webpack-plugin/src/index.ts; fixing the source declaration is the right path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md`
around lines 19 - 24, The API report flags CSSPlugins as missing a release tag;
update the source export for CSSPlugins in the module where it's declared by
adding a JSDoc release tag (e.g., /** `@public` */) above the export so the
generated declaration includes the tag, and ensure the related Plugins type used
in the CSSPlugins.parserPlugins typing is correctly exported/imported (symbols:
CSSPlugins, Plugins) so the API extractor can resolve types.
🧹 Nitpick comments (1)
packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts (1)

118-153: Prefer mutating the reducer accumulator to avoid repeated object cloning.

Line 118-Line 153 rebuilds prev with object spread on every asset. This creates avoidable O(n²)-style allocation churn for larger builds.

♻️ Suggested refactor
- const customSections = assets
-   .reduce<Record<string, { content: string | { ruleList: LynxStyleNode[] } }>>(
-     (prev, cur) => {
-       switch (cur.info['assetType']) {
-         case 'javascript':
-           return ({
-             ...prev,
-             [cur.name.replace(/\.js$/, '')]: {
-               content: cur.source.source().toString(),
-             },
-           })
-         case 'extract-css':
-           return ({
-             ...prev,
-             [`${cur.name.replace(/\.css$/, '')}:CSS`]: {
-               'encoding': 'CSS',
-               content: {
-                 ruleList: cssChunksToMap(
-                   [cur.source.source().toString()],
-                   [],
-                   true,
-                 ).cssMap[0] ?? [],
-               },
-             },
-           })
-         default:
-           return prev
-       }
-     },
-     {},
-   )
+ const customSections: Record<string, { content: string | { ruleList: LynxStyleNode[] } }> = {}
+ for (const cur of assets) {
+   switch (cur.info['assetType']) {
+     case 'javascript':
+       customSections[cur.name.replace(/\.js$/, '')] = {
+         content: cur.source.source().toString(),
+       }
+       break
+     case 'extract-css':
+       customSections[`${cur.name.replace(/\.css$/, '')}:CSS`] = {
+         encoding: 'CSS',
+         content: {
+           ruleList: cssChunksToMap([cur.source.source().toString()], [], true).cssMap[0] ?? [],
+         },
+       } as never
+       break
+     default:
+       break
+   }
+ }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts`
around lines 118 - 153, The reducer currently rebuilds the accumulator with
object spread on each iteration causing O(n²) allocations; in the reduce
callback (the function passed to .reduce in ExternalBundleWebpackPlugin) stop
returning new objects and instead mutate the accumulator `prev`: for
'javascript' set prev[cur.name.replace(/\.js$/, '')] = { content:
cur.source.source().toString() } and for 'extract-css' set
prev[`${cur.name.replace(/\.css$/, '')}:CSS`] = { encoding: 'CSS', content: {
ruleList: cssChunksToMap([cur.source.source().toString()], [], true).cssMap[0]
?? [] } }; then return prev; keep the reduce generic/typing for Record<string, {
content: string | { ruleList: LynxStyleNode[] } }> unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/react-externals/src/index.css`:
- Line 8: The empty CSS rule `.dummy {}` is failing Stylelint's
`block-no-empty`; update the `.dummy` rule to be non-empty (e.g., add a harmless
declaration like `display: block;` or a comment/declaration that preserves the
trigger behavior) so the selector remains but the block no longer violates
`block-no-empty`; locate the `.dummy` rule in the CSS and add the single
non-empty declaration or comment inside it.

In `@packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts`:
- Around line 172-201: The test sets an environment stub via vi.stubEnv('DEBUG',
'rsbuild,rslib,rspack') but never restores it, causing cross-test leakage;
change the call to capture the returned restore function (e.g., const
restoreDebug = vi.stubEnv(...)) and call restoreDebug() after the
build/decode/assertions (or in a finally block) so the DEBUG env is reset for
subsequent tests; reference vi.stubEnv in the test around the
build(rslibConfig)/decodeTemplate(...)/assert expectations to locate where to
add the restore call.

In `@packages/webpack/externals-loading-webpack-plugin/src/index.ts`:
- Line 330: Replace the hard-coded '__main-thread' suffix used when deriving the
CSS section name with the configured mainThreadLayer value: instead of
sectionPath.replace('__main-thread', '') + ':CSS' use
sectionPath.replace(mainThreadLayer, '') + ':CSS' (apply the same change in both
the async and sync branches where __LoadStyleSheet is called), so that
__LoadStyleSheet(sectionPath.replace(mainThreadLayer, '') + ':CSS',
response.url) correctly resolves customized main thread layer names.
- Line 340: The catch path builds an Error message using error.message which can
throw if a non-Error (null/primitive) was thrown; replace the direct access with
a guarded conversion: derive a safeMessage by checking if error is an object
with a message property and using that, otherwise use String(error) (or a
default string), then construct the new Error with that safeMessage and set the
cause only when appropriate (or pass the original thrown value as cause if
supported). Apply the same guarded logic to both occurrences where reject(new
Error('Failed to load script ' + sectionPath + ' in ' + response.url + ': ' +
error.message, { cause: error })) is used so non-Error throws are handled
safely.

---

Duplicate comments:
In `@packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md`:
- Around line 19-24: The API report flags CSSPlugins as missing a release tag;
update the source export for CSSPlugins in the module where it's declared by
adding a JSDoc release tag (e.g., /** `@public` */) above the export so the
generated declaration includes the tag, and ensure the related Plugins type used
in the CSSPlugins.parserPlugins typing is correctly exported/imported (symbols:
CSSPlugins, Plugins) so the API extractor can resolve types.

---

Nitpick comments:
In
`@packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts`:
- Around line 118-153: The reducer currently rebuilds the accumulator with
object spread on each iteration causing O(n²) allocations; in the reduce
callback (the function passed to .reduce in ExternalBundleWebpackPlugin) stop
returning new objects and instead mutate the accumulator `prev`: for
'javascript' set prev[cur.name.replace(/\.js$/, '')] = { content:
cur.source.source().toString() } and for 'extract-css' set
prev[`${cur.name.replace(/\.css$/, '')}:CSS`] = { encoding: 'CSS', content: {
ruleList: cssChunksToMap([cur.source.source().toString()], [], true).cssMap[0]
?? [] } }; then return prev; keep the reduce generic/typing for Record<string, {
content: string | { ruleList: LynxStyleNode[] } }> unchanged.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9033e2d and bd1dfa6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (27)
  • .changeset/thick-needles-rest.md
  • .changeset/wet-rockets-taste.md
  • examples/react-externals/src/index.css
  • examples/react-externals/src/index.tsx
  • packages/rspeedy/lynx-bundle-rslib-config/package.json
  • packages/rspeedy/lynx-bundle-rslib-config/src/webpack/ExternalBundleWebpackPlugin.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/rspeedy/lynx-bundle-rslib-config/test/fixtures/css-lib/index.css
  • packages/rspeedy/lynx-bundle-rslib-config/test/fixtures/css-lib/index.ts
  • packages/rspeedy/plugin-react/src/css.ts
  • packages/rspeedy/plugin-react/src/pluginReactLynx.ts
  • packages/tools/css-serializer/src/css/ast.ts
  • packages/tools/css-serializer/src/css/cssChunksToMap.ts
  • packages/tools/css-serializer/src/css/debundle.ts
  • packages/tools/css-serializer/src/css/index.ts
  • packages/tools/css-serializer/src/index.ts
  • packages/tools/css-serializer/test/css.test.ts
  • packages/tools/css-serializer/vitest.config.ts
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/externals-loading-webpack-plugin/test/helpers/setup-env.js
  • packages/webpack/template-webpack-plugin/etc/template-webpack-plugin.api.md
  • packages/webpack/template-webpack-plugin/package.json
  • packages/webpack/template-webpack-plugin/src/LynxTemplatePlugin.ts
  • packages/webpack/template-webpack-plugin/src/WebEncodePlugin.ts
  • packages/webpack/template-webpack-plugin/src/css/index.ts
  • packages/webpack/template-webpack-plugin/src/index.ts
  • packages/webpack/template-webpack-plugin/src/web/genStyleInfo.ts
💤 Files with no reviewable changes (1)
  • packages/webpack/template-webpack-plugin/src/css/index.ts

Copy link
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.

♻️ Duplicate comments (2)
packages/webpack/externals-loading-webpack-plugin/src/index.ts (2)

341-341: ⚠️ Potential issue | 🟡 Minor

Harden catch-path message construction for non-Error throws.

Line 341 and Line 368 assume error.message exists; primitives/null can cause a second failure in error handling.

🛡️ Suggested fix
- reject(new Error('Failed to load script ' + sectionPath + ' in ' + response.url + ': ' + error.message, { cause: error }))
+ const reason = (error && typeof error === 'object' && 'message' in error)
+   ? String(error.message)
+   : String(error);
+ reject(new Error('Failed to load script ' + sectionPath + ' in ' + response.url + ': ' + reason, { cause: error }))
- throw new Error('Failed to load script ' + sectionPath + ' in ' + response.url + ': ' + error.message, { cause: error })
+ const reason = (error && typeof error === 'object' && 'message' in error)
+   ? String(error.message)
+   : String(error);
+ throw new Error('Failed to load script ' + sectionPath + ' in ' + response.url + ': ' + reason, { cause: error })

Also applies to: 368-368

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/webpack/externals-loading-webpack-plugin/src/index.ts` at line 341,
The catch-path builds a new Error using error.message which can throw if the
thrown value is null/primitive; replace uses of error.message in the reject(new
Error(..., { cause: error })) expression with a safe stringifier (e.g. const
safeMsg = (error && typeof error === 'object' && 'message' in error) ? (error as
Error).message : String(error)) and use safeMsg in the constructed message, and
optionally only pass cause when error is an Error instance (e.g. cause: error
instanceof Error ? error : undefined) to harden both occurrences that currently
reference error.message.

330-331: ⚠️ Potential issue | 🟠 Major

Use configured main-thread suffix for CSS section derivation.

Line 330 and Line 357 still hard-code __main-thread, so CSS lookup can fail when mainThreadLayer is customized.

🔧 Suggested fix
- const styleSheet = __LoadStyleSheet(sectionPath.replace('__main-thread', '') + ':CSS', response.url);
+ const mainThreadSuffix = '__${externalsLoadingPluginOptions.mainThreadLayer}';
+ const cssSectionPath = sectionPath.endsWith(mainThreadSuffix)
+   ? sectionPath.slice(0, -mainThreadSuffix.length)
+   : sectionPath;
+ const styleSheet = __LoadStyleSheet(cssSectionPath + ':CSS', response.url);

Also applies to: 357-358

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/webpack/externals-loading-webpack-plugin/src/index.ts` around lines
330 - 331, Replace the hard-coded "__main-thread" string with the configured
main-thread suffix (mainThreadLayer) when deriving the CSS section path: change
the calls that compute the CSS lookup (the sectionPath.replace('__main-thread',
'') + ':CSS' used before passing to __LoadStyleSheet) to remove the configured
mainThreadLayer instead of the literal, and apply the same change to the other
occurrence that currently uses "__main-thread"; ensure you remove only the
suffix instance of mainThreadLayer from sectionPath (preserving other parts)
before appending ":CSS" and calling __LoadStyleSheet(response.url).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/webpack/externals-loading-webpack-plugin/src/index.ts`:
- Line 341: The catch-path builds a new Error using error.message which can
throw if the thrown value is null/primitive; replace uses of error.message in
the reject(new Error(..., { cause: error })) expression with a safe stringifier
(e.g. const safeMsg = (error && typeof error === 'object' && 'message' in error)
? (error as Error).message : String(error)) and use safeMsg in the constructed
message, and optionally only pass cause when error is an Error instance (e.g.
cause: error instanceof Error ? error : undefined) to harden both occurrences
that currently reference error.message.
- Around line 330-331: Replace the hard-coded "__main-thread" string with the
configured main-thread suffix (mainThreadLayer) when deriving the CSS section
path: change the calls that compute the CSS lookup (the
sectionPath.replace('__main-thread', '') + ':CSS' used before passing to
__LoadStyleSheet) to remove the configured mainThreadLayer instead of the
literal, and apply the same change to the other occurrence that currently uses
"__main-thread"; ensure you remove only the suffix instance of mainThreadLayer
from sectionPath (preserving other parts) before appending ":CSS" and calling
__LoadStyleSheet(response.url).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bd3ba9 and c07a9a2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/rspeedy/lynx-bundle-rslib-config/test/external-bundle.test.ts
  • packages/webpack/externals-loading-webpack-plugin/src/index.ts
  • packages/webpack/template-webpack-plugin/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/webpack/template-webpack-plugin/package.json

luhc228
luhc228 previously approved these changes Mar 3, 2026
"@lynx-js/runtime-wrapper-webpack-plugin": "workspace:*",
"@lynx-js/tasm": "0.0.20"
"@lynx-js/tasm": "0.0.26",
"css-tree": "^3.1.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like the css-tree package has never been used.

Comment on lines +145 to +159
function removeIgnoreCSS(rule: ReturnType<typeof chain.module.rule>) {
if (
// Rslib has a builtin ignore-css-loader
// We need to remove it and use our own ignore-css-loader
rule.uses.has(CHAIN_ID.USE.IGNORE_CSS)
) {
rule.uses.delete(CHAIN_ID.USE.IGNORE_CSS)
}
}

if (!chain.plugins.has(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)) {
chain
.plugin(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)
.use(CssExtractPlugin)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be related with output.emitCss option, which defaults to true when output.target === 'web'.

Instead of changing the underlying loader rules, we should set output.target to 'web' in the Rslib config.

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.

3 participants