4.42.0 • Published 1 month ago

@backpackjs/storefront v4.42.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

A Sort of Guide to Migrating to @backpackjs/storefront v2 + Cart API

The following is guide for migrating a project currently using @backpackjs/storefront v1 to use @backpackjs/storefront v2 with the new Cart API. It's loosely based off of seven commits made by Nguyen, each addressing a different part of the migration. If you follow along and do the same things that he did in these seven commits, you should be somewhere between 80 - 90% done with the migration. The remaining work will/ be project specific and I'm not sure there's much I can do for you there.

The 7 Commits (👈🏻 this links to the pull request)

  1. feat: initial scaffold for migrating LIV to latest (👈🏻 these link to the headings in this document)
  2. chore: replace singular inits with useStorefrontInit in layout
  3. fix: the cart selects in local store
  4. feat: fix up the cart line items and some elevar stuff
  5. feat: fix up account page
  6. fix: add checks in for elevar orders [1]
  7. fix: add checks in for elevar orders [2]

  1. feat: initial scaffold for migrating LIV to latest (👈🏻 this links to the commit)

    Objectives

    • Update dependencies in package.json^1 (👈🏻 and these link to examples of whatever was just talked about)
    • Migrate all imports using '@backpackjs/storefront'; to '@backpackjs/storefront/v2';
    • Eliminate all instances of @backpackjs/utilities being imported into the project and replace with the equivalent functionality ^2

    Gotchas

    • Problem: You may need to add components that aren't in the project and are no longer available in newer versions of @backpackjs/storefront

      Solution: First check all your projects and see if you can find a version of the component you need. If you can't find it anywhere there, you'll have to go and look at an old commit from a point in time when the monorepo had what you're looking for.

      For example, say you need the ShopifyMedia component but you can't find it anywhere. You suspect that it was in the storefront package back in January, so you find a commit from January, then you find and click on the button that says "Browse Files" and then you search for the component, utility, whatever you're looking for.

    • Problem: Occurances of @backpackjs/utilities are infrequent and can difficult to anticipate and identify

      Solution: The easiest way to resolve this quickly is to do a find all in folder search for @backpackjs/utilities and just pick them off one by one. You may have to move the actual utility function into the project somewhere. Use this change as an example.

  2. chore: replace singular inits with useStorefrontInit in layout

    Objectives

    • Add what is now the now only init to layouts/Storefront.jsx^3
    • Remove all instances of useCartInit and useCustomerInit^4

    Gotchas

    • none
  1. fix: the cart selects in local store

    Objectives

    • Update the data passed to cartAddItem and it's derivatives
      • variantId becomes merchandiseId ^6
      • customAttributes becomes attributes ^7
    • Update the data passed to cartUpdateItem and it's derivatives
      • id becomes lineId
    • Either the data structure for the cart changed or one of the values in the cart changed type (e.g. string to Base64 encoded) and as a result we have to do a little more legwork to find matches in the cart^8
    • Additionally, the nomenclature has changed between the buy sdk and the new Cart API. What was once known as lineItems is now simply known as lines^9

    Gotchas

    • Problem: The changes in data structure and wording can be pretty subtle and difficult to spot at times

      Solution: Be aware that wherever this type of data shows up is usually preceeded by fetching some data from the recoil store e.g. get(store.state.cartItems$). Because your project might be different enough that you couldn't just copy liquid-iv, you might need to do a little sleuthing in order to find all the places that need to be updated. First, I would think of all the places where cart data is used and poke around there for and updates. And then second, I would do a search all for "get(store.state." and look around there, and by that point you should have found everything.

  1. feat: fix up the cart line items and some elevar stuff

    Objectives

    • Add some optional chaining inside elevar data to avoid throwing errors^11
    • Account for changes in data structure inside cart variant prices^13

    Gotchas

    • none
  1. feat: fix up account page

    Objectives

    • Note the change in data returned from useCustomerAddresses and update accordingly^14
    • Remove any imports leveraging the dynamic import^15
    • Remove redirect logic for customers with accounts but no order history^16

    Gotchas

    • Problem: Note how optional chaining is added in varoius places throughout. You might think that you don't have to bother with making those little changes because they won't actually make any difference and so you don't. Then 45 minutes passes and an unexplained error pops up all of a sudden. Then three days pass and, oop, another unexplained error. A week goes by, a month, and the whole time all these seemingly random cannot read property of undefined errors keep popping up.

      Solution: Those optional chainging updates were/are probably in there for some reason. Save yourself the headache and just add them now instead of periodically over the next four months.

  1. fix: add checks in for elevar orders [1]

    Objectives

    Gotchas

    • none
  2. fix: add checks in for elevar orders [2]

    Objectives

    Gotchas

    • none

