Repository navigation
Rollup typescript warning #1590
Replies: 1 comment
|
Your config already includes I tested this small case with export const copy = structuredClone({ nested: { value: 1 } });
From the package directory where you run Rollup, check: npm ls typescript @rollup/plugin-typescript
node -p "require('typescript').version"
node -p "require.resolve('typescript')"If the compiler is old, update the project's This fixes only the type declaration side. The emitted JavaScript still calls native |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
/**
/
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"]
}
All reactions