79778868

Date: 2025-09-30 08:22:17
Score: 0.5
Natty:
Report link

As @Bergi suggested I set external to include default/index.ts file. Here is documentation about external.

Exact solution looks like this:

tsconfig.json:

{
  "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):

// ...
{
  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(),
  ],
},
// ...
Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Bergi
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Jan KrupiƄski