Skip to content

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

Merged
sapphi-red merged 5 commits into
vitejs:mainfrom
sapphi-red:feat/show-error-when-accessing-vars-not-expose-in-cjs-build
Nov 13, 2024
Merged

sapphi-red merged 5 commits into
vitejs:mainfrom
sapphi-red:feat/show-error-when-accessing-vars-not-expose-in-cjs-build

Conversation

@sapphi-red

Copy link
Copy Markdown
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
Comment thread packages/vite/index.cjs Resolved
Comment thread packages/vite/index.cjs Resolved
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
bluwy
bluwy previously approved these changes Nov 13, 2024

@bluwy bluwy left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

Added that check (fbcfc1c) 👍

@bluwy bluwy left a comment

Copy link
Copy Markdown
Member

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
@sapphi-red
sapphi-red deleted the feat/show-error-when-accessing-vars-not-expose-in-cjs-build branch November 22, 2024 11:23
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
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