linaria icon indicating copy to clipboard operation
linaria copied to clipboard

[Regression] Vite: Pre-transform error: Module is disposed

Open PierreGUI opened this issue 7 months ago • 1 comments

Environment

  • Linaria version: 6.2.0
  • wyw-in-js version: 0.5.0
  • Bundler (+ version): Vite 5.3.2
  • Node.js version: 18.17.1
  • OS: MacOS 14.4.1

Description

I'm unable to reproduce in a smaller repo, this seems to be affecting large codebases.
I used to build my Remix project with Vite in Linaria 6.1.0, but this error starts appearing since version 6.2.0. I'm aware the new linaria version comes with a bunch of @wyw-in-js updates too, but I tried the latest wyw packages with the older Linaria version and it still appears to build fine.

This is an sample of the many errors I get:

[vite] Pre-transform error: Module 00312 is disposed in/src/components/clients/songs/JamSessions.redux.ts
| /src/components/clients/artists/SongsHeader.view.tsx

[vite] Error when evaluating SSR module /src/components/clients/artists/SongsPresenter.view.tsx:
|- /node_modules/@wyw-in-js/transform/lib/module.js:223
      throw new EvalError(`${e.message} in${this.callstack.join('\n| ')}\n`);
      ^

EvalError: Module 00312 is disposed in/src/components/clients/songs/JamSessions.redux.ts
| /src/components/clients/artists/SongsHeader.view.tsx

    at Module.evaluate (/node_modules/@wyw-in-js/transform/lib/module.js:223:13)
    at require.Object.assign.ensure (/node_modules/@wyw-in-js/transform/lib/module.js:117:7)
    at /src/components/clients/artists/SongsHeader.view.tsx:11:43
    at /src/components/clients/artists/SongsHeader.view.tsx:118:3
    at Script.runInContext (node:vm:135:12)
    at Module.evaluate (/node_modules/@wyw-in-js/transform/lib/module.js:208:14)
    at evaluate (/node_modules/@wyw-in-js/transform/lib/evaluators/index.js:14:5)
    at BaseAction.evalFile (/node_modules/@wyw-in-js/transform/lib/transform/generators/evalFile.js:35:43)
    at evalFile.next (<anonymous>)
    at /node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:78
    at EventEmitter.action (/node_modules/@wyw-in-js/transform/lib/utils/EventEmitter.js:25:22)
    at BaseAction.emitAction (/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:131:39)
    at nextFn (/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:66:32)
    at processNext (/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:111:28)
    at Object.next (/node_modules/@wyw-in-js/transform/lib/transform/actions/BaseAction.js:120:9)
    at asyncActionRunner (/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:39:102)
    at asyncActionRunner (/node_modules/@wyw-in-js/transform/lib/transform/actions/actionRunner.js:46:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async transform (/node_modules/@wyw-in-js/transform/lib/transform.js:107:20)
    at async TransformPluginContext.transform (file:///node_modules/@wyw-in-js/vite/esm/index.mjs:117:22)
    at async PluginContainer.transform (file:///node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:49587:18)
    at async loadAndTransform (file:///node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:52409:27)
    at async Proxy.warmupRequest (file:///node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:63130:9)

Noticed it affects .redux files where I use react-redux's connect HoC, which kinda reminds me of #1226

Reproducible Demo

I am unfortunately unable to make one atm, but I'm still trying to. Any help or hint is welcome 🙏

PierreGUI avatar Jul 02 '24 10:07 PierreGUI