ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

Package subpath './plugin-typescript2' is not defined by "exports" -- incorrect import #462

Closed Aderafif closed 12 months ago

Aderafif commented 12 months ago
[!] Error: Package subpath './plugin-typescript2' is not defined by "exports"

I got this error when trying to do npm rollup -c

Tried to downgrade to version 0.31.0 and still facing the same issue

Versions

├── rollup-plugin-dts@6.0.0 ├── rollup-plugin-typescript2@0.35.0 ├── rollup@3.28.1 ├── tslib@2.6.2

On other issue, it said solved on rollup-plugin-typescript2 v 0.31.0

rollup.config.mjs

import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup/plugin-typescript2";
import dts from "rollup-plugin-dts";
import terser from "@rollup/plugin-terser";
import packageJson from "./package.json" assert { type: "json" };
// const packageJson = require("./package.json");

export default [
  {
    input: "src/index.ts",
    output: [
      {
        file: packageJson.main,
        format: "cjs",
        sourcemap: true,
      },
      {
        file: packageJson.module,
        format: "esm",
        sourcemap: true,
      },
    ],
    plugins: [
      resolve(),
      commonjs(),
      typescript({ tsconfig: "./tsconfig.json" }),
    ],
  },
  {
    input: "dist/esm/types/index.d.ts",
    output: [{ file: "dist/index.d.ts", format: "esm" }],
    plugins: [typescript()],
  },
];
agilgur5 commented 12 months ago

import typescript from "rollup/plugin-typescript2";

You have a typo. That is not the correct import (or package). rollup-plugin-typescript2 is the package.

rollup/ means that you are trying to look within a subpath of the rollup package.