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

Export of enum from a library gives The requested module '...' does not provide an export named 'default' #12837

Closed
7 tasks done
rf-vivanovs opened this issue Apr 12, 2023 · 1 comment

Comments

@rf-vivanovs
Copy link

Describe the bug

Trying to use a typescript export in my library gives me:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@test_test_interfaces_scopes.js?v=464ae4f6' does not provide an export named 'default' (at main.ts:5:1)

The code in question is:

import {TestScope} from "@test/test/interfaces/scopes"

console.log(TestScope.test)

I created a minimal repo from basic typescript vite example that observes the same issue.
I can see that the JS file builds correctly, but for some reason the export is trying to export default instead of targeted export.

So the expectation would be that I can just export my library written in typescript without any problems.

While similar to #12764 it is not a barrel export, just raw export

Reproduction

https:/rf-vivanovs/vitejs-export-bug

Steps to reproduce

  1. Clone the repo (node modules already included)
  2. run npm run dev
  3. Open the local link
  4. Observe that JS doesn't load
  5. Check console
  6. Observe that there is an error:
Uncaught SyntaxError: The requested module '...' does not provide an export named 'default' 

System Info

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 76.50 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    npm: 8.19.3 - ~/.nvm/versions/node/v16.19.0/bin/npm
  Browsers:
    Chrome: 112.0.5615.49
    Safari: 16.3
  npmPackages:
    vite: ^4.2.0 => 4.2.1

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Apr 13, 2023

If you're exporting a library with raw TS files, you need to specify that library in optimizeDeps.exclude. esbuild is currently optimizing that into JS, so it doesn't work when you try to import it.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 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