@rollup/plugin-typescript: Path of Typescript compiler option 'outDir' must be located inside the same directory as the Rollup 'file' option. #1777
Replies: 5 comments 12 replies
-
@shellscape how come this was moved to discussion? I have provided a link to reproduction: remarkablemark/html-react-parser#1535 |
Beta Was this translation helpful? Give feedback.
-
Is there a reason for this breakage. It makes having multiple configurations difficult. |
Beta Was this translation helpful? Give feedback.
-
The workaround is to set the import Path from 'node:path';
import rollupPluginTypescript from '@rollup/plugin-typescript';
const target = { file: './dist/cjs/index.cjs', format: 'cjs' };
//...
const configs = [
{
input: 'src/index.ts',
output: target
plugins: [
rollupPluginTypescript({
tsconfig: 'tsconfig.json',
compilerOptions: { outDir: Path.dirname(target.file) },
}),
]
}
];
export default configs; But this seems unnecessary for every rollup config. |
Beta Was this translation helpful? Give feedback.
-
same here import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import path from 'path';
import { fileURLToPath } from 'url';
import pkg from './package.json' assert { type: 'json' };
console.clear();
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const deps = Object.keys(pkg.dependencies).concat(Object.keys(pkg.devDependencies));
export default {
input: 'src/index.ts', // Replace with the path to your entry TypeScript file
output: [
{
dir: 'dist/cjs',
format: 'cjs',
sourcemap: true,
preserveModules: true
},
{
dir: 'dist/esm',
format: 'esm',
sourcemap: true,
preserveModules: true
}
],
plugins: [
json(),
resolve(),
commonjs(),
typescript({
tsconfig: 'tsconfig.json',
compilerOptions: {
/* Basic Options */
target: 'ES5',
module: 'ES2020',
lib: ['ES2019', 'ES2020'],
allowJs: true,
checkJs: false,
/* Strict Type-Checking Options */
strict: true,
/* Module Resolution Options */
moduleResolution: 'node',
esModuleInterop: true,
/* Advanced Options */
forceConsistentCasingInFileNames: true,
skipDefaultLibCheck: true,
skipLibCheck: true,
outDir: path.join(__dirname, 'dist')
}
})
],
external: deps // Add any external dependencies you don't want to bundle
}; |
Beta Was this translation helpful? Give feedback.
-
Thanks, this is resolved by #1783. See remarkablemark/html-react-parser#1596 where I had to update plugins: [
typescript({
compilerOptions: {
outDir: 'dist',
},
)},
], |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@rollup/plugin-typescript
12.1.0
4.22.4
20
Expected Behavior
Rollup build does not error
Actual Behavior
Rollup build throws error:
Additional Information
May be related to #1773
Beta Was this translation helpful? Give feedback.
All reactions