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(live-previews): fix replacement of the scoped default imports #5967

Merged
merged 3 commits into from
May 20, 2024

Conversation

aliemir
Copy link
Member

@aliemir aliemir commented May 20, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

Changes

In the live preview code we're replacing imports with provided scopes of packages.

Example:

import { Button } from "@mui/material";

will be replaced with:

const { Button } = MuiMaterial;

In some cases, imports may be made with subpaths/scopess of a package;

Example:

import Button from "@mui/material/Button";

In this case we've been replacing it with the same structure:

const { Button } = MuiMaterial;

This replacement was using the default import name (in this case Button) but it was flawed because the default import name don't have to match the actual export name.

Example:

import Button$1 from "@mui/material/Button";

In this case, a broken replacement is made:

const { Button$1 } = MuiMaterial;

This caused Button$1 to be undefined and break the preview.

In this PR, we've made a small change in this logic to use scope name and have a name change in the destructuring process.

Example:

import Button$1 from "@mui/material/Button";
import { default as Button$2 } from "@mui/material/Button";
import { Button } from "@mui/material";

will be replaced with

const {
  Button: Button$1,
  Button: Button$2,
  Button
} = MuiMaterial;

@aliemir aliemir requested a review from a team as a code owner May 20, 2024 08:06
Copy link

changeset-bot bot commented May 20, 2024

⚠️ No Changeset found

Latest commit: 7beb11d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented May 20, 2024

Deploy Preview for refine-video-club ready!

Name Link
🔨 Latest commit 7beb11d
🔍 Latest deploy log https://app.netlify.com/sites/refine-video-club/deploys/664b0482af92290008dfb6df
😎 Deploy Preview https://deploy-preview-5967--refine-video-club.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 20, 2024

Deploy Preview for finefoods-example-refine-dev ready!

Name Link
🔨 Latest commit 7beb11d
🔍 Latest deploy log https://app.netlify.com/sites/finefoods-example-refine-dev/deploys/664b0482acb88c000835616c
😎 Deploy Preview https://deploy-preview-5967--finefoods-example-refine-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@BatuhanW BatuhanW merged commit 327e747 into master May 20, 2024
25 checks passed
@BatuhanW BatuhanW deleted the fix/live-previews-scoped-default-imports branch May 20, 2024 08:31
@aliemir aliemir added this to the June Release milestone May 20, 2024
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.

4 participants