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
v3 alpha: import fails with "Default condition should be last one" #422
Comments
I just worked on imports, build integration, etc. You can try again with alpha 11. I don't know if it is the source of your problem but I added a section about commonjs dependencies in the getting started. Also I initialized a directory with example applications to validate actual integration in different systems. Depending on your environment you might want to add an example app to help diagnose issues specific to it. |
@albanm Thanks a lot, that's so helpful! I only had time for a quick test today, I will dig into this deeper on Monday. My current situation: I tested adding commonjs to my vite-config as you described. Migrating from vue-cli to vite actually fixed the error in my original issue description, but at the moment I get
in my browser console. I haven't digged deeper into this yet, I will do that next week |
I just tested the example application you pointed towards and starting it fails with this error message:
It seems to that there are still some problems in regards to dependencies / dependency resolution for the alpha? |
I pushed a commit upgrading the example app to version 3.0.0-beta.1, it works fine in my environment. But I don't think the upgrade is changing anything in this regard. I see you are using pnpm, maybe that is the reason the dependencies are not found by vite, this example app was setup with npm. You can follow these steps to try to initialize the project with pnpm from the start and see if it changes something. |
I tested it agian with both pnpm and npm and both seem to work (At least I don't get any errors on startup as before). So this seems to be fixed for the app-example. |
@albanm My main issue is currently that I get
I am using pnpm as well. My vite.config.ts:
Are you sure these should be devDependencies?
|
Those are not dev dependencies for the library. This project uses npm workspaces, the actual package.json you are interested is in lib/package.json. It references @json-layout/core that has all these dependencies. I suppose there might be a problem with dependency hoisting or something like that. |
This is probably the answer vitejs/vite#10047 (comment) I will try to test this. I hope it is possible to have a configuration that works the same way when dependencies are flattened or nested. |
Ok, this is difficult to understand. Now the test app works even without declaring the list of commonjs deps, maybe there is a cache effect but I don't see how as I deleted node_modules/.cache and use "vite --force". I wanted to try something like this:
Can you try this or something similar @lukas-mertens ? If a path is wrong maybe you can fix it by checking where the dependency actually is using "npm ls ajv" for example. |
I've been getting the "Default condition should be last one" error with webpack. According to the Node.js docs the "default" export should always come last: Webpack enforces this and throws an error if it's not. Switching the order in the package.json files for |
I am not sure I understand the exact change you made. Is it just inverting "types" and "default" keys in the nested exports ? I should create a small test app with webpack like I did with vite. I would gladly accept a PR of this if someone has a good light project template with webpack+vue+vuetify (see https://github.com/koumoul-dev/vuetify-jsonschema-form/tree/next/app-examples). |
Yeah, inverting the "types" and "default". So, for example, this:
Becomes this:
|
@albanm exactly, this solved the issue for me using webpack as well, but then I switched to vite. Somehow this issue changed topics, I should have opened a new one, but I didn't know, at that point, that the problem was only caused by webpack. |
As this was also discussed in this issue: If someone else is struggling with the mix of commonjs/esm, read my comment here: json-layout/json-layout#1 (comment) |
I am currently testing the newest alpha
^3.0.0-alpha.7
. Currently as soon as I import vjsf using:I get a
error.
Is it possible that this has something to do with the way the
exports
are defined inpackage.json
?The text was updated successfully, but these errors were encountered: