wxt-dev / wxt-dev/wxt

The common code for content scripts and sidepanel is not shared (e.g., React).

Open
#1,773 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Feature Request

My extension has three entry points: two content scripts and one sidepanel. All use React, but after packaging, I found that React was not extracted into a shared module, resulting in a larger installation package size.

Is your feature request related to a bug?

It may be related to #357, but it does not meet my expectations.

It achieves code splitting by dynamically loading esm within the content script, but this causes run_at to fail. What I want is to achieve code sharing by changing all output formats to a unified iife.

What are the alternatives?

I suspect this may be due to the different export formats: the content script is iife, while the sidepanel is esm.

Would exporting both to the iife format allow Rollup to generate shared code chunks normally?

Additional context

I am currently converting an extension I have already developed to use WXT. Previously, I used Webpack, my strategy was to bundle the background script separately and then bundle all other parts together; WXT's strategy seems to be to bundle the content script separately, which led to the issue I'm raising.

The installation package size I originally generated using Webpack was 412 KB, but after switching to WXT, it increased to 633 KB.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the content-script and sidepanel entry points are bundled and compare their current IIFE and ESM outputs. Check whether a shared React module can be produced without breaking content-script run_at behavior; done means the packaged extension shares common code and avoids the reported size increase.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.