rollup-plugin-typescript2 icon indicating copy to clipboard operation
rollup-plugin-typescript2 copied to clipboard

watch mode `Error: Could not find source file`

Open skagur-k opened this issue 1 year ago • 2 comments

What happens and why it is incorrect

Rollup watch mode emits the following error: (plugin rpt2) Error: Could not find source file: '/home/skagur/dev/rpt2-repro/index.ts'

Repository for the reproduction of the errror: Reproduction repo

Possibly related to #214

Environment

Versions

Binaries:
    Node: 18.4.0 - /home/linuxbrew/.linuxbrew/bin/node
    Yarn: 1.23.0-20220130.1630 - /home/linuxbrew/.linuxbrew/bin/yarn
    npm: 8.12.1 - /home/linuxbrew/.linuxbrew/bin/npm
  npmPackages:
    rollup: ^2.77.2 => 2.77.2 
    rollup-plugin-typescript2: ^0.32.1 => 0.32.1 
    typescript: ^4.7.4 => 4.7.4 
  npmGlobalPackages:
    typescript: 4.7.4

rollup.config.js

:
// rollup.config.js

import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from 'rollup-plugin-typescript2'
import postCSS from 'rollup-plugin-postcss'
import pkg from './package.json'
import bundleSize from 'rollup-plugin-bundle-size'
import analyzer from 'rollup-plugin-visualizer'

const devMode = process.env.NODE_ENV === 'development'
console.log(`${devMode ? 'development' : 'production'} mode bundle`)

export default {
	input: './index.ts',
	output: [
		{
			file: pkg.main,
			format: 'cjs',
			sourcemap: devMode ? 'inline' : false,
		},
		{
			file: pkg.module,
			format: 'es',
			sourcemap: devMode ? 'inline' : false,
		},
	],
	external: [...Object.keys(pkg.peerDependencies || {})],
	plugins: [
		nodeResolve(),
		commonjs(),
		typescript({
			typescript: require('typescript'),
		}),
		postCSS({
			plugins: [require('autoprefixer')],
		}),
		bundleSize(),
		analyzer(),
	],
}

tsconfig.json

:
{
	"$schema": "https://json.schemastore.org/tsconfig",
	"display": "Default",
	"compilerOptions": {
		"composite": false,
		"declaration": true,
		"declarationMap": false,
		"declarationDir": "dist/types",
		"esModuleInterop": true,
		"forceConsistentCasingInFileNames": true,
		"inlineSources": false,
		"isolatedModules": true,
		"moduleResolution": "node",
		"noUnusedLocals": true,
		"noUnusedParameters": true,
		"skipLibCheck": true,
		"strict": true,
		"outDir": "dist/esm",
		"jsx": "react-jsx",
		"lib": ["ES2016", "ES2017", "DOM", "es6"],
		"module": "ESNext",
		"target": "es5",
		"noImplicitReturns": true,
		"noImplicitThis": true,
		"noImplicitAny": true,
		"strictNullChecks": true,
		"suppressImplicitAnyIndexErrors": true,
		"allowSyntheticDefaultImports": true,
		"typeRoots": ["./node_modules/@types"]
	},
	"include": ["src/**/*", "../tsconfig/global.d.ts"],
	"exclude": ["dist", "build", "node_modules"]
}

package.json

:
{
	"name": "@skaui/treeview",
	"version": "1.0.0",
	"description": "SKA UI - TreeView",
	"main": "./dist/cjs/index.js",
	"module": "./dist/esm/index.mjs",
	"types": "./dist/types/index.d.ts",
	"files": [
		"./dist"
	],
	"sideEffects": false,
	"scripts": {
		"dev": "rollup -c -w"
	},
	"keywords": [],
	"author": "Nam Hyuck Kim ([email protected])",
	"license": "ISC",
	"devDependencies": {
		"@rollup/plugin-commonjs": "^22.0.1",
		"@rollup/plugin-node-resolve": "^13.3.0",
		"@rollup/plugin-typescript": "^8.3.4",
		"@types/react": "^18.0.15",
		"autoprefixer": "^10.4.7",
		"postcss": "^8.4.14",
		"react": "^18.2.0",
		"react-dom": "18.2.0",
		"rollup": "^2.77.2",
		"rollup-plugin-bundle-size": "^1.0.3",
		"rollup-plugin-postcss": "^4.0.2",
		"rollup-plugin-typescript2": "^0.32.1",
		"rollup-plugin-visualizer": "^5.7.1",
		"tailwindcss": "^3.1.6",
		"typescript": "^4.7.4"
	},
	"peerDependencies": {
		"react": "^17.2.0",
		"react-dom": "^17.2.0"
	}
}

plugin output with verbosity 3

:
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "noEmitOnError": false,
    "inlineSourceMap": false,
    "outDir": "/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/placeholder",
    "moduleResolution": 2,
    "allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
    "options": {
        "composite": false,
        "declaration": true,
        "declarationMap": false,
        "esModuleInterop": true,
        "forceConsistentCasingInFileNames": true,
        "inlineSources": false,
        "isolatedModules": true,
        "moduleResolution": 2,
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "skipLibCheck": true,
        "strict": true,
        "outDir": "/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/placeholder",
        "jsx": 4,
        "lib": [
            "lib.es2016.d.ts",
            "lib.es2017.d.ts",
            "lib.dom.d.ts",
            "lib.es2015.d.ts"
        ],
        "module": 99,
        "target": 1,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "suppressImplicitAnyIndexErrors": true,
        "allowSyntheticDefaultImports": true,
        "typeRoots": [
            "/home/skagur/dev/rpt2-repro/node_modules/@types"
        ],
        "configFilePath": "/home/skagur/dev/rpt2-repro/tsconfig.json",
        "noEmitHelpers": false,
        "importHelpers": true,
        "noResolve": false,
        "noEmit": false,
        "noEmitOnError": false,
        "inlineSourceMap": false,
        "allowNonTsExtensions": true
    },
    "fileNames": [
        "/home/skagur/dev/rpt2-repro/src/Button.tsx",
        "/home/skagur/dev/rpt2-repro/src/global.d.ts",
        "/home/skagur/dev/rpt2-repro/src/index.ts"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "$schema": "https://json.schemastore.org/tsconfig",
        "display": "Default",
        "compilerOptions": {
            "composite": false,
            "declaration": true,
            "declarationMap": false,
            "declarationDir": "dist/types",
            "esModuleInterop": true,
            "forceConsistentCasingInFileNames": true,
            "inlineSources": false,
            "isolatedModules": true,
            "moduleResolution": "node",
            "noUnusedLocals": true,
            "noUnusedParameters": true,
            "skipLibCheck": true,
            "strict": true,
            "outDir": "dist/esm",
            "jsx": "react-jsx",
            "lib": [
                "ES2016",
                "ES2017",
                "DOM",
                "es6"
            ],
            "module": "ESNext",
            "target": "es5",
            "noImplicitReturns": true,
            "noImplicitThis": true,
            "noImplicitAny": true,
            "strictNullChecks": true,
            "suppressImplicitAnyIndexErrors": true,
            "allowSyntheticDefaultImports": true,
            "typeRoots": [
                "./node_modules/@types"
            ]
        },
        "include": [
            "src/**/*",
            "../tsconfig/global.d.ts"
        ],
        "exclude": [
            "dist",
            "build",
            "node_modules"
        ],
        "compileOnSave": false
    },
    "errors": [],
    "wildcardDirectories": {
        "/home/skagur/dev/rpt2-repro/src": 1
    },
    "compileOnSave": false
}
rpt2: included:
[
    "*.ts+(|x)",
    "**/*.ts+(|x)"
]
rpt2: excluded:
[
    "*.d.ts",
    "**/*.d.ts"
]
rpt2: transpiling '/home/skagur/dev/rpt2-repro/src/index.ts'
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/code/cache/e827b637ff444b424d1c753c7c57ddbf8eae8195'
rpt2:     cache miss
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/syntacticDiagnostics/cache/e827b637ff444b424d1c753c7c57ddbf8eae8195'
rpt2:     cache miss
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/semanticDiagnostics/cache/e827b637ff444b424d1c753c7c57ddbf8eae8195'
rpt2:     cache miss
rpt2:     watching: /home/skagur/dev/rpt2-repro/src/Button.tsx
rpt2: generated declarations for '/home/skagur/dev/rpt2-repro/src/index.ts'
rpt2: dependency '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2:     imported by '/home/skagur/dev/rpt2-repro/src/index.ts'
rpt2: resolving './Button' imported by '/home/skagur/dev/rpt2-repro/src/index.ts'
rpt2:     to '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2: transpiling '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/code/cache/e08ba165e1bbdf15434ff4b59bdb19e99e3ed886'
rpt2:     cache miss
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/syntacticDiagnostics/cache/e08ba165e1bbdf15434ff4b59bdb19e99e3ed886'
rpt2:     cache miss
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/semanticDiagnostics/cache/e08ba165e1bbdf15434ff4b59bdb19e99e3ed886'
rpt2:     cache miss
rpt2:     watching: 
rpt2: generated declarations for '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2: resolving '/home/skagur/dev/rpt2-repro/node_modules/tslib/tslib.es6.js' imported by '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2:     to '/home/skagur/dev/rpt2-repro/node_modules/tslib/tslib.es6.js'
rpt2: resolving '/home/skagur/dev/rpt2-repro/node_modules/react/jsx-runtime.js' imported by '/home/skagur/dev/rpt2-repro/src/Button.tsx'
rpt2:     to '/home/skagur/dev/rpt2-repro/node_modules/react/jsx-runtime.js'
rpt2: generating target 1
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/syntacticDiagnostics/cache/0a37055cfdc1aaa6994c5c4e7660f2f9be84848d'
rpt2:     cache miss
rpt2: generating target 1
rpt2:     cache: '/home/skagur/dev/rpt2-repro/node_modules/.cache/rollup-plugin-typescript2/rpt2_2e251205a01feeeabda92056ef5763ec288bad10/syntacticDiagnostics/cache/0a37055cfdc1aaa6994c5c4e7660f2f9be84848d'
rpt2:     cache miss
[!] (plugin rpt2) Error: Could not find source file: '/home/skagur/dev/rpt2-repro/index.ts'.

skagur-k avatar Jul 31 '22 13:07 skagur-k

Possible duplicate of #271, which was recently fixed by #364, but hasn't been released yet (looking to do a release very soon, though I don't have publishing permissions)

agilgur5 avatar Jul 31 '22 16:07 agilgur5

Thanks for the response. Good luck on the next release!

skagur-k avatar Aug 01 '22 02:08 skagur-k

#364 has been released in 0.33.0

I confirmed in your repro that with 0.33.0 the error is no longer present, so this indeed turns out to be a duplicate of #271 .

agilgur5 avatar Aug 23 '22 23:08 agilgur5