Expected Behavior
I except the JavaScript build files to be generated to dist/ and the Typescript declaration files to be generated to types/.
Actual Behavior
The plugin tries to outsmart me by resolving a relative path to the declaration output using the tsconfig's directory. However, this is a problem because:
- the declarations will not end up where I told it to.
- the asset output filename will be relative, which is not allowed.
Additional Information
Instead of resolving the path at all, as the error suggests ("must be strings that are neither absolute nor relative paths"), pass the output directory path as is.
./src/main.ts → ./dist/main.js...
[!] (plugin typescript) Error: The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../types/main.d.ts".
Error: The "fileName" or "name" properties of emitted files must be strings that are neither absolute nor relative paths, received "../types/main.d.ts".
at error (C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\rollup\dist\shared\rollup.js:198:30)
at FileEmitter.emitFile (C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\rollup\dist\shared\rollup.js:15513:24)
at C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\@rollup\plugin-typescript\dist\index.js:816:26
at Array.forEach (<anonymous>)
at C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\@rollup\plugin-typescript\dist\index.js:808:37
at Array.forEach (<anonymous>)
at Object.generateBundle (C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\@rollup\plugin-typescript\dist\index.js:806:37)
at C:\Users\elias\Desktop\tscpp\rollup-plugin-typescript-repl\node_modules\rollup\dist\shared\rollup.js:22779:37
import typescript from '@rollup/plugin-typescript';
export default {
input: './src/main.ts',
output: {
file: './dist/main.js',
format: 'cjs',
},
plugins: [
typescript({
declaration: true,
declarationDir: './types',
}),
],
};
Expected Behavior
I except the JavaScript build files to be generated to
dist/and the Typescript declaration files to be generated totypes/.Actual Behavior
The plugin tries to outsmart me by resolving a relative path to the declaration output using the tsconfig's directory. However, this is a problem because:
Additional Information
Instead of resolving the path at all, as the error suggests ("must be strings that are neither absolute nor relative paths"), pass the output directory path as is.