I'm using rollupjs and my function "clone" is appearing in the outputted index.js but not in the bottom line export. This means that clients can't get to it.
I've noticed tsc is working though beceause its included in the typescript declaration file
my rollup config file
const packageJson = require("./package.json");
const EXTERNAL = Object.keys(packageJson.devDependencies);
let includePathOptions = {
include: {},
paths: ['src/components', 'src/utils'],
external: EXTERNAL,
extensions: ['.ts', '.tsx', '.html']
};
export default [
{
input: "index.ts",
output: [
{
file: packageJson.module,
format: "esm",
sourcemap: true,
},
],
plugins: [
includePaths(includePathOptions),
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
],
external: EXTERNAL
},
{
input: "dist/esm/types/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "esm" }],
external: EXTERNAL,
plugins: [dts()],
},
];
my clone function is like so:
import { CloneMode } from "./enums";
const clone = <T>(obj: T, mode?: CloneMode) : T => {
// if it's deep we'll write it out as a sting then rencode it
if (mode == CloneMode.Deep) {
return JSON.parse(JSON.stringify(obj));
} else {
if (obj instanceof Array) {
if (mode == CloneMode.Iterate) {
let tmp: any[] = []
obj.forEach((elem) => tmp.push(elem))
//@ts-ignore : This will work
return tmp;
} else {
return JSON.parse(JSON.stringify(obj));
}
} else {
return { ...obj };
}
}
}
export { clone }
how does the bottom line export get generated? and how can i make the index.js be the same as the index.d.ts