-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Resolving dependencies without entry point #247
Comments
How do you use such a package then? Only with deep imports? And what does a typical BuckleScript package look like? Could’ve at least provided an example. |
Sorry for not providing an example - here is example repo https://github.com/baransu/vite-issue-247. It's a vite reason-react template with my small addition to present my issue. It uses 2 Reason (BuckleScript) packages:
BuckleScript uses deep imports to modules you want to use. Here is an example of |
I added more graceful handling of package with no main field (or non-existent main field) in the commit above, but that won't make your repro run because I think overall Reason/BuckleScript ecosystem has some problematic integration practices with the npm ecosystem - e.g. declaring a main file that does not exist is simply wrong, and shipping non-ESM-compatible dist files is something Vite simply does not intend to support. |
BuckleScript provides support for ESM output for packages (as well as CommonJS). I’m not sure about single entry point for packages vs deep imports we use atm. JS output is not intended to be included into version control and compiler during clean compilation generates new JS files thats why we cannot rely on JS entrypoints. |
Describe the bug
Currently, when resolving dependencies
vite
looks inpackage.json
formodule
orentry
, otherwise it fallbacks toindex.js
:vite/src/node/resolver.ts
Line 245 in 3f0aff9
This is problematic with BuckleScript compiled modules where ReasonML files are transpiled 1:1 into
*.bs.js
files without a single "entry" module. Later when using such a package in your application, paths point directly to the module you need without unnecessary reexports.Right now
vite
throws an unhandled exception when trying to use such package when index.js is not found:vite/src/node/depOptimizer.ts
Line 129 in 3f0aff9
As I understand the solution would be to exclude those packages in
vite.config.js
but it can be tedious as none of the BuckleScript packages use entry point convention and there is no way to do it using the BuckleScript compiler (but it's outside of the scope of this issue).Reproduction
System Info
vite
version:0.16.10
macOS 10.15.4
v10.16.3
vue
version (fromyarn.lock
orpackage-lock.json
)@vue/compiler-sfc
versionLogs (Optional if provided reproduction)
vite
orvite build
with the--debug
flag.The text was updated successfully, but these errors were encountered: