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

feat: show error when accessing variables not exposed in CJS build #18649

Conversation

sapphi-red
Copy link
Member

Description

No error happened when accessing variables not exposed in CJS build. This PR adds an error for that, so the user can know what is needed to do.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Nov 13, 2024
@sapphi-red sapphi-red added this to the 6.0 milestone Nov 13, 2024
packages/vite/index.cjs Outdated Show resolved Hide resolved
packages/vite/index.cjs Outdated Show resolved Hide resolved
Co-authored-by: Bjorn Lu <[email protected]>
bluwy
bluwy previously approved these changes Nov 13, 2024
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can look into a Rollup plugin or a post-build script that ensures the exports are properly implemented in both ESM and CJS, but I think that can be done later.

@sapphi-red
Copy link
Member Author

Added that check (fbcfc1c) 👍

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sapphi-red sapphi-red merged commit 87c5502 into vitejs:main Nov 13, 2024
15 checks passed
@sapphi-red sapphi-red deleted the feat/show-error-when-accessing-vars-not-expose-in-cjs-build branch November 22, 2024 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants