Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开发环境的 tree-shaking 问题 #9449

Closed
7 tasks done
Miofly opened this issue Jul 30, 2022 · 1 comment
Closed
7 tasks done

开发环境的 tree-shaking 问题 #9449

Miofly opened this issue Jul 30, 2022 · 1 comment

Comments

@Miofly
Copy link

Miofly commented Jul 30, 2022

Describe the bug

I have a public 'utils' directory in my project, structured like the figure, export all the methods in 'index.ts', so that they can be import in utils/index.ts, but that will cause all uitls in the development environment to be loaded.

image

example: import { isUndefined } from '@dzh/utils',I only import one of these methods, and all utils were imported
image

import { isUndefined } from '@dzh/utils/src/is';
Must be import to a specific directory to not be so.

So there is no good way to deal with this kind of problem in the development environment, in addition to utils there will be public hooks and so on。

Reproduction

https://github.com/Miofly/vite-dev-tree-shaking

System Info

System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1
    Memory: 83.66 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.15 - ~/Documents/mio/new-mio/mio/node_modules/.bin/npm
  Browsers:
    Chrome: 103.0.5060.134
    Safari: 15.4
  npmPackages:
    @vitejs/plugin-vue: ^3.0.1 => 3.0.1 
    vite: ^3.0.1 => 3.0.4

Used Package Manager

pnpm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jul 30, 2022

I think this is a duplicate of #8237

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants