ezolenko / rollup-plugin-typescript2

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

`vitest` error: `this.load is not a function` #442

Closed Hextar closed 1 year ago

Hextar commented 1 year ago

What happens and why it is incorrect

Running vitest shows a this.load is not a function error on the terminal, using:

- vue: 3.2.47
- rollup-plugin-typescript2: 0.34.1
- vitest: 0.29.2

image

Environment

 System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 5.76 GB / 31.26 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  npmPackages:
    rollup-plugin-typescript2: ^0.34.1 => 0.34.1 
    typescript: ^4.9.5 => 4.9.5 

tsconfig.json

:
#### tsconfig.json ```json5 { "extends": "@vue/tsconfig/tsconfig.web.json", "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], "compilerOptions": { "lib": ["esnext", "dom", "dom.iterable", "scripthost"], "allowJs": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "noFallthroughCasesInSwitch": true, "strictNullChecks": false, "skipLibCheck": true, "esModuleInterop": true, "declaration": true, "outDir": "dist", "declarationDir": "dist", "baseUrl": ".", "paths": { "@/*": ["./src/*"] } }, "references": [ { "path": "./tsconfig.vite-config.json" } ] } ``` #### tsconfig.vite-config.json ``` { "extends": "@vue/tsconfig/tsconfig.node.json", "include": ["vite.config.*"], "compilerOptions": { "composite": true, "types": ["vite/client", "node", "vitest"] } } ```

package.json

:
```json { "name": "darwin-uikit", "version": "0.0.6", "private": true, "description": "UI kit library for the Darwin platform", "author": "Stefano Salidu ", "type": "module", "files": [ "/dist" ], "main": "dist/index.js", "module": "dist/index.cjs", "exports": { ".": { "import": "./dist/index.js", "require": "./dist/index.cjs" }, "./dist/index.css": { "import": "./dist/index.css", "require": "./dist/index.css" } }, "types": "dist/entry.d.ts", "scripts": { "storybook": "echo no storybook for now [WIP]", "clean": "rm -rf dist", "typecheck": "vue-tsc --noEmit", "build": "npm run clean && npm run typecheck && vite build", "prepare": "npm run build", "lint": "eslint . --ext .js,.ts,.tsx,.vue", "lint:staged": "eslint --fix --quiet", "format": "prettier . --write", "format:check": "prettier . --check", "format:staged": "pretty-quick --staged", "test:unit": "vitest", "test:ui": "vitest --ui", "up": "taze major -I" }, "dependencies": { "@vue/tsconfig": "^0.1.3", "@vueuse/core": "^9.13.0", "@vueuse/head": "^1.1.19", "vue": "^3.2.47", "vue-demi": "^0.13.11" }, "devDependencies": { "@types/color-convert": "^2.0.0", "@types/color-hash": "^1.0.2", "@types/lodash": "^4.14.191", "@types/node": "^18.14.6", "@types/sanitize-html": "^2.8.1", "@types/uuid": "^9.0.1", "@types/vue-router": "^2.0.0", "@vitejs/plugin-vue": "^4.0.0", "@vitest/ui": "^0.29.2", "@vue/eslint-config-standard": "^8.0.1", "@vue/eslint-config-typescript": "^11.0.2", "@vue/test-utils": "^2.3.1", "autoprefixer": "^10.4.13", "color-convert": "^2.0.1", "color-hash": "^2.0.2", "critters": "^0.0.16", "cross-env": "^7.0.3", "eslint": "^8.35.0", "eslint-config-prettier": "^8.7.0", "eslint-plugin-decorator-position": "^5.0.2", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier-vue": "^4.2.0", "eslint-plugin-vue": "^9.9.0", "eslint-plugin-vue-scoped-css": "^2.4.0", "lightningcss": "^1.19.0", "lint-staged": "^13.1.2", "moment": "^2.29.4", "postcss": "^8.4.21", "prettier": "^2.8.4", "pretty-quick": "^3.1.3", "remove": "^0.1.5", "rollup-plugin-typescript2": "^0.34.1", "sanitize-html": "^2.10.0", "sass": "^1.58.3", "taze": "^0.9.0", "typescript": "^4.9.5", "unplugin-vue-components": "^0.24.1", "uuid": "^9.0.0", "vite": "^4.1.4", "vite-plugin-dts": "^2.1.0", "vite-plugin-fonts": "^0.7.0", "vite-plugin-inspect": "^0.7.15", "vite-plugin-libcss": "^1.0.5", "vite-svg-loader": "^4.0.0", "vitest": "^0.29.2", "vue-router": "^4.1.6", "vue-tsc": "^1.2.0", "vuedraggable": "^2.24.3" }, "babel": { "presets": [ [ "@babel/preset-env", { "targets": { "node": "current" } } ] ] }, "engines": { "node": ">= 16.0.0", "npm": ">= 7.0.0" }, "publishConfig": { "registry": "https://npm.pkg.github.com" }, "gitHooks": { "pre-commit": "lint-staged" }, "lint-staged": { "*.{js,jsx,ts,tsx,vue}": [ "npm run lint:staged", "npm run format:staged" ] } } ```
agilgur5 commented 1 year ago

It looks like Vite did not support Rollup's this.load until just a few weeks ago: https://github.com/vitejs/vite/issues/6810 / https://github.com/vitejs/vite/pull/11469 . It seems to have only been released in the 4.2.x betas as of right now.

So this is an upstream Vite issue, not a bug with rpt2