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

fix: optimize lodash imports #3974

Merged
merged 2 commits into from Dec 15, 2022
Merged

fix: optimize lodash imports #3974

merged 2 commits into from Dec 15, 2022

Conversation

stipsan
Copy link
Member

@stipsan stipsan commented Dec 15, 2022

Description

The babel-plugin-lodash optimization appears to no longer be working. Look at the output of lib/router.esm.js for example and how it have this output:

import { intersection, difference, pick, isPlainObject, flatten, identity } from 'lodash';

This PR fixes it so that it generates this output:

import flatten from 'lodash/flatten.js';
import difference from 'lodash/difference.js';
import intersection from 'lodash/intersection.js';
import isPlainObject from 'lodash/isPlainObject.js';
import pick from 'lodash/pick.js';
import identity from 'lodash/identity.js';

This also fixes the ESM URL use case:

const {renderStudio} = await import('https://esm.sh/sanity') // Use `https://esm.sh/sanity@3.0.6` to reproduce the same error as seen at the time of this PR
// Uncaught SyntaxError: The requested module '/v99/lodash@4.17.21/es2022/lodash.js' does not provide an export named 'isPlainObject' (at router.js:formatted:5:56)

What to review

Since it's just an optimisation step it shouldn't break any existing behaviour or introduce new behaviour, beyond a smaller bundle size.

Notes for release

  • fix: lodash imports are optimized again

@vercel
Copy link

vercel bot commented Dec 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Dec 15, 2022 at 11:37AM (UTC)
1 Ignored Deployment
Name Status Preview Comments Updated
studio-workshop ⬜️ Ignored (Inspect) Dec 15, 2022 at 11:37AM (UTC)

Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

:yay-cat:

@stipsan stipsan merged commit 6c7d48d into next Dec 15, 2022
@stipsan stipsan deleted the fix-lodash-esm branch December 15, 2022 13:14
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.

None yet

2 participants