Trying to make a node package that will extract my react component that is written in typescript.
Result: Console Error:
./src/index.ts → dist/index.ts, dist/index.es.ts...
[!] Error: Could not resolve './components/GeneralSectionForm' from src/index.ts
Error: Could not resolve './components/GeneralSectionForm' from src/index.ts
This is rollup config
import babel from 'rollup-plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import external from 'rollup-plugin-peer-deps-external';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import reactSvg from "rollup-plugin-react-svg";
export default [
{
input: './src/index.ts',
output: [
{
file: 'dist/index.ts',
format: 'cjs',
},
{
file: 'dist/index.es.ts',
format: 'es',
exports: 'named',
}
],
plugins: [
postcss({
plugins: [],
minimize: true,
}),
babel({
exclude: 'node_modules/**',
presets: ['@babel/preset-react']
}),
external(),
resolve(),
terser(),
reactSvg({
svgo: {
plugins: [], // passed to svgo
multipass: true
},
// whether to output jsx
jsx: false,
// include: string
include: ["src/custom.d.ts"],
// exclude: string
exclude: null
})
]
}
];
src/index.ts
export * from './components/GeneralSectionForm';
I assume that issue is cus src/index.ts is not the javascript type of file,
does anyone know how to set up this to work with a typescript file?