Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Rollupjs not including function in bottom line export command of index.js

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.

dist/esm/index.js enter image description here

I've noticed tsc is working though beceause its included in the typescript declaration file

dist/index.d.ts index.d.ts

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

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!