As @Bergi suggested I set external
to include default/index.ts file. Here is documentation about external.
Exact solution looks like this:
tsconfig.json:
paths
for neatness.{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"jsx": "react",
"sourceMap": true,
"outDir": "dist",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": "src",
"paths": {
"@general/*": ["general/*"],
"@react/*": ["_react/*"]
}
}
}
rollup.config.mjs (only _react scope):
I added "@general"
to external
I added paths
option in output
to transform imports paths
// ...
{
input: 'src/_react/index.ts',
output: [
{
file: `dist/react/cjs/index.js`,
format: 'cjs',
sourcemap: true,
paths: {
'@general': '../../general/cjs',
},
},
{
file: `dist/react/esm/index.js`,
format: 'esm',
sourcemap: true,
paths: {
'@general': '../../general/esm',
},
},
],
external: ['@general'],
plugins: [
external(),
resolve(),
commonJS(),
typescript({
tsconfig: './tsconfig.json',
}),
terser(),
],
},
// ...