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

Vite server 500 crash when using VitePluginHelper.asset with concatenated string #455

Open
Erudition opened this issue Apr 5, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Erudition
Copy link

When I go to add VitePluginHelper.asset to my svg path strings in Elm, the server no longer works, and vite crashes with:

TypeError: Invalid value used in weak set
    at WeakSet.add (<anonymous>)
    at output (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:12529:30)
    at Object.error (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:12571:13)
    at logError (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:42888:26)
    at viteErrorMiddleware (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:42902:9)
    at call (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:48900:7)
    at next (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:48848:5)
    at call (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:48913:3)
    at next (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:48848:5)
    at call (file:///home/adroit/Projects/Minder/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-79892de8.js:48913:3)

But as soon as I take it out and leave it as a plain string, it works fine again.

@Erudition
Copy link
Author

Erudition commented Apr 5, 2023

Edit: just realized this is due to:
That string should be just a string without any concatenation.
That seems to even apply to a single variable, no concatenation... so what it's really asking for is a string literal.
I'm definitely going to need concatenation though.

but when I put in a full string url the problem does indeed go away... How can we accomplish this?

@hmsk
Copy link
Owner

hmsk commented Apr 26, 2023

Thanks for reporting! Can you provide a reproducible repo?

@Erudition
Copy link
Author

Hi hmsk, I'm not able to start another vite project at the moment, but above I identified the issue as resulting from the lack of string concatenation support. If anyone else runs into this cryptic error, make sure you're only using full string literals to specify your asset paths.

I left the issue open in case anyone knows how we can get concatenation working, which is important in Elm for reusable functions -- e.g. if I have a button fn that sets the button icon based on its inputs, you may want to pass in something like "airplane" to the reusable function to specify the icon -- not env-specific/path/to/all/icons/airplane.svg. If we still need to specify somewhere all the icons we'll ever use, as Vite seems to depend on, that's fine, and doesn't necessarily rule out concatenation.

@Erudition Erudition changed the title Vite server 500 crash when using VitePluginHelper.asset Vite server 500 crash when using VitePluginHelper.asset with concatenated string May 4, 2023
@hmsk
Copy link
Owner

hmsk commented May 5, 2023

Thanks for giving the additional detail! I don't know if we can make concatenation possible technically, but at least wanna try to avoid the crash and give a proper guide/warning.

@hmsk hmsk added the enhancement New feature or request label May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants