ezolenko / rollup-plugin-typescript2

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

Error with Vue scoped dynamic slots when using `@rollup/plugin-alias` #445

Open webdevnerdstuff opened 1 year ago

webdevnerdstuff commented 1 year ago

Troubleshooting

  1. Does tsc have the same output? No

  2. Does your Rollup plugin order match this plugin's compatibility? Yes

  3. Can you create a minimal example that reproduces this behavior? This is the project repository I'm having this issue with: https://github.com/webdevnerdstuff/vuetify-drilldown-table

What happens and why it is incorrect

When trying to bundle the code, I'm getting this error output. The code works as expected when running in development under vite (pnpm play if you are checking out the repo). The error is almost identical to what is happening in this issue: https://github.com/ezolenko/rollup-plugin-typescript2/issues/325 Except in my case I'm using @vitejs/plugin-vue not the depreciated package rollup-plugin-vue. Perhaps it's the same issue? The other issue didn't really have a resolution, so I'm a bit stuck at the moment and don't know what to do. Any help is greatly appreciated at this point as my experience with ts/rollup is relatively new'ish, and I've been stuck trying to figure this out for over a week now.

In the repo example I gave, you can see the code in the VDrilldownTable.vue file at line 190. I also tried doing the same thing a different way (pretty much does the same thing) at line 201. They both produce the same error.

Environment

Versions

 System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 5.72 GB / 64.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 19.0.1 - ~/.nvm/versions/node/v19.0.1/bin/node
    Yarn: 1.22.19 - ~/node_modules/.bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v19.0.1/bin/npm
  npmPackages:
    rollup: ^3.20.6 => 3.20.6
    rollup-plugin-typescript2: ^0.34.1 => 0.34.1
    typescript: ^5.0.4 => 5.0.4
  npmGlobalPackages:
    typescript: 4.9.4

rollup.config.js

:
https://github.com/webdevnerdstuff/vuetify-drilldown-table/blob/main/rollup.config.js ```js import alias from '@rollup/plugin-alias'; import commonjs from '@rollup/plugin-commonjs'; import nodePolyfills from 'rollup-plugin-polyfill-node'; import pkg from './package.json'; import typescript from 'rollup-plugin-typescript2'; import vue from '@vitejs/plugin-vue'; import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'; import { nodeResolve } from '@rollup/plugin-node-resolve'; import json from '@rollup/plugin-json'; import { fileURLToPath, URL } from 'node:url'; import scss from 'rollup-plugin-scss'; import postcss from 'rollup-plugin-postcss'; import terser from '@rollup/plugin-terser'; const banner = `/** * @name ${pkg.name} * @version ${pkg.version} * @description ${pkg.description} * @author ${pkg.author} * @copyright Copyright ${new Date().getFullYear()}, WebDevNerdStuff * @homepage ${pkg.homepage} * @repository ${pkg.repository} * @license ${pkg.license} License */ `; export default { input: 'src/index.ts', output: [ { exports: 'named', file: `dist/${pkg.name}.js`, format: 'cjs', banner, }, { exports: 'named', file: `dist/${pkg.name}.es.js`, format: 'es', banner, }, ], external: [ ...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {}), ], plugins: [ json(), alias({ resolve: ['.js', '.jsx', '.ts', '.tsx'], entries: [ { find: '@', replacement: 'src', }, ] }), nodePolyfills(), nodeResolve({ alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, browser: true, extensions: [ '.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue', ], }), commonjs(), typescript(), vue({ defaultLang: { script: 'ts' }, template: { transformAssetUrls }, }), vuetify({ autoImport: false, styles: 'none', }), postcss({ modules: true, extract: true }), scss(), terser(), ], }; ```

tsconfig.json

:
https://github.com/webdevnerdstuff/vuetify-drilldown-table/blob/main/tsconfig.json ```json5 { "compilerOptions": { "allowSyntheticDefaultImports": true, "baseUrl": ".", "declaration": true, "declarationDir": "./dist", "esModuleInterop": true, "importHelpers": true, "jsx": "preserve", "lib": [ "ESNext", "DOM" ], "module": "ESNext", "moduleResolution": "Node", "noImplicitAny": false, "noEmit": true, "outDir": "./dist", "paths": { "@/*": [ "./src/*" ] }, "resolveJsonModule": true, "rootDir": "src", "skipLibCheck": true, "strict": true, "target": "ESNext", "typeRoots": [ "./ts", "./node_modules/@types", "./node_modules/vuetify/types" ], "types": [ "node", "vuetify" ], "useDefineForClassFields": true }, "exclude": [ "playground", "src/App.vue", "src/main.ts", "src/components/**/*.ts", "src/components/**/*.vue", "src/playground/**/*.vue", "src/playground/**/*.ts", "src/stores/**/*.ts", "node_modules" ], "include": [ "auto-imports.d.ts", "src/**/*.ts", "src/**/*.vue" ], "references": [ { "path": "./tsconfig.node.json" } ] } ```

package.json

:
https://github.com/webdevnerdstuff/vuetify-drilldown-table/blob/main/package.json ```json { "name": "vuetify-drilldown-table", "version": "0.0.0-alpha1", "description": "The vuetify-drilldown-table", "private": false, "main": "dist/vuetify-drilldown-table.js", "module": "dist/vuetify-drilldown-table.es.js", "types": "dist/types/index.d.ts", "scripts": { "dev": "vite", "watch": "pnpm dev", "play": "sh src/playground/configs/build.sh && NODE_ENV=playground vite", "bundle": "rollup -c --bundleConfigAsCjs", "build": "vue-tsc && vite build", "predeploy": "npm run build", "deploy": "gh-pages -d docs", "prepublishOnly": "npm run bundle", "lint": "eslint src/**/*.{ts,vue} --max-warnings 10", "prepare": "husky install" }, "lint-staged": { "src/**/*.{js,ts,vue}": [ "npm run lint" ] }, "author": "WebDevNerdStuff & Bunnies... lots and lots of bunnies! (https://webdevnerdstuff.com)", "funding": [ { "type": "patreon", "url": "https://www.patreon.com/WebDevNerdStuff" }, { "type": "individual", "url": "https://bit.ly/wdns-paypal-veet-plugin" } ], "license": "MIT", "files": [ "dist/*", "LICENSE.md", "README.md" ], "repository": "https://github.com/webdevnerdstuff/vuetify-drilldown-table", "bugs": { "url": "https://github.com/webdevnerdstuff/vuetify-drilldown-table/issues" }, "homepage": "https://github.com/webdevnerdstuff/vuetify-drilldown-table", "keywords": [ "vuetify-drilldown-table", "vuetifyDrilldownTable", "v-drilldown-table", "vDrilldownTable", "v-data-table", "vDataTable", "drilldown table", "vuetify", "vuetify3", "api", "drawer", "vue", "vue3", "component", "javascript", "webdevnerdstuff", "wdns" ], "dependencies": { "vue": "^3.2.47", "vuetify": "3.1.15" }, "devDependencies": { "@babel/core": "^7.21.4", "@babel/eslint-parser": "^7.21.3", "@mdi/font": "^7.2.96", "@rollup/plugin-alias": "^5.0.0", "@rollup/plugin-commonjs": "^24.1.0", "@rollup/plugin-json": "^6.0.0", "@rollup/plugin-node-resolve": "^15.0.2", "@rollup/plugin-terser": "^0.4.1", "@types/node": "^18.15.13", "@typescript-eslint/eslint-plugin": "^5.59.0", "@typescript-eslint/parser": "^5.59.0", "@vitejs/plugin-vue": "^4.1.0", "@vue/cli-plugin-babel": "^5.0.8", "@vue/cli-plugin-eslint": "^5.0.8", "@vue/cli-service": "^5.0.8", "@vue/compiler-sfc": "^3.2.47", "@vue/eslint-config-typescript": "^11.0.2", "autoprefixer": "^10.4.14", "eslint": "^8.38.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-vue": "^9.11.0", "gh-pages": "^5.0.0", "husky": "^8.0.3", "lint-staged": "^13.2.1", "pinia": "^2.0.35", "postcss": "^8.4.23", "postcss-html": "^1.5.0", "postcss-scss": "^4.0.6", "prettier": "^2.8.7", "roboto-fontface": "^0.10.0", "rollup": "^3.20.7", "rollup-plugin-polyfill-node": "^0.12.0", "rollup-plugin-postcss": "^4.0.2", "rollup-plugin-scss": "^4.0.0", "rollup-plugin-typescript2": "^0.34.1", "sass": "^1.62.0", "stylelint": "^15.5.0", "stylelint-config-standard": "^33.0.0", "stylelint-order": "^6.0.3", "stylelint-scss": "^4.6.0", "typescript": "^5.0.4", "unplugin-auto-import": "^0.15.3", "vite": "^4.3.1", "vite-plugin-babel": "^1.1.3", "vite-plugin-eslint": "^1.8.1", "vite-plugin-stylelint": "^4.3.0", "vite-plugin-vuetify": "^1.0.2", "vue-tsc": "^1.4.2", "vue3-code-block": "^2.1.0", "webfontloader": "^1.6.28" } } ```

plugin output with verbosity 3

:
```text > vuetify-drilldown-table@0.0.0-alpha1 bundle /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table > rollup -c --bundleConfigAsCjs src/index.ts → dist/vuetify-drilldown-table.js, dist/vuetify-drilldown-table.es.js... rpt2: built-in options overrides: { "noEmitHelpers": false, "importHelpers": true, "noResolve": false, "noEmit": false, "noEmitOnError": false, "inlineSourceMap": false, "outDir": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/placeholder", "moduleResolution": 2, "allowNonTsExtensions": true } rpt2: parsed tsconfig: { "options": { "target": 99, "module": 99, "moduleResolution": 2, "strict": false, "importHelpers": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "declaration": true, "baseUrl": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table", "outDir": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/placeholder", "rootDir": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src", "lib": [ "lib.esnext.d.ts", "lib.dom.d.ts" ], "paths": { "@/*": [ "./src/*" ] }, "types": [ "node", "vuetify" ], "typeRoots": [ "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/@types", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/vuetify/types" ], "skipLibCheck": true, "useDefineForClassFields": true, "jsx": 1, "resolveJsonModule": true, "noEmit": false, "configFilePath": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.json", "pathsBasePath": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table", "noEmitHelpers": false, "noResolve": false, "noEmitOnError": false, "inlineSourceMap": false, "allowNonTsExtensions": true }, "fileNames": [ "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/composables/helpers.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/composables/levelColors.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/utils/props.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugins/index.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugins/theme.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugins/vuetify.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugins/webfontloader.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/types.d.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/vite-env.d.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/vue-shim.d.ts" ], "projectReferences": [ { "path": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.node.json", "originalPath": "./tsconfig.node.json" } ], "typeAcquisition": { "enable": false, "include": [], "exclude": [] }, "raw": { "compilerOptions": { "target": "ESNext", "module": "ESNext", "moduleResolution": "Node", "strict": false, "importHelpers": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "declaration": true, "declarationDir": "./dist", "baseUrl": ".", "outDir": "./dist", "rootDir": "src", "lib": [ "ESNext", "DOM" ], "paths": { "@/*": [ "./src/*" ] }, "types": [ "node", "vuetify" ], "typeRoots": [ "./ts", "./node_modules/@types", "./node_modules/vuetify/types" ], "skipLibCheck": true, "useDefineForClassFields": true, "jsx": "preserve", "resolveJsonModule": true, "noEmit": true }, "exclude": [ "playground", "src/App.vue", "src/main.ts", "src/components/**/*.ts", "src/components/**/*.vue", "src/playground/**/*.ts", "src/stores/**/*.ts", "node_modules" ], "include": [ "src/**/*.ts", "src/**/*.vue" ], "references": [ { "path": "./tsconfig.node.json" } ], "compileOnSave": false }, "errors": [], "wildcardDirectories": { "/users/webdevnerdstuff/dev/sites/plugins/vuetify-drilldown-table/src": 1 }, "compileOnSave": false } rpt2: typescript version: 5.0.4 rpt2: tslib version: 2.5.0 rpt2: rollup version: 3.20.6 rpt2: rollup-plugin-typescript2 version: 0.34.1 rpt2: plugin options: { "check": true, "verbosity": 3, "clean": false, "cacheRoot": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2", "include": [ "*.ts+(|x)", "**/*.ts+(|x)" ], "exclude": [ "*.d.ts", "**/*.d.ts" ], "abortOnError": true, "rollupCommonJSResolveHack": false, "useTsconfigDeclarationDir": false, "tsconfigOverride": {}, "transformers": [], "tsconfigDefaults": {}, "objectHashIgnoreUnknownHack": false, "cwd": "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table", "typescript": "version 5.0.4" } rpt2: rollup config: { "external": [ "vue", "vuetify" ], "input": "src/index.ts", "plugins": [ { "name": "commonjs--resolver" }, { "name": "json" }, { "name": "alias" }, { "name": "polyfill-node" }, { "name": "node-resolve", "version": "15.0.2", "resolveId": { "order": "post" } }, { "name": "commonjs", "version": "24.1.0" }, { "name": "rpt2" }, { "name": "vite:vue" }, { "name": "vuetify:styles", "enforce": "pre" }, { "name": "postcss" }, { "name": "scss" }, { "name": "terser", "numOfWorkersUsed": 0 }, { "name": "stdin" } ], "output": [ { "banner": "/**\n * @name vuetify-drilldown-table\n * @version 0.0.0-alpha1\n * @description The vuetify-drilldown-table\n * @author WebDevNerdStuff & Bunnies... lots and lots of bunnies! (https://webdevnerdstuff.com)\n * @copyright Copyright 2023, WebDevNerdStuff\n * @homepage https://github.com/webdevnerdstuff/vuetify-drilldown-table\n * @repository https://github.com/webdevnerdstuff/vuetify-drilldown-table\n * @license MIT License\n */\n", "exports": "named", "file": "dist/vuetify-drilldown-table.js", "format": "cjs", "plugins": [] }, { "banner": "/**\n * @name vuetify-drilldown-table\n * @version 0.0.0-alpha1\n * @description The vuetify-drilldown-table\n * @author WebDevNerdStuff & Bunnies... lots and lots of bunnies! (https://webdevnerdstuff.com)\n * @copyright Copyright 2023, WebDevNerdStuff\n * @homepage https://github.com/webdevnerdstuff/vuetify-drilldown-table\n * @repository https://github.com/webdevnerdstuff/vuetify-drilldown-table\n * @license MIT License\n */\n", "exports": "named", "file": "dist/vuetify-drilldown-table.es.js", "format": "es", "plugins": [] } ] } rpt2: tsconfig path: /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.json rpt2: included: [ "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.node.json/*.ts+(|x)", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.node.json/**/*.ts+(|x)", "*.ts+(|x)", "**/*.ts+(|x)" ] rpt2: excluded: [ "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.node.json/*.d.ts", "/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/tsconfig.node.json/**/*.d.ts", "*.d.ts", "**/*.d.ts" ] rpt2: Ambient types: rpt2: /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/types.d.ts rpt2: /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/vite-env.d.ts rpt2: /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/types/vue-shim.d.ts rpt2: /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/@types+node@18.15.12/node_modules/@types/node/index.d.ts rpt2: ambient types changed, redoing all semantic diagnostics rpt2: transpiling '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/code/cache/d16e569ed47d77d08ea8a5183ddcf5d0c7999378' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/syntacticDiagnostics/cache/d16e569ed47d77d08ea8a5183ddcf5d0c7999378' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/semanticDiagnostics/cache/d16e569ed47d77d08ea8a5183ddcf5d0c7999378' rpt2: cache miss rpt2: generated declarations for '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: dependency '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: imported by '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: resolving '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' imported by '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: to '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: transpiling '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/code/cache/0d49262cd21e5d7f9526ce330e031f57bd06f059' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/syntacticDiagnostics/cache/0d49262cd21e5d7f9526ce330e031f57bd06f059' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/semanticDiagnostics/cache/0d49262cd21e5d7f9526ce330e031f57bd06f059' rpt2: cache miss rpt2: generated declarations for '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: dependency '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: imported by '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: resolving 'src/plugin' imported by '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/index.ts' rpt2: to '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/src/plugin/index.ts' rpt2: transpiling 'src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts' rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/code/cache/e801a4c34ed69198e1d73d4d3569a9bfe321f761' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/syntacticDiagnostics/cache/e801a4c34ed69198e1d73d4d3569a9bfe321f761' rpt2: cache miss rpt2: cache: '/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.cache/rollup-plugin-typescript2/rpt2_364f7afc7ef7b5ac9a9f55a744a6be0d3cb715ba/semanticDiagnostics/cache/e801a4c34ed69198e1d73d4d3569a9bfe321f761' rpt2: cache miss rpt2: rolling caches [!] (plugin rpt2) RollupError: src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts:631:19 - error TS2322: Type 'Function' is not assignable to type 'SSRSlot'. Type 'Function' provides no match for the signature '(...args: any[]): VNode[]'. 631 default: _withCtx(() => [ ~~~~~~~ src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts:636:19 - error TS2322: Type 'number' is not assignable to type 'SSRSlot'. 636 _: 2 /* DYNAMIC */ ~ src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts:638:59 - error TS2769: No overload matches this call. The last overload gave the following error. Argument of type '(slot: string) => { name: string; fn: Function; }' is not assignable to parameter of type '(value: string[][K], key: K, index: number) => VNodeChild'. Types of parameters 'slot' and 'value' are incompatible. Type 'string[][K]' is not assignable to type 'string'. Type 'string | number | (() => string) | (() => string) | (() => string) | ((...items: string[]) => number) | { (...items: ConcatArray[]): string[]; (...items: (string | ConcatArray)[]): string[]; } | ... 30 more ... | { ...; }' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. 638 _renderList(Object.keys(_unref(slots)), (slot) => { ~~~~~~~~~~~ node_modules/.pnpm/@vue+runtime-core@3.2.47/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1519:25 1519 export declare function renderList(source: T, renderItem: (value: T[K], key: K, index: number) => VNodeChild): VNodeChild[]; ~~~~~~~~~~ The last overload is declared here. src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts:646:59 - error TS2769: No overload matches this call. The last overload gave the following error. Argument of type '(slot: string) => { name: string; fn: Function; }' is not assignable to parameter of type '(value: string[][K], key: K, index: number) => VNodeChild'. Types of parameters 'slot' and 'value' are incompatible. Type 'string[][K]' is not assignable to type 'string'. 646 _renderList(Object.keys(_unref(slots)), (slot) => { ~~~~~~~~~~~ node_modules/.pnpm/@vue+runtime-core@3.2.47/node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1519:25 1519 export declare function renderList(source: T, renderItem: (value: T[K], key: K, index: number) => VNodeChild): VNodeChild[]; ~~~~~~~~~~ The last overload is declared here. src/plugin/VDrilldownTable.vue?vue&type=script&setup=true&lang.ts at error (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup@3.20.6/node_modules/rollup/dist/shared/rollup.js:279:30) at Object.error (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup@3.20.6/node_modules/rollup/dist/shared/rollup.js:24706:20) at RollupContext.error (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/src/context.ts:35:17) at /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/src/diagnostics.ts:70:17 at Array.forEach () at printDiagnostics (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/src/diagnostics.ts:42:14) at typecheckFile (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/src/index.ts:67:3) at Object. (/Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/src/index.ts:257:5) at Generator.next () at /Users/webdevnerdstuff/Dev/Sites/plugins/vuetify-drilldown-table/node_modules/.pnpm/rollup-plugin-typescript2@0.34.1_7z4wb4mnpapsgobacn7mivmt6i/node_modules/rollup-plugin-typescript2/node_modules/tslib/tslib.es6.js:76:71 ```
webdevnerdstuff commented 1 year ago

Some additional information. I was messing around with removing the use of rollup.config.js, and was trying something unrelated. Instead of the rollup config, I used vite to build instead of rollup, and I didn't get the error. Why it works via vite, but not rollup, I have no idea.

vite.config.ts

:
```js import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import * as path from 'path'; import typescript2 from 'rollup-plugin-typescript2'; import dts from "vite-plugin-dts"; export default defineConfig({ plugins: [ vue(), dts({ insertTypesEntry: true, }), typescript2({ check: false, include: ["src/plugin/**/*.vue"], tsconfigOverride: { compilerOptions: { outDir: "dist", sourceMap: true, declaration: true, declarationMap: true, }, }, exclude: ["vite.config.ts"] }) ], build: { rollupOptions: { input: { main: path.resolve(__dirname, "src/index.ts") }, external: ['vue'], output: { exports: "named", globals: { vue: 'Vue', }, }, }, }, resolve: { alias: { '@': path.resolve(__dirname, 'src'), }, }, }); ```
ezolenko commented 1 year ago

Maybe plugin order matters? In your second config you have typescript() after vue().

webdevnerdstuff commented 1 year ago

I just messed around with the order a bit, but nothing changed. BUT... when I was stripping things down to match my vite config (more updated than posted above), it appears that @rollup/plugin-alias is the guilty party. I remove alias, and and the bundle process passed (aside from aliases getting resolved). Moving the alias did not change anything, and resulted in the same errors.

Specifically when I have it set to:

alias({
  entries: [
    { find: '@', replacement: 'src' },
  ]
}),

Additionally, if I change it to something like the following, the same problem exists.

alias({
  entries: [
    { find: '@plugin', replacement: 'src/plugin' },
  ]
}),

I tried other ways of using that plugin with entries as an object, that had the same problem. If I change the find value to anything that doesn't actually resolve anything (ex. @foo) it doesn't throw the error.

Originally I thought the nodeResolve.alias would deal with the alias (doesn't appear to, was going to drop that bit). But without the alias plugin nothing will resolve. So I'd either have to find some other plugin that would resolve the aliases or drop using the rollup config and do everything through vite. I also need something to resolve the aliases in the declaration files anyway. Especially considering it's not playing nice with rpt2, using the vite config might be the better option. I'm not sure why it's fine in the vite config, but not the rollup config (aside from it using different resolvers), when under the hood it's still using rollup.

For reference, I added a new vite config for the build script to use (I'm using the regular one for the docs pages already). This is what it has, and seems to be working as expected. Granted I have yet to actually test it as an npm package as it's wip, but the build does pass. If you want to see any other changes, my dev branch is the most up to date now.

vite.build.config.ts

:
```js import { defineConfig } from 'vite'; import * as path from 'path'; import babel from 'vite-plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; import dts from 'vite-plugin-dts'; import pkg from './package.json'; import terser from '@rollup/plugin-terser'; import typescript from 'rollup-plugin-typescript2'; import vue from '@vitejs/plugin-vue'; import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'; import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'; const banner = `/** * @name ${pkg.name} * @version ${pkg.version} * @description ${pkg.description} * @author ${pkg.author} * @copyright Copyright ${new Date().getFullYear()}, WebDevNerdStuff * @homepage ${pkg.homepage} * @repository ${pkg.repository} * @license ${pkg.license} License */ `; export default defineConfig({ publicDir: false, build: { lib: { entry: './src/plugin/index.ts', name: pkg.name, formats: ['es', 'cjs'], fileName: format => `${pkg.name}.${format}.js`, }, rollupOptions: { input: { main: path.resolve(__dirname, './src/index.ts') }, external: [ ...Object.keys(pkg.dependencies || {}), ], output: { banner, }, }, }, plugins: [ babel(), commonjs(), vue({ template: { transformAssetUrls }, }), dts({ insertTypesEntry: true, }), typescript({ check: true, include: ['./src/plugin/**/*.vue'], }), vuetify({ autoImport: false, styles: 'none', }), cssInjectedByJsPlugin({ topExecutionPriority: false }), terser(), ], resolve: { alias: { '@': path.resolve(__dirname, './src'), '@root': path.resolve(__dirname, './') }, extensions: [ '.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue', ], }, }); ```