Skip to content

Rollup typescript warning #1589

@TriveniBrijesh

Description

@TriveniBrijesh

I have to use structuredClone function in my react component, build component during give below typescript warning from rollup. I have to use rollup/plugin-typescript latest version.
@rollup/plugin-typescript TS2304: Cannot find name 'structuredClone'.
how to fixt that warning?

Rollup.config.js file
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import excludeDeps from "rollup-plugin-exclude-dependencies-from-bundle";
import { terser } from "rollup-plugin-terser";
import dts from "rollup-plugin-dts";
import url from "rollup-plugin-url";

const production = !process.env.ROLLUP_WATCH;
const PACKAGE_ROOT_PATH = process.cwd();
// rollup.config.js
/**

  • @type {import('rollup').RollupOptions}
    /
    export default [
    {
    input: ${PACKAGE_ROOT_PATH}/src/index.ts,
    output: [
    {
    dir: "dist",
    format: "es",
    sourcemap: false,
    },
    ],
    plugins: [
    excludeDeps(),
    resolve(),
    commonjs(),
    typescript({
    tsconfig: ${PACKAGE_ROOT_PATH}/tsconfig.json,
    }),
    production && terser({ format: { comments: false } }),
    url({
    include: ["**/
    .woff", "**/*.woff2"],
    // setting infinite limit will ensure that the files
    // are always bundled with the code, not copied to /dist
    limit: Infinity,
    }),
    ],
    },
    {
    input: "dist/types/index.d.ts",
    output: [{ file: "dist/index.d.ts", format: "esm" }],
    plugins: [dts()],
    external: ['moment/min/locales','react-toastify/dist/ReactToastify.css']
    },
    ];

tsconfig.json file
{
"compilerOptions": {
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"jsx": "react",
"lib": ["ESNext", "DOM"],
"module": "ESNext",
"declaration": true,
"sourceMap": false,
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"typeRoots": ["types"]
},
"exclude": ["node_modules", "/*.test.tsx", "/*.stories.tsx"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions