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

@linaria/shaker process node_modules library error, it is socket.io-client library in my project #1310

Closed
justwalk opened this issue Aug 1, 2023 · 3 comments · Fixed by #1350
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided platform: ssr 🛠️ Issue related to SSR

Comments

@justwalk
Copy link

justwalk commented Aug 1, 2023

Environment

  • Linaria version: 4.5.4
  • "@linaria/babel-preset": "^4.5.4",
    "@linaria/core": "^4.5.4",
    "@linaria/extractor": "^4.5.0",
    "@linaria/logger": "^4.5.0",
    "@linaria/preeval": "^3.0.0-beta.23",
    "@linaria/react": "^4.5.4",
    "@linaria/shaker": "^4.5.3",
    "@linaria/utils": "^4.5.3",
    "@linaria/vite": "^4.5.4",
  • vite(+ version): 4.4.7
  • Node.js version: 18..0.0
  • OS: mac os

Description

I upgrade my linaria version from "3.0.0-beta.15" to "4.5.0". linaria reported an error, that is
Failed to transpile /pages/index/Counter.tsx because: Cannot read properties of undefined (reading 'fd') in | /demo/vite-ssr-cli/node_modules/socket.io-client/lib/url.js | /demo/vite-ssr-cli/node_modules/socket.io-client/lib/index.js

my project depend on "socket.io-client" library, The error occurs when linaria handles the "socket.io-client"

i found linaria shaker would process all dependencies include node_modules. but sometimes it would be interrupted in some library. here is "socket.io-client"

how can i fix it,thanks

Reproducible Demo

Reproduce is very easy. it just has these code, it would be bugs
import { Manager } from "socket.io-client"; const socket = new Manager('ws://example.com') socket.on("disconnect", (reason) => { console.log(reason) }); const style = css
color: red;
``

demo on sandbox
https://codesandbox.io/p/sandbox/prod-meadow-ksk5x9?file=%2Fsrc%2FApp.tsx%3A11%2C1

@justwalk justwalk added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Aug 1, 2023
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler platform: ssr 🛠️ Issue related to SSR and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Aug 1, 2023
@layershifter
Copy link
Contributor

Repro with v5: https://stackblitz.com/edit/vitejs-vite-qsh3gp

yarn dev

[plugin:linaria] ENOENT: no such file or directory, open '/home/projects/vitejs-vite-qsh3gp/node_modules/.vite/deps/socket__io-client.js'

Looks that there is a problem with resolver.

yarn build

error during build:
EvalError: Cannot read properties of undefined (reading 'indexOf') in/home/projects/vitejs-vite-qsh3gp/src/App.jsx
    at Module.evaluate (file:///home/projects/vitejs-vite-qsh3gp/node_modules/@linaria/babel-preset/lib/module.js:224:13)
    at evaluate (file:///home/projects/vitejs-vite-qsh3gp/node_modules/@linaria/babel-preset/lib/evaluators/index.js:15:5)

Looks like a problem with shaker, should be debugged.

@layershifter
Copy link
Contributor

yarn dev

This problem is covered and described in #1246.

@Anber
Copy link
Collaborator

Anber commented Sep 26, 2023

build has been fixed in #1354 and #1349. dev will be fixed in #1246

@Anber Anber closed this as completed Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided platform: ssr 🛠️ Issue related to SSR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants