Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
1natsu172 opened this issue Aug 28, 2024 · 3 comments
Open
5 tasks done

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

1natsu172 opened this issue Aug 28, 2024 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@1natsu172
Copy link
Contributor

1natsu172 commented Aug 28, 2024

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

@1natsu172 1natsu172 added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Aug 28, 2024
@1natsu172
Copy link
Contributor Author

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

@aklinker1
Copy link
Collaborator

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.

@1natsu172
Copy link
Contributor Author

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.

@aklinker1 aklinker1 added bug Something isn't working and removed pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug labels Aug 29, 2024
@aklinker1 aklinker1 added this to the v1.0 milestone Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants