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

Load wxt.config.ts as ESM #297

Open
aklinker1 opened this issue Dec 23, 2023 · 1 comment
Open

Load wxt.config.ts as ESM #297

aklinker1 opened this issue Dec 23, 2023 · 1 comment
Labels
bug Something isn't working upstream Issue related to an upstream library

Comments

@aklinker1
Copy link
Collaborator

aklinker1 commented Dec 23, 2023

Describe the bug

Currently, WXT uses c12 (and c12 uses jiti internally) to load the wxt.config.ts file, but it is loaded as CJS.

This causes Vite 5's CJS warning to show up when importing a Vite plugin, like Vue. At the bottom of the stacktrace, you can see the warning is triggered by @vitejs/plugin-vue in this case. Same with all other vite plugins that import vite.

Screenshot 2023-12-23 at 9 38 42 AM
Trace: The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
    at warnCjsUsage (/home/runner/work/wxt/wxt/templates/vue/node_modules/vite/index.cjs:32:3)
    at Object.<anonymous> (/home/runner/work/wxt/wxt/templates/vue/node_modules/vite/index.cjs:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/runner/work/wxt/wxt/templates/vue/node_modules/@vitejs/plugin-vue/dist/index.cjs:6:14)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)

To Reproduce

repro.zip

pnpx wxt@0.12.3 init . --template vue
pnpm i
pnpm build

Note

Using v0.12.3 because the warning is silenced in later versions.

The warning is present in the prepare, build, and dev commands.

Expected behavior

The wxt.config.ts file should be imported as ESM, and these warnings should go away.

Environment

  System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 1.19 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.1 - ~/.asdf/installs/nodejs/18.16.1/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.16.1/bin/yarn
    npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.9.0 - ~/.asdf/installs/nodejs/18.16.1/bin/pnpm
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 16.5.2
  npmPackages:
    wxt: ^0.12.0 => 0.12.3

Additional context

@aklinker1 aklinker1 added triage Bug or problem that needs to be looked into bug Something isn't working upstream Issue related to an upstream library and removed triage Bug or problem that needs to be looked into labels Dec 23, 2023
@aklinker1
Copy link
Collaborator Author

Looks like this should be possible to do with c12 already... unjs/unbuild#94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Issue related to an upstream library
Projects
None yet
Development

No branches or pull requests

1 participant