Skip to content

Address No "exports" main defined in package json for vite #18287

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

moshie
Copy link

@moshie moshie commented Jun 11, 2025

Summary

Package JSON is missing the main property

Fixes: #16751

Resolves:

Screenshot 2025-06-11 at 16 34 19

Test plan

I applied this fix directly in my local node modules and this fixed the error

@moshie moshie requested a review from a team as a code owner June 11, 2025 15:31
Co-authored-by: Rodrigo Espinosa de los Monteros <1084688+RodEsp@users.noreply.github.com>
@moshie
Copy link
Author

moshie commented Jun 12, 2025

@RodEsp Good catch thanks, updated

@moshie
Copy link
Author

moshie commented Jun 16, 2025

@philipp-spiess Sorry to ping you but this bug is affecting us and was wondering if you wouldn't mind reviewing this PR for me please?

@thecrypticace
Copy link
Contributor

thecrypticace commented Jun 16, 2025

Doesn't this imply that you have to use a version of node where require(esm) is enabled?

afaik the only reason this would fail is because require(…) is being used instead of import "" or await import(…) to load a file which feels weird in this case since Vite is basically all in on ESM and Vite's CJS build has been deprecated for quite a while. Afaik it's going away in Vite 7 too so I'm curious to know how/why this is happening / still a problem.

@moshie
Copy link
Author

moshie commented Jun 16, 2025

Yeah I get the feeling something is wrong in playwright's component testing which uses Vite under the hood to create the components bundle and serve it.

// playwright-ct.config.ts
import { default as tailwindcss } from "@tailwindcss/vite";
import { defineConfig } from "@playwright/experimental-ct-react";

export default defineConfig({
	use: {
		ctViteConfig: {
			plugins: [react(), tailwindcss()],
		},
	},
});

I can see from the error tract that they are using the CJS loader.

I'll try and make time to create a reproduction which I'll share in a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vite Plugin Does Not Work With Storybook Vite
3 participants