rollup-plugin-ts-paths
rollup-plugin-ts-paths copied to clipboard
[!] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
Hello,
Sorry for the trouble, I might do something wrong but I tried to use this plugin and get prompted with
[!] TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
tsconfig.json (in root folder)
{
"extends": "@tsconfig/svelte/tsconfig.json",
"include": ["src/**/*"],
"exclude": ["node_modules/*", "__sapper__/*", "public/*"],
"compilerOptions": {
"baseUrl": "./",
"module": "es2020",
"target": "es2020",
"paths": {
"@src/*": ["src/*"],
"@environments/*": ["src/environments/*"]
}
}
}
rollup.config.js
import tsConfigPaths from 'rollup-plugin-ts-paths';
...
export default {
input: "src/main.ts",
output: {
sourcemap: true,
format: "iife",
name: "app",
file: "public/build/bundle.js",
},
plugins: [
tsConfigPaths(),
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
css: (css) => {
css.write("bundle.css");
},
preprocess: sveltePreprocess(),
}),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ["svelte"],
}),
commonjs(),
typescript({ sourceMap: !production }),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload("public"),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
};
import in the app
<script lang="ts">
import Home from "@src/components/home/Home.svelte";
</script>
<style>
main {
width: 100%;
height: 100%;
position: relative;
}
</style>
<main>
<Home />
</main>
it seems you need to specify an outDir option on your tsconfig
This error happens with different combinations of tsconfig settings - turning composite: false solved the problem for one person.