Skip to content

Conversation

BPScott
Copy link
Member

@BPScott BPScott commented Aug 13, 2019

WHY are these changes introduced?

Maintaining our own CDN distribution of our CSS files is a little annoying as it leads to more complex builds. Let's let unpkg handle our CDN styles (just like IBM's Carbon design system and React).

The first step to that is adding minified styles into npm package - that was #1957
The second step is ripping out our build config that uploads files to sdks.shopifycdn.com and updates our links to unpkg.com files (that's this PR)

WHAT is this pull request doing?

  • Stop publishing css files to sdks.shopifycdn.com
  • Update docs to use unpkg link for CSS files
  • Make it clear that we suggest downloading these files and hosting them yourself rather than using unpkg directly

How to 🎩

  • Read doc updates and ensure they make sense and the links work
  • Smile and nod that the deploy scripts are dead
  • Note that sdks.shopifycdn is never referenced elsewhere in the project

@BPScott BPScott temporarily deployed to polaris-react-pr-1960 August 13, 2019 17:36 Inactive
@BPScott
Copy link
Member Author

BPScott commented Aug 13, 2019

This is a draft PR for now. Once #1957 is merged and a new RC is released, I shall rebase this atop latest master and confirm it is ready for review.

@BPScott BPScott force-pushed the use-unpkg-for-cdn branch from 8466d29 to 3d8e4c0 Compare August 13, 2019 17:42
@BPScott BPScott temporarily deployed to polaris-react-pr-1960 August 13, 2019 17:43 Inactive
@BPScott BPScott force-pushed the use-unpkg-for-cdn branch from 3d8e4c0 to b4f648d Compare August 15, 2019 14:28
@BPScott BPScott temporarily deployed to polaris-react-pr-1960 August 15, 2019 14:28 Inactive
@BPScott BPScott force-pushed the use-unpkg-for-cdn branch from b4f648d to 0c7d578 Compare August 15, 2019 14:35
@BPScott BPScott temporarily deployed to polaris-react-pr-1960 August 15, 2019 14:35 Inactive
@BPScott BPScott marked this pull request as ready for review August 15, 2019 14:40
- Stop publishing css files to sdks.shopifycdn.com
- Update docs to use unpkg link for CCSS files
- Make it clear that we sugggest downloading these files and hosting
  them yourself rather than using unpkg directly
@BPScott BPScott force-pushed the use-unpkg-for-cdn branch from 0c7d578 to 1b54456 Compare August 15, 2019 14:55
@BPScott BPScott temporarily deployed to polaris-react-pr-1960 August 15, 2019 14:55 Inactive
Copy link
Member

@chloerice chloerice left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a couple of minor questions.

import '@shopify/polaris/styles.css';
```

Otherwise include the CSS in your HTML. We suggest copying the styles file into your own project, but you may also use it directly:
Copy link
Member

Choose a reason for hiding this comment

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

We suggest copying the styles file into your own project

Do we want to recommend this because we don't want to be tied to unpkg? I think if we clarify why we suggest this, it will help people understand why it would be worth copying vs linking in their HTML.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking more along the lines that generally don't want to add an extra point of failure your app - why pull in stuff from another host when you can your own.

That tradeoff affects all 3rd party code it doesn't seem that polaris specific so i left it out as it felt like already implied knowledge.

How about: We suggest copying the styles file into your own project to avoid adding extra hosts you depend upon, but you may also use it directly?

Copy link
Member

Choose a reason for hiding this comment

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

I guess I just find it confusing because using a CDN is supposed to be better performance wise than having a bunch of styles local to your app. Having all of the Bootstrap styles local to your app for instance would be insane vs having the CDN link. I'm struggling to find it convincing to consumers as something that would be a useful tradeoff.

extra point of failure your app

If we frame copying it to your app locally as a fallback in case the CDN is down does that makes sense? Or are you thinking of other points of failure?

Copy link
Member Author

Choose a reason for hiding this comment

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

This article is handy https://csswizardry.com/2019/05/self-host-your-static-assets/

a CDN is supposed to be better performance wise than having a bunch of styles local to your app.

Broadly speaking yes. However much of those benefits are lost if you you've got one asset on a different host to everything else - it's another host you have to negotiate a connection with and you lose any resource prioritization. The time you lose to those things offset any gain you'd get from using a CDN. It's preferable to keep all your critical static assets on a single host - even if that host isn't fronted by a CDN.

Having all of the Bootstrap styles local to your app for instance would be insane vs having the CDN link.

Indeed it would, however having the single boostrap.min.css file hosted on the same server as your other static assets would be preferable to both, which is the style of hosting we're talking about :)

If we frame copying it to your app locally as a fallback in case the CDN is down does that makes sense?

I think that pattern adds extra complication for negligible additional resilience. I don't think it is worth explaining or promoting it.

Copy link
Member

Choose a reason for hiding this comment

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

The time you lose to those things offset any gain you'd get from using a CDN. It's preferable to keep all your critical static assets on a single host - even if that host isn't fronted by a CDN.

Ahhh okay, that makes sense. Thank you for clarifying!

Copy link
Member Author

Choose a reason for hiding this comment

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

Any time :)

- Added support for React hooks in Storybook ([#1665](https://github.com/Shopify/polaris-react/pull/1665))
- Created `toBeDisabled`, `mountWithContext` and added custom testing matchers ([#1596](https://github.com/Shopify/polaris-react/pull/1596))
- Enabled strict mode in TypeScript ([#1883](https://github.com/Shopify/polaris-react/pull/1883))
- Moved to `unpkg.com` for our CDN CSS assets, instead of using `sdks.shopifycdn.com`. Existing URLs will continue to work but new versions will only be available on `unpkg.com` ([#1960](https://github.com/Shopify/polaris-react/pull/1960))
Copy link
Member

@chloerice chloerice Aug 15, 2019

Choose a reason for hiding this comment

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

Is there a section in the change log for breaking changes? Will this change also be included in the upgrade instructions for v4?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a breaking changes section. Do you think it belongs there more? I was torn as existing links will still continue to work, it's only if you want the new stuff the URL has changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll also be mentioning this in the migration guide doc that is being written in #1945

Copy link
Member

@chloerice chloerice Aug 15, 2019

Choose a reason for hiding this comment

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

Agreed--since the old links continue to work and it's just moving forward from v4 on that the domain changes, it wouldn't make sense to call this a breaking change 👍

I do think it's worth mentioning in the v4 upgrade instructions though, since people are used to just swapping out the semver version number when they upgrade but this is a whole new host.

@BPScott
Copy link
Member Author

BPScott commented Aug 15, 2019

Gonna merge as is, I've got some follow-up work to tidy up the getting started examples so we can tweak the wording around CSS hosting recommendations in there.

@BPScott BPScott merged commit accb2f7 into master Aug 15, 2019
@BPScott BPScott deleted the use-unpkg-for-cdn branch August 15, 2019 19:16
BPScott added a commit that referenced this pull request Aug 19, 2019
- Stop publishing css files to sdks.shopifycdn.com
- Update docs to use unpkg link for CCSS files
- Make it clear that we sugggest downloading these files and hosting
  them yourself rather than using unpkg directly
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.

2 participants