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

optimizeDeps ignores deep imports #12326

Closed
7 tasks done
gajus opened this issue Mar 7, 2023 · 1 comment
Closed
7 tasks done

optimizeDeps ignores deep imports #12326

gajus opened this issue Mar 7, 2023 · 1 comment

Comments

@gajus
Copy link
Contributor

gajus commented Mar 7, 2023

Describe the bug

I am expecting @contra/utilities to be converted from CommonJS to ESM by ESbuild when I configure { optimizeDeps: ['@contra/utilities'] }. Instead, @contra/utilities is not processed by ESbuild.

@contra/utilities defines explicit "exports", i.e. it is included as:

import { hasOwnPropertyAlt } from '@contra/utilities/hasOwnPropertyAlt'

It appears that optimizeDeps only works if I explicitly define the exported route: {optimizeDeps: ['@contra/utilities/hasOwnPropertyAlt']}

I expect that it would be enough to define @contra/utilities.

A possible solution: Allow to use Regex in includes, i.e. { optimizeDeps: [/@contra/] }

Reproduction

N/A

Steps to reproduce

N/A

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.59 GB / 64.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.volta/tools/image/node/18.12.1/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.19.2 - ~/.volta/tools/image/node/18.12.1/bin/npm
    Watchman: 2023.02.06.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 110.0.5481.177
    Safari: 15.4
  npmPackages:
    @vitejs/plugin-react: ^3.1.0 => 3.1.0
    vite: ^4.1.4 => 4.1.4

Used Package Manager

pnpm

Logs

It appears like

  vite:config } +187ms
{
  optimizeDeps: {
    disabled: 'build',
    include: [
      '@contra/utilities',
      'react/jsx-runtime',
      'react/jsx-dev-runtime',
      'react'
    ],
    exclude: [
      'vite-plugin-ssr/client',
      'vite-plugin-ssr/client/router',
      'vite-plugin-ssr/routing',
      '@brillout/json-serializer/parse',
      '@brillout/json-serializer/stringify'
    ],
    esbuildOptions: { preserveSymlinks: false },
    entries: [
      '/Users/gajus/Developer/contra/gaia-og4/apps/contra-web-app/renderer/_default.page.client.tsx',
      '/Users/gajus/Developer/contra/gaia-og4/apps/contra-web-app/renderer/_error.page.client.tsx',
      '/Users/gajus/Developer/contra/gaia-og4/apps/contra-web-app/src/pages/index.page.client.tsx'
    ]
  }
}
vite:resolve 1.37ms @contra/utilities -> /Users/gajus/Developer/contra/gaia-og4/packages/utilities/dist/index.js +0ms
vite:resolve 1.20ms @contra/utilities/hasOwnPropertyAlt -> /Users/gajus/Developer/contra/gaia-og4/packages/utilities/dist/hasOwnPropertyAlt.js +0ms

Validations

@gajus gajus changed the title optimizeDeps ignores exports optimizeDeps ignores deep imports Mar 7, 2023
@bluwy
Copy link
Member

bluwy commented Mar 8, 2023

Duplicate of #5419

@bluwy bluwy marked this as a duplicate of #5419 Mar 8, 2023
@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2023
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