^7: That update got missed in this commit but now is the best time to make that change

4.42.0-next.0

1 month ago

4.42.1-next.0

1 month ago

4.42.0

1 month ago

4.41.1-next.0

4 months ago

4.41.0

4 months ago

4.40.0

5 months ago

4.39.8-next.0

5 months ago

4.37.0

10 months ago

4.36.2-next.0

10 months ago

4.37.0-next.0

10 months ago

4.36.0

11 months ago

4.39.1

8 months ago

4.39.0

9 months ago

4.39.5

8 months ago

4.39.4

8 months ago

4.39.3

8 months ago

4.39.2

8 months ago

4.39.7

6 months ago

4.39.6

7 months ago

4.38.0

9 months ago

4.39.2-next.1

8 months ago

4.39.2-next.0

8 months ago

4.39.6-next.0

8 months ago

4.39.6-next.1

8 months ago

4.36.0-next.0

11 months ago

4.39.1-next.1

8 months ago

4.39.1-next.0

8 months ago

4.39.5-next.0

8 months ago

4.40.0-next.0

6 months ago

4.37.1-next.0

10 months ago

4.37.1-next.2

9 months ago

4.37.1-next.1

9 months ago

4.36.1-next.2

10 months ago

4.36.1-next.0

10 months ago

4.36.1-next.1

10 months ago

4.38.0-next.0

9 months ago

4.39.3-next.0

8 months ago

4.35.3-next.1

11 months ago

4.35.3-next.0

11 months ago

4.35.3

11 months ago

4.35.2

11 months ago

4.35.4-next.0

11 months ago

1.14.13

11 months ago

4.33.5

1 year ago

4.33.4

1 year ago

4.33.6-next.1

12 months ago

4.33.6-next.0

1 year ago

4.32.4

12 months ago

4.35.1

12 months ago

4.35.0

12 months ago

4.34.1-next.0

12 months ago

4.34.1

12 months ago

4.34.0

12 months ago

4.35.1-next.0

12 months ago

4.33.5-next.3

1 year ago

4.33.5-next.1

1 year ago

4.33.5-next.2

1 year ago

4.33.5-next.0

1 year ago

4.34.2-next.0

12 months ago

4.34.2-next.1

12 months ago

4.35.2-next.1

11 months ago

4.35.2-next.0

12 months ago

4.33.2-next.2

1 year ago

4.33.2-next.3

1 year ago

4.33.2-next.1

1 year ago

4.33.3-next.0

1 year ago

4.33.3-next.1

1 year ago

4.33.3

1 year ago

4.33.2

1 year ago

4.33.4-next.0

1 year ago

4.33.2-next.0

1 year ago

4.32.4-next.0

1 year ago

4.32.4-next.1

1 year ago

4.31.0-next.0

1 year ago

4.31.1-next.0

1 year ago

4.34.0-next.1

1 year ago

4.34.0-next.0

1 year ago

4.32.3-main.75

1 year ago

4.32.3-main.76

1 year ago

4.33.1

1 year ago

4.33.0

1 year ago

4.32.3-main.8

1 year ago

4.32.0

1 year ago

4.32.3

1 year ago

4.32.2

1 year ago

4.32.1

1 year ago

4.32.3-next.0

1 year ago

4.32.3-next.6

1 year ago

4.32.1-next.0

1 year ago

4.32.1-next.1

1 year ago

4.32.2-next.0

1 year ago

4.31.0

1 year ago

4.31.2-next.0

1 year ago

4.31.2-next.1

1 year ago

4.29.1-next.1

1 year ago

4.29.1-next.0

1 year ago

4.29.0-next.0

1 year ago

4.29.2-next.1

1 year ago

4.29.2-next.0

1 year ago

4.30.0

1 year ago

4.29.1

1 year ago

4.29.0

1 year ago

4.25.0

2 years ago

4.28.3-next.0

1 year ago

4.26.0

2 years ago

4.26.1

1 year ago

4.26.1-next.0

1 year ago

4.24.0

2 years ago

4.28.2

1 year ago

4.28.3

1 year ago

4.28.4

1 year ago

4.26.2-next.2

1 year ago

4.26.2-next.0

1 year ago

4.26.2-next.1

1 year ago

4.24.0-next.0

2 years ago

4.27.1

1 year ago

4.28.4-next.1

1 year ago

4.28.4-next.0

1 year ago

4.28.4-next.2

1 year ago

4.27.1-next.0

1 year ago

4.27.2-next.0

1 year ago

4.25.1-next.2

2 years ago

4.25.1-next.1

2 years ago

4.25.1-next.0

2 years ago

4.28.5-next.0

1 year ago

4.24.1-next.0

2 years ago

1.14.11

1 year ago

1.14.12

1 year ago

4.28.2-next.0

1 year ago

4.22.3-next.0

2 years ago

4.22.0-next.0

2 years ago

4.23.1-main.133

2 years ago

1.14.5

2 years ago

1.14.4

2 years ago

1.14.8

2 years ago

1.14.7

2 years ago

1.14.6

2 years ago

1.14.10

2 years ago

4.23.0

2 years ago

4.22.0

2 years ago

4.22.1

2 years ago

4.22.2

2 years ago

4.22.3

2 years ago

4.9.0

2 years ago

1.11.1

2 years ago

4.8.0

2 years ago

4.7.1-next.0

2 years ago

4.7.1-next.1

2 years ago

4.2.0-next.0

2 years ago

4.7.0

2 years ago

1.10.0

2 years ago

4.6.0

2 years ago

1.11.0

2 years ago

1.13.0

2 years ago

4.10.3-next.0

2 years ago

4.5.0

2 years ago

1.14.1

2 years ago

1.14.0

2 years ago

1.14.3

2 years ago

1.14.2

2 years ago

4.21.0

2 years ago

4.11.1-next.0

2 years ago

4.4.0

2 years ago

4.10.1

2 years ago

4.10.2

2 years ago

4.10.0

2 years ago

1.9.1

2 years ago

4.2.1-next.1

2 years ago

4.2.1-next.0

2 years ago

4.20.0

2 years ago

4.3.0

2 years ago

4.12.3

2 years ago

4.12.4

2 years ago

4.12.5

2 years ago

4.12.6

2 years ago

1.9.5

2 years ago

1.9.4

2 years ago

1.9.3

2 years ago

4.2.0

2 years ago

1.9.2

2 years ago

4.12.0

2 years ago

4.12.1

2 years ago

4.12.2

2 years ago

4.0.1-next.0

2 years ago

4.1.0

2 years ago

4.11.0

2 years ago

2.0.0-ssg-fix.0

2 years ago

2.0.1-ssg-fix.0

2 years ago

1.8.2

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.8.4

2 years ago

1.8.3

2 years ago

0.5.10

2 years ago

0.5.11

2 years ago

1.6.0

2 years ago

0.5.12

2 years ago

0.5.13

2 years ago

1.5.0

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.9

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.3

2 years ago

0.3.20

2 years ago

0.3.27

2 years ago

0.3.26

2 years ago

0.3.25

2 years ago

0.3.23

2 years ago

0.3.21

2 years ago

0.3.19

2 years ago

0.3.18

2 years ago

0.3.17

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.3.0

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.16

2 years ago

0.3.15

2 years ago

0.3.14

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.1.63

2 years ago

0.1.65

2 years ago

0.1.60

2 years ago

0.1.61

2 years ago

0.1.62

2 years ago

0.2.2

2 years ago

0.1.40

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.24

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.16

2 years ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.8

2 years ago

0.1.9

2 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.0.203

3 years ago

0.0.202

3 years ago

0.0.201

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.0.199

3 years ago

0.0.198

3 years ago

0.0.197

3 years ago

0.0.196

3 years ago

0.0.195

3 years ago

0.0.194

3 years ago

0.0.193

3 years ago

0.0.192

3 years ago

0.0.191

3 years ago

0.0.190

3 years ago

0.0.189

3 years ago

0.0.188

3 years ago

0.0.187

3 years ago

0.0.186

3 years ago

0.0.185

3 years ago

0.0.184

3 years ago

0.0.183

3 years ago

0.0.182

3 years ago

0.0.181

3 years ago

0.0.180

3 years ago

0.0.179

3 years ago

0.0.178

3 years ago

0.0.177

3 years ago

0.0.176

3 years ago

0.0.175

3 years ago

0.0.174

3 years ago

0.0.173

3 years ago

0.0.172

3 years ago

0.0.171

3 years ago

0.0.170

3 years ago

0.0.169

3 years ago

0.0.168

3 years ago

0.0.167

3 years ago

0.0.166

3 years ago

0.0.165

3 years ago

0.0.164

3 years ago

0.0.163

3 years ago

0.0.162

3 years ago

0.0.161

3 years ago

0.0.160

3 years ago

0.0.159

3 years ago

0.0.158

3 years ago

0.0.157

3 years ago

0.0.156

3 years ago

0.0.155

3 years ago

0.0.154

3 years ago

0.0.153

3 years ago

0.0.152

3 years ago

0.0.151

3 years ago

0.0.150

3 years ago

0.0.149

3 years ago

0.0.148

3 years ago

0.0.147

3 years ago

0.0.146

3 years ago

0.0.145

3 years ago

0.0.144

3 years ago

0.0.143

3 years ago

0.0.142

3 years ago

0.0.141

3 years ago

0.0.140

3 years ago

0.0.139

3 years ago

0.0.138

3 years ago

0.0.137

3 years ago

0.0.136

3 years ago

0.0.135

3 years ago

0.0.134

3 years ago

0.0.133

3 years ago

0.0.132

3 years ago

0.0.131

3 years ago

0.0.130

3 years ago

0.0.129

3 years ago

0.0.128

3 years ago

0.0.127

3 years ago

0.0.126

3 years ago

0.0.125

3 years ago

0.0.124

3 years ago

0.0.123

3 years ago

0.0.122

3 years ago

0.0.121

3 years ago

0.0.120

3 years ago

0.0.119

3 years ago

0.0.118

3 years ago

0.0.117

3 years ago

0.0.116

3 years ago

0.0.115

3 years ago

0.0.114

3 years ago

0.0.113

3 years ago

0.0.112

3 years ago

0.0.111

3 years ago

0.0.110

3 years ago

0.0.109

3 years ago

0.0.108

3 years ago

0.0.107

3 years ago

0.0.106

3 years ago

0.0.105

3 years ago

0.0.104

3 years ago

0.0.103

3 years ago

0.0.102

3 years ago

0.0.101

3 years ago

0.0.100

3 years ago

0.0.25

3 years ago

0.0.24

3 years ago

0.0.23

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago