I am building a React component library in typescript. The library is supposed to use and build on top of the following:
"dependencies": {
"@hookform/resolvers": "^2.9.10",
"axios": "^1.1.3",
"chart.js": "^4.0.1",
"react-beautiful-dnd": "^13.1.1",
"react-chartjs-2": "^5.0.1",
"react-hook-form": "^7.39.4",
"react-router-dom": "^6.4.3",
"reflect-metadata": "^0.1.13",
"yup": "^0.32.11"
}
As direct dependency, and it has also development dependencies as follows:
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.2",
"@rollup/plugin-json": "^5.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^9.0.2",
"@types/axios": "^0.14.0",
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-beautiful-dnd": "^13.1.2",
"@types/yup": "^0.32.0",
"react": "^18.2.0",
"rollup": "^3.3.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-scss": "^3.0.0",
"sass": "^1.56.1",
"tslib": "^2.4.1",
"typescript": "^4.9.3"
}
I have a rollup config file as follows:
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import json from "rollup-plugin-json";
import copy from "rollup-plugin-copy";
import postcss from "rollup-plugin-postcss";
export default [
{
input: "src/index.ts",
output: [
{
file: "dist/cjs/index.js",
format: "cjs",
sourcemap: true,
},
{
file: "dist/esm/index.js",
format: "esm",
sourcemap: true,
},
],
plugins: [
peerDepsExternal(),
commonjs(),
resolve(),
json(),
typescript({ tsconfig: "./tsconfig.json" }),
postcss(),
copy({
targets: [
{
src: "src/index.css",
dest: "dist",
rename: "index.css"
},
{
src: "README.md",
dest: "dist",
rename: "README.md"
},
{
src: "package.json",
dest: "dist",
rename: "package.json"
}
]
})
],
},
{
input: "dist/esm/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "esm" }],
external: [/\.css$/],
plugins: [dts()],
},
];
I could build the library though there are some cirular dependencies warnings, and i coud also publish it to both npm
and github
scoped package repo.
But when i test the library eaither with direct install from npm or github i have the folliwin errors:
- Module not found: Error: Can't resolve 'url','zlip','fs','path' in '[LIB_PATH]\dist\esm'
Any idea why this is happening? Thanks in advance.