ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

vite dev throws `TypeError: Cannot read properties of undefined (reading 'add')` #470

Closed MarArMar closed 3 months ago

MarArMar commented 3 months ago

But vite build works.

All packages are on the latest versions, I suppose this is some new incompatibility.. Maybe with Typescript => 5.3 ?

More error details (same output with verbosity : 3) :

SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:28100
                transformedFiles.add(id); // note: this does not need normalization as we only compare Rollup <-> Rollup, and not Rollup <-> TS
                                 ^

TypeError: Cannot read properties of undefined (reading 'add')
    at TransformContext.<anonymous> (/SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:28100:34)
    at Generator.next (<anonymous>)
    at /SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:63:69
    at new Promise (<anonymous>)
    at __awaiter (/SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:59:10)
    at TransformContext.transform (/SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:28099:20)
    at Object.transform (file:///SvelteTypia/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:51133:62)
    at async loadAndTransform (file:///SvelteTypia/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:53888:29)
    at async instantiateModule (file:///SvelteTypia/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:54932:10) {
  plugin: 'rpt2',
  id: '/SvelteTypia/node_modules/@sveltejs/kit/src/runtime/control.js',

Reproduction : https://github.com/MarArMar/Sveltekit-RPT2-Typia

Why it is incorrect

Cannot start server in dev

Versions

env info

:
```text System: OS: Linux 6.5 CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor Memory: 48.01 GB / 62.01 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 20.12.2 - /usr/bin/node npm: 10.5.0 - /usr/bin/npm pnpm: 9.0.6 - ~/.local/share/pnpm/pnpm bun: 1.1.5 - ~/.bun/bin/bun npmPackages: rollup-plugin-typescript2: ^0.36.0 => 0.36.0 typescript: ^5.4.5 => 5.4.5 ```

tsconfig.json

:
```json5 { "extends": "./.svelte-kit/tsconfig.json", "compilerOptions": { "allowJs": true, "checkJs": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "resolveJsonModule": true, "skipLibCheck": true, // Typia config // https://typia.io/docs/setup/#manual-setup "sourceMap": false, // Here: Seems to be working when working only with TS files "plugins": [ { "transform": "typia/lib/transform" } ], "strictNullChecks": true, "strict": true } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes // from the referenced tsconfig.json - TypeScript does not merge them in } ```

package.json

:
```json { "name": "SvelteTypia", "version": "0.0.1", "type": "module", "scripts": { "dev": "vite dev", "build": "vite build", "prepare": "ts-patch install && typia patch" }, "dependencies": { "typia": "^6.0.3" }, "devDependencies": { "@sveltejs/adapter-auto": "^3.2.0", "@sveltejs/kit": "^2.5.7", "@sveltejs/vite-plugin-svelte": "^3.1.0", "svelte": "^4.2.15", "svelte-check": "^3.7.0", "tslib": "^2.6.2", "typescript": "^5.4.5", "vite": "^5.2.10", "rollup-plugin-typescript2": "^0.36.0", "ts-node": "^10.9.2", "ts-patch": "^3.1.2" } } ```
agilgur5 commented 3 months ago

Please don't remove the issue template, it's there for a reason. You seemed to have used a different project's issue template; they are not the same, please do not do that, there's a reason every project asks for different details.

SvelteTypia/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:28100
                transformedFiles.add(id); // note: this does not need normalization as we only compare Rollup <-> Rollup, and not Rollup <-> TS

TypeError: Cannot read properties of undefined (reading 'add')

If transformedFiles is undefined, that would mean this line never got ran which would suggest that buildStart never ran, which sounds like a Vite bug to me.

Although you did not provide your complete logs, which the issue template specifically asks for and which you skipped, so I have no idea if there were some error beforehand, for instance, from this Rollup version check.

In any case, that sounds like a Vite compatibility issue.