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(gatsby-plugin-netlify-cms): Mark relevant dependencies as externals #19575

Merged
merged 8 commits into from
Nov 26, 2019

Conversation

erezrokah
Copy link
Contributor

@erezrokah erezrokah commented Nov 17, 2019

Fixes #18245
Fixes #17568

I can split this into two PRs (one per issue) if needed.

Main changes:

  1. Mark netlify-cms-app and relevant dependencies as externals to avoid re-build during bundle. netlify-cms-app,netlify-identity-widget, react and react-dom are already set up for that since they expose a global variable on the window object which Webpack can reference instead of importing the module.

  2. The reason netlify-identity-widget was still included in the main app bundle here is that it didn't pass Gatsby's default thresholds for code splitting. Forcing it into its own cache group makes sure it's not in the app bundle.
    It will still be included in the html as a link tag with a preload attribute, since it is imported as a runtime dependency (though we do know at build time it won't be needed). I actually wrote some code to remove it from the html using a gatsby-ssr.js but then realized it will prevent using the widget all together in other contexts than the plugin (not sure such a scenario exists).
    Along with code splitting the widget when enableIdentityWidget is true, when the widget is disabled it will be ignored completely from the build via the webpack.IgnorePlugin plugin.

Would love to get some feedback and if there is something I can do to make it easier for other people to test it please let me know (thought about publishing it separately).

Also, I'm not sure how to go about versioning.

Update:
Also fixes #15126

@erezrokah erezrokah requested a review from erquhart November 17, 2019 19:42
@erezrokah erezrokah requested a review from a team as a code owner November 17, 2019 19:42
@LekoArts LekoArts added status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response type: feature or enhancement labels Nov 20, 2019
@erezrokah erezrokah force-pushed the fix/gatsby_plugin_netlify_cms branch from cc3a3c9 to ec5424b Compare November 20, 2019 11:24
@erezrokah erezrokah force-pushed the fix/gatsby_plugin_netlify_cms branch from ec5424b to 1459b05 Compare November 26, 2019 11:37
Copy link
Contributor

@erquhart erquhart left a comment

Choose a reason for hiding this comment

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

@LekoArts this is good to go 👍

@sidharthachatterjee sidharthachatterjee removed the status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response label Nov 26, 2019
@sidharthachatterjee sidharthachatterjee changed the title fix: gatsby plugin netlify cms fix(gatsby-plugin-netlify-cms): Mark relevant dependencies as externals Nov 26, 2019
Copy link
Contributor

@sidharthachatterjee sidharthachatterjee left a comment

Choose a reason for hiding this comment

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

Thank you so much! 🥇

@sidharthachatterjee sidharthachatterjee added the bot: merge on green Gatsbot will merge these PRs automatically when all tests passes label Nov 26, 2019
@gatsbybot gatsbybot merged commit 8137255 into gatsbyjs:master Nov 26, 2019
@gatsbot
Copy link

gatsbot bot commented Nov 26, 2019

Holy buckets, @erezrokah — we just merged your PR to Gatsby! 💪💜

Gatsby is built by awesome people like you. Let us say “thanks” in two ways:

  1. We’d like to send you some Gatsby swag. As a token of our appreciation, you can go to the Gatsby Swag Store and log in with your GitHub account to get a coupon code good for one free piece of swag. We’ve got Gatsby t-shirts, stickers, hats, scrunchies, and much more. (You can also unlock even more free swag with 5 contributions — wink wink nudge nudge.) See gatsby.dev/swag for details.
  2. We just invited you to join the Gatsby organization on GitHub. This will add you to our team of maintainers. Accept the invite by visiting https://github.com/orgs/gatsbyjs/invitation. By joining the team, you’ll be able to label issues, review pull requests, and merge approved pull requests.

If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes
Projects
None yet
5 participants