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

Reference IDs containing $$ fail to be resolved with LightningCSS #16297

Closed
7 tasks done
jackwakefield opened this issue Mar 28, 2024 · 1 comment · Fixed by #16306
Closed
7 tasks done

Reference IDs containing $$ fail to be resolved with LightningCSS #16297

jackwakefield opened this issue Mar 28, 2024 · 1 comment · Fixed by #16306
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@jackwakefield
Copy link

Describe the bug

When using LightningCSS and building with Vite, URLs can be replaced with a reference ID containing $$ (e.g. gbjdc$$i / __VITE_ASSET__gbjdc$$i__).

When the generated URLs are then replaced with the built asset URLs, it searches for the asset using an incorrect ID, replacing $$ with $ (e.g. gbjdc$i).

Reproduction

https://stackblitz.com/edit/vitejs-vite-aaxr6p

Steps to reproduce

Run npm install followed by npm run build.

System Info

System:
  OS: Linux 6.8 Arch Linux
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Memory: 10.70 GB / 31.05 GB
  Container: Yes
  Shell: 3.7.0 - /usr/bin/fish
Binaries:
  Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
  Yarn: 4.1.1 - ~/.yarn/bin/yarn
  npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  pnpm: 8.15.2 - /usr/bin/pnpm
npmPackages:
  @vitejs/plugin-react-swc: ^3.6.0 => 3.6.0 
  vite: ^5.2.6 => 5.2.6

Used Package Manager

yarn

Logs

Click to expand!
Compiling message catalogs…
Done!
[sentry-vite-plugin] Info: Using environment variables configured in ".env.sentry-build-plugin".
(node:570047) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
vite v5.2.6 building for production...
node_modules/@tanstack/react-query/build/modern/useSuspenseQuery.js (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.
node_modules/@tanstack/react-query/build/modern/useBaseQuery.js (1:0): Error when using sourcemap for reporting an error: Can't resolve original location of error.
[plugin:vite:resolve] [plugin vite:resolve] Module "fs" has been externalized for browser compatibility, imported by "/home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/tiny-xlsx/src/index.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/tiny-xlsx/node_modules/jszip/lib/readable-stream-browser.js". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 1904 modules transformed.
x Build failed in 9.48s

✨ [vite-plugin-robots]:
✓ Copied: .robots.production.txt -> dist/robots.txt

error during build:
RollupError: [vite:css-post] Plugin error - Unable to get file name for unknown file "gbjdc$i".
    at getRollupError (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/rollup/dist/es/shared/parseAst.js:376:41)
    at error (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/rollup/dist/es/shared/parseAst.js:372:42)
    at FileEmitter.getFileName (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/rollup/dist/es/shared/node-entry.js:19083:24)
    at file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:31702:43
    at String.replace (<anonymous>)
    at resolveAssetUrlsInCss (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:31701:37)
    at Object.renderChunk (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/vite/dist/node/chunks/dep-BBHrJRja.js:31784:36)
    at async transformChunk (file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/rollup/dist/es/shared/node-entry.js:17723:16)
    at async file:///home/jackwakefield/workspace/apps/web/also-asked-frontend/node_modules/rollup/dist/es/shared/node-entry.js:17797:17
    at async Promise.all (index 0)

Validations

Copy link

stackblitz bot commented Mar 28, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) labels Mar 29, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: css p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants