Skip to content

tree-shaking doesn't work well for UMD bundle with axios and dayjs #992

Description

@zerofront

Current Behavior

I used tsdx to create a project A, and import axios, dayjs, and export. then I use tsdx to create project B and import some function from project A, but not using axios, dayjs. and I find axios/dayjs code in project B UMD bundle

Flow

project A

tsdx create A (select basic)

change src/index.ts

import dayjs from 'dayjs'
import axios from 'axios'

const sum = (a: number, b: number) => {
  console.log('boop');
  return a + b;
};

const minus = (a: number, b: number) => {
  console.log('poop');
  return a - b;
};

export {
  sum,
  minus,
  dayjs,
  axios,
}

npm publish

project B

tsdx create B (select basic)

change src/index.ts

import { minus } from 'A'

function final(a: number, b: number) {
  return minus(a, b)
}

export {
  final
}

change project b tsdx.config.js

module.exports = {
  rollup(config) {
    if (config.output.format === 'umd') {
      delete config.external;
    }
    return config;
  }
}

Check UMD bundle, although I did not use axios, the bundle has this part of the code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: supportAsking for support with something or a specific use caseproblem: removed issue templateOP removed the issue template without good causeproblem: staleIssue has not been responded to in some timescope: upstreamIssue in upstream dependency

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions