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(resolve)!: remove resolve.browserField #14733

Merged
merged 4 commits into from
Oct 24, 2023
Merged

feat(resolve)!: remove resolve.browserField #14733

merged 4 commits into from
Oct 24, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Oct 23, 2023

Description

resolve.browserField was introduced deprecated by default in #10071. The plan was to update resolve.mainFields to ['browser', 'module', 'jsnext:main', 'jsnext'] which I did in this PR.

This particular change can be breaking for tooling as some tools (e.g. vite-plugin-svelte) wants to add additional mainFields, and the only way to not remove the existing ['module', 'jsnext:main', 'jsnext'] was to hardcode it:

https://github.com/sveltejs/vite-plugin-svelte/blob/b4b4fddf4d226856aa0f27fa4f32621dfb2938bf/packages/vite-plugin-svelte/src/utils/constants.js#L1

https://github.com/sveltejs/vite-plugin-svelte/blob/b4b4fddf4d226856aa0f27fa4f32621dfb2938bf/packages/vite-plugin-svelte/src/utils/options.js#L359-L362

Additional context

Noticed this while working on #14723


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

@bluwy bluwy added p2-nice-to-have Not breaking anything but nice to have (priority) breaking change labels Oct 23, 2023
@stackblitz
Copy link

stackblitz bot commented Oct 23, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Comment on lines 138 to -140
const resolveOptions: NodeImportResolveOptions = {
mainFields: ['main'],
browserField: true,
Copy link
Member Author

@bluwy bluwy Oct 23, 2023

Choose a reason for hiding this comment

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

I'm not sure if this was a mistake, the browserField was used in SSR resolving.

Copy link
Member

Choose a reason for hiding this comment

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

Before #10071, Vite used browser field even with ssrModuleLoader and I wanted to preserve that behavior to avoid a breaking change. I think this change makes sense.

@patak-dev
Copy link
Member

Looks good to me. I think it would be good to add a warning if the user has browserField: false and 'browser' is present in mainFields to help with the migration.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

Thanks! I forgot about this thing 😅

packages/vite/src/node/plugins/resolve.ts Show resolved Hide resolved
Comment on lines 138 to -140
const resolveOptions: NodeImportResolveOptions = {
mainFields: ['main'],
browserField: true,
Copy link
Member

Choose a reason for hiding this comment

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

Before #10071, Vite used browser field even with ssrModuleLoader and I wanted to preserve that behavior to avoid a breaking change. I think this change makes sense.

@bluwy
Copy link
Member Author

bluwy commented Oct 24, 2023

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 297b425: Open

suite result latest scheduled
analogjs success success
astro success success
histoire success success
ladle success success
laravel failure failure
marko failure failure
nuxt success success
nx failure failure
previewjs success success
qwik success success
rakkas success success
sveltekit success failure
unocss success success
vike success failure
vite-plugin-pwa failure failure
vite-plugin-react success success
vite-plugin-react-pages success success
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success success
vite-setup-catalogue success success
vitepress success success
vitest success failure

@bluwy bluwy merged commit 43cc3b9 into main Oct 24, 2023
10 checks passed
@bluwy bluwy deleted the browser-field-away branch October 24, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants