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

[antd, mantine] Content script ui compiled error when using UI components #703

Closed
5 tasks done
hussion opened this issue Jun 4, 2024 · 9 comments
Closed
5 tasks done
Labels
bug Something isn't working contribution welcome

Comments

@hussion
Copy link

hussion commented Jun 4, 2024

Describe the bug

As long as in the content script ui (Such as: entrypoints/example-ui.content/App.tsx), reference to the component of the three-party component library antd, the compilation error will be reported, in the configuration of vite, sourcemap off still failed to compile; This is normal in popup or other newtab pages

Errors are as follows:
image

Reproduction

wxx-react.zip

Steps to reproduce

Run pnpm dev

System Info

System:
    OS: macOS 13.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 120.82 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.2 - ~/.nvm/versions/node/v18.20.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.2/bin/npm
    pnpm: 9.1.4 - ~/.nvm/versions/node/v18.20.2/bin/pnpm
  Browsers:
    Chrome: 125.0.6422.142
    Safari: 16.5
  npmPackages:
    wxt: ^0.18.4 => 0.18.4

Used Package Manager

pnpm

Validations

@hussion hussion added the pending-triage Someone (usually a maintainer) needs to look into this to see if it's a bug label Jun 4, 2024
@hussion
Copy link
Author

hussion commented Jun 5, 2024

@aklinker1 Do you have time to take a look?

@aklinker1
Copy link
Collaborator

aklinker1 commented Jun 8, 2024

Sorry, no idea what is going on. Reproduction is good. There aren't sourcemaps provided by antd, so I'm not sure why Vite is attempting to load them, nor what the original error is.

If someone else wants to debug this, feel free. I don't have time right now.

@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 Jun 8, 2024
@aklinker1
Copy link
Collaborator

Also seeing this with mantine, see the new react-mantine example. Seems related to something in the react ecosystem... Not seeing anything like this with other frameworks.

@hussion
Copy link
Author

hussion commented Jun 20, 2024

Also seeing this with mantine, see the new react-mantine example. Seems related to something in the react ecosystem... Not seeing anything like this with other frameworks.

yeah, The issue at hand is causing significant frustration, to the extent that I had to switch the component library. Even when attempting to block error information in the configuration file, it seems like it may impact compilation speed. It is my hope that someone can provide a solution for this matter.

@aklinker1
Copy link
Collaborator

Discovered something maybe relevant here today? If you add a package to vite's ssr.noExternal array, it can cause similar logs. Not an exact match, but wanted to share here:

// wxt.config.ts
  vite: () => ({
    plugins: [Icons({ compiler: "vue3" }), Vue()],
+   ssr: {
+     noExternal: [/.*/],
+   },
  }),
✔ Started dev server @ http://localhost:3000                                                        5:33:48 PM
ℹ Pre-rendering chrome-mv3 for development with Vite 5.3.1                                          5:33:48 PM
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/htmlparser2@9.1.0/node_modules/htmlparser2/lib/esm/index.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/index.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/htmlparser2@9.1.0/node_modules/htmlparser2/lib/esm/Parser.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/index.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/htmlparser2@9.1.0/node_modules/htmlparser2/lib/esm/Tokenizer.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/pseudo-selectors/index.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/compile.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/decode.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/querying.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/stringify.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/legacy.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/manipulation.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/traversal.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/helpers.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/domutils@3.1.0/node_modules/domutils/lib/esm/feeds.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/pseudo-selectors/filters.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/sort.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/generated/decode-data-xml.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/css-select@5.1.0/node_modules/css-select/lib/esm/general.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/decode_codepoint.js" points to missing source files
Sourcemap for "/Users/aklinker1/Development/github.com/aklinker1/github-better-line-counts/node_modules/.pnpm/entities@4.5.0/node_modules/entities/lib/esm/generated/decode-data-html.js" points to missing source files
...

There was about 4x as many logs as I've shown above, truncated it for clarity.

@hussion
Copy link
Author

hussion commented Jun 21, 2024

@aklinker1 may be the same issue : vite issue, You see if it helps.

@aklinker1 aklinker1 added the vite plugin Issue related to integrating a specific vite plugin label Jul 6, 2024
@aklinker1 aklinker1 changed the title content script ui compiled error when using UI components [antd, mantine] Content script ui compiled error when using UI components Jul 6, 2024
@aklinker1 aklinker1 removed the vite plugin Issue related to integrating a specific vite plugin label Jul 6, 2024
@1natsu172
Copy link
Contributor

@hussion

I also encountered this issue before. The conclusion is that it's a problem with Vite (Rollup), not WXT. The issue arises because the presence of directives (like use client;) in React components isn't accounted for, causing the generated sourcemap lines to be misaligned.

While many people in the thread ignore the warning, I found that broken sourcemaps cause issues, so I've been using the https://github.com/huozhi/rollup-preserve-directives solution from that answer as a workaround.

However, using this plugin can significantly increase build times and degrade performance. 🙃

@1natsu172
Copy link
Contributor

The vite team seems to have decided to ignore the warning vitejs/vite-plugin-react#369. Next release of vite-plugin-react will have no warnings.

@aklinker1
Copy link
Collaborator

Gonna close this then! Thanks for finding that @1natsu172

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

No branches or pull requests

3 participants