Skip to content

Modified wxt.config via wxt.hook is reset on dev reloaded #939

Closed

Description

@1natsu172

Describe the bug

There is a bug that causes wxt.config modified via hook to be reset. I'm modifying the outDir, but the path is broken. The path is correct at startup dev, but the reset when the HMR reloads. This is causing content-script to not reload.

It can be reproduced with the example of separating outDir from dev and prod written in docs - https://wxt.dev/guide/go-further/reusable-modules.html#actually-doing-something.

image

This is similar to this #863 . Perhaps the cause may be the same.

Reproduction

main...1natsu172:repro-weired-ourDir-path

Steps to reproduce

cd packages/wxt-demo
pnpm dev
# save something content-script file.

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1
    Memory: 178.72 MB / 8.00 GB
    Shell: 3.7.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 22.7.0 - ~/.asdf/installs/nodejs/22.7.0/bin/node
    npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 9.6.0 - ~/.asdf/installs/nodejs/22.7.0/bin/pnpm
    bun: 1.1.25 - ~/.asdf/shims/bun
    Watchman: 2024.04.22.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 111.1.49.120
    Chrome: 128.0.6613.85
    Safari: 17.6
  npmPackages:
    wxt: workspace:* => 0.19.7

Used Package Manager

pnpm

Validations

Activity

  1. added
    pending-triage
    on Aug 28, 2024
  2. 1natsu172 commented on Aug 28, 2024

    @1natsu172
    ContributorAuthor

    I think there is probably the cause. The reloadConfig is being called, but resolveConfig is executed in the context before the hook.

    async reloadConfig() {
    wxt.config = await resolveConfig(inlineConfig, command);
    },

    // Initialize hooks
    wxt.hooks.addHooks(config.hooks);
    await wxt.hooks.callHook('ready', wxt);

  3. aklinker1 commented on Aug 28, 2024

    @aklinker1
    Member

    Duplicate of #857. Keep this open because I like your description more. Need to think more of how exactly to solve this problem. Maybe add a new hook and make people modify config in that hook instead.

  4. 1natsu172 commented on Aug 28, 2024

    @1natsu172
    ContributorAuthor

    Right, if you don't change the whole core design, a dedicated hook might be a good low-cost idea. It would be easy to understand for people.

  5. added and removed
    pending-triage
    on Aug 29, 2024
  6. added this to the v1.0 milestone on Oct 19, 2024
  7. aklinker1 commented on Nov 28, 2024

    @aklinker1
    Member

    Released in v0.19.17

  8. added theissue type on Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions