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 regression in Vite 2.0.0 beta #1467

Closed
3 tasks done
Schniz opened this issue Jan 10, 2021 · 0 comments
Closed
3 tasks done

Tree-shaking regression in Vite 2.0.0 beta #1467

Schniz opened this issue Jan 10, 2021 · 0 comments

Comments

@Schniz
Copy link

Schniz commented Jan 10, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

When using @tabler/icon with vite@1.0.0-rc.13, @tabler/icons wasn't all bundled into your production build. Using vite@2.0.0-beta.12, all the icons are bundled into the production bundle.

or:

when importing one icon from @tabler/icon:

import {IconBrandFirefox} from '@tabler/icons'

it used to only bundle this very icon. Now it bundles all the icons.

Reproduction

Here's a reproduction repo: https://github.com/Schniz/vite-preact-ts
check out the GitHub action with the analyzed data: https://github.com/Schniz/vite-preact-ts/runs/1676562255#step:4:9

System Info

  • vite version: 2.0.0-beta.19
  • Operating System: MacOS, but also reproducible in CI (ubuntu-latest)
  • Node version: v12.20.0
  • Package manager (npm/yarn/pnpm) and version: yarn v1.22.10

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
2021-01-10T12:02:58.442Z vite:config bundled config file loaded in 129ms
2021-01-10T12:02:58.448Z vite:config using resolved config: {
  esbuild: { jsxFactory: 'h', jsxFragment: 'Fragment' },
  plugins: [
    'alias',
    'vite:dynamic-import-polyfill',
    'vite:resolve',
    'vite:html',
    'vite:css',
    'vite:esbuild',
    'vite:json',
    'vite:wasm',
    'vite:worker',
    'vite:asset',
    'prefresh',
    'vite:css-post',
    'vite:build-html',
    'commonjs',
    'vite:data-uri',
    'vite:import-glob',
    'vite:define',
    'rollup-plugin-dynamic-import-variables',
    'visualizer',
    'rollup-plugin-analyzer',
    'vite:esbuild-transpile',
    'vite:terser',
    'vite:size'
  ],
  alias: [
    {
      find: /^\/@vite\//,
      replacement: '/Users/USERNAME/Code/vite-preact-ts/node_modules/vite/dist/client/'
    },
    { find: 'react', replacement: 'preact/compat' },
    { find: 'react-dom', replacement: 'preact/compat' }
  ],
  build: {
    base: '/',
    target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
    polyfillDynamicImport: true,
    outDir: 'dist',
    assetsDir: 'assets',
    assetsInlineLimit: 4096,
    cssCodeSplit: true,
    sourcemap: false,
    rollupOptions: { plugins: [Array] },
    minify: 'terser',
    terserOptions: {},
    cleanCssOptions: {},
    write: true,
    manifest: false,
    lib: false,
    ssr: false
  },
  configFile: '/Users/USERNAME/Code/vite-preact-ts/vite.config.ts',
  inlineConfig: {
    root: undefined,
    mode: undefined,
    configFile: undefined,
    logLevel: undefined,
    build: {}
  },
  root: '/Users/USERNAME/Code/vite-preact-ts',
  command: 'build',
  mode: 'production',
  isProduction: true,
  optimizeCacheDir: '/Users/USERNAME/Code/vite-preact-ts/node_modules/.vite',
  server: {},
  env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  assetsInclude: [Function: assetsInclude],
  logger: {
    info: [Function: info],
    warn: [Function: warn],
    error: [Function: error],
    clearScreen: [Function: clearScreen]
  }
}
building for production...
-----------------------------
Rollup File Analysis
-----------------------------
bundle size:    1.274 MB
original size:  1.276 MB
code reduction: 0.2 %
module count:   11

█████████████████████████████████████████████████░
file:            /node_modules/@tabler/icons/icons-react/dist/index.umd.js
bundle space:    98.3 %
rendered size:   1.252 MB
original size:   1.252 MB
code reduction:  0.02 %
dependents:      1
  - /src/app.tsx

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /node_modules/preact/dist/preact.module.js
bundle space:    0.79 %
rendered size:   10.026 KB
original size:   10.267 KB
code reduction:  2.35 %
dependents:      4
  - /node_modules/preact/hooks/dist/hooks.module.js
  - /node_modules/preact/compat/dist/compat.module.js
  - /src/app.tsx
  - /src/main.tsx

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /node_modules/preact/compat/dist/compat.module.js
bundle space:    0.57 %
rendered size:   7.316 KB
original size:   8.037 KB
code reduction:  8.97 %
dependents:      2
  - �/node_modules/preact/compat/dist/compat.module.js?commonjs-proxy
  - /node_modules/@tabler/icons/icons-react/dist/index.umd.js

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /node_modules/preact/hooks/dist/hooks.module.js
bundle space:    0.2 %
rendered size:   2.588 KB
original size:   2.641 KB
code reduction:  2.01 %
dependents:      1
  - /node_modules/preact/compat/dist/compat.module.js

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            �commonjsHelpers.js
bundle space:    0.05 %
rendered size:   667 Bytes
original size:   1.414 KB
code reduction:  52.83 %
dependents:      2
  - �/node_modules/preact/compat/dist/compat.module.js?commonjs-proxy
  - /node_modules/@tabler/icons/icons-react/dist/index.umd.js

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /src/index.css
bundle space:    0.04 %
rendered size:   497 Bytes
original size:   442 Bytes
code reduction:  0 %
dependents:      1
  - /src/main.tsx

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /src/app.tsx
bundle space:    0.03 %
rendered size:   405 Bytes
original size:   461 Bytes
code reduction:  12.15 %
dependents:      1
  - /src/main.tsx

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            �/node_modules/preact/compat/dist/compat.module.js?commonjs-proxy
bundle space:    0.01 %
rendered size:   69 Bytes
original size:   240 Bytes
code reduction:  71.25 %
dependents:      1
  - /node_modules/@tabler/icons/icons-react/dist/index.umd.js

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /src/main.tsx
bundle space:    0.01 %
rendered size:   64 Bytes
original size:   134 Bytes
code reduction:  52.24 %
dependents:      1
  - /index.html

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            vite/dynamic-import-polyfill
bundle space:    0 %
rendered size:   30 Bytes
original size:   29 Bytes
code reduction:  0 %
dependents:      1
  - /index.html

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
file:            /index.html
bundle space:    0 %
rendered size:   0 Byte
original size:   272 Bytes
code reduction:  100 %
dependents:      0


[write] assets/index.5d6b8df0.js 658.18kb, brotli: 48.27kb
[write] assets/index.e8186b7a.css 0.35kb, brotli: 0.17kb
[write] index.html 0.34kb
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
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

1 participant