SlideShare una empresa de Scribd logo
1 de 47
Descargar para leer sin conexión
Pitfalls when developing with the
SharePoint Framework (SPFx)
Chris O’Brien (MVP)
Independent/Content and Code, UK
Add
Speaker
Photo here
Notes on this presentation
If you have previously seen this presentation/slide deck
before, note the following updates:
Content Slides
Pitfalls around Office UI Fabric 27-30
Pitfalls around calling the Microsoft
Graph or custom APIs secured with Azure
Active Directory
31-35
Use of SPFx component bundles 40-42
Fundamentals – how it all works
Packages installed/updated using npm
• .NET analogy = NuGet
Dependent JS libraries stored in node_modules
• .NET analogy = the BIN directory
• Gets bundled/deployed with your app
Package.json records your top-level dependencies
• .NET analogy = packages.config
• Allows other devs to build app from source control
• N.B. Each dependency may have IT’S OWN dependencies and package.json
COB App
- node_modules
- jQuery
- node_modules
- cache-swap
- node_modules
- React
- node_modules
……
Simplified node_modules hierarchy
Fundamentals - how to add a library
Use npm install command e.g:
npm install jquery
Installs library to your app (in node_modules)
Important parameter:
--save OR --save-exact
Usually add TypeScript typings (for auto-complete)
npm install @types/jquery -–save
Understanding package.json
dependencies node
• Lists all 3rd party libraries needed to
run
devDependencies node
• Lists all 3rd party libraries needed to
develop/build
Semantic versioning (semver)
Example Known as Meaning
^1.2.1 Caret dependency Greater than or equal to 1.2.1, but less than 2.0.0
~1.2.1 Tilde dependency Greater than or equal to 1.2.1, but less than 1.3.0
1.2.1 Exact dependency 1.2.1 only
Fundamentals
3 part version number – e.g. 1.0.0
Major.Minor.Patch
Major = breaking change/substantial differences
Minor = non-breaking e.g. new methods
Patch = no interface changes e.g. optimisations,
documentation
Versioning/dependency pitfalls
Using caret
dependencies (the
default)
Not specifying –
save on npm install
Dev:
Not locking
dependencies
down
Shipping:
Will change in
npm 5!
--save
(until npm 5)
Dependencies and shipping
The problem – “dependency float”
• Your app has many JS dependencies (the node_modules tree)
• node_modules should not be checked-in
• Different version somewhere in tree -> Broken app
The solution – npm shrinkwrap
• Generates npm-shrinkwrap.json file
Critical to getting a “100% reproducible build”
• Locks down dependencies – for entire node_modules tree
npm shrinkwrap
Tip - check-in npm-shrinkwrap.json
for each shipped release
• Allows exact build to be recreated
• Allows other devs to build exact app from
source control
Better than save-exact – deals with
full dependency tree
• save-exact only deals with top-level
dependencies
Remember the rule:
= OK
^ = Not OK
Recommendations – versioning etc.
Pitfall How avoided More reading
Avoid dependency issues
in dev
Ensure devs *save* packages properly – use npm
install --save/--save-exact.
Consider custom .npmrc file across team
http://cob-
sp.com/2fOtApJ
Avoid dependency issues
when shipping
Use npm shrinkwrap for each release https://docs.npmjs.
com/cli/shrinkwrap
Code re-use pitfall
Copy/pasting JS code into each app,
because not clear how to re-use properly
Re-using existing JS code
Create a module for your code
• Expose each method with exports statement:
module.exports = {
CheckRealValue: COB.CORE.Utilities.CheckRealValue,
StringIsEmpty: COB.CORE.Utilities.StringIsEmpty
}
Create package.json file
• Specify entry point (file)
Re-using existing JS code
Access module with ‘require’
• var cobUtil = require('cob-utility')
• cobUtil.StringIsEmpty("foo");
So, now you have a module.
How to include/reference that?
Some popular options
Use npm LOCAL packages
• Install from file path (COPY) or use NPM LINK
Use node_modules higher up filesystem
• Take advantage of “recurse upwards” approach of npm- See http://cob-
sp.com/2eXDJOI
Use private package hosting
• npm private packages - $7 pm/user
• VSTO private hosting - $4 pm/user
Also consider:
https://www.visualstudio.co
m/en-
us/docs/package/install
Recommendations – code re-use
Pitfall How More reading
Copy/pasting JS code into
each project
Create modules for existing code
Consider module strategy:
• npm install [filepath]
• npm link (for “parallel dev” of client and utility
code)
• Use of npm private packages etc.
http://nicksellen.co.
uk/2015/04/17/ho
w-to-manage-
private-npm-
modules.html
http://stackoverflo
w.com/questions/2
1233108/cross-
project-references-
between-two-
projects
SPFX coding pitfalls
Dealing with async
code/ promises
Calling the
Microsoft Graph
(permutations)
Calling secure APIs
(AAD)Office UI Fabric
Adding a library
TypeScript issues
Pitfall – Office UI Fabric issues
Problem:
You want to use Fabric but are confused..
Office UI Fabric
• Office UI Fabric Core a.k.a. Fabric Core - this is a set of
core styles, typography, a responsive grid, animations,
icons, and other fundamental building blocks of the
overall design language.
• Office UI Fabric React a.k.a. Fabric React - this package
contains a set of React components built on top of the
Fabric design language.
Pitfall – Office UI Fabric issues
Problem:
You want to use Fabric but are confused..
Solution:
• To use Fabric Core easily, use SPFx v1.3.4
or later (
• Using React? Can use Fabric React
components – use individual static links
(for bundle size)
Key npm packages:
• office-ui-fabric-
react
• @microsoft/sp-
office-ui-fabric-
core (new)
Correct use of Fabric React (bundling
approach)
WARNING – React styles are bundled with EACH web part in this
approach. Mitigate with SPFx component bundles if you need to (e.g.
expecting many of your web parts on page).
See http://cob-sp.com/2hPVmUc
Pitfall – calling the Graph/custom APIs
Problem:
You need to call the Graph or a custom API
from SPFx (i.e. AAD-secured)
Solution:
• Understand today’s options:
• GraphHttpClient (limited scenarios!)
• AAD app + adal.js
• AAD app + SPO auth cookie/IFrame approach
• Understand a future option:
• AAD app + tell SPFx to trust it
Graph/custom API permutations
- GraphHttpClient
- or more likely, use of adal.js
Calling the Graph from
client-side
- adal.js
- SPO auth cookie/IFrame
Calling custom API (AAD)
from client-side
•- adal.js from client (SPO auth cookie approach gives token
which cannot be used with Graph)
- adal.NET within custom API
OR
- New Azure Functions bindings (preview – can’t get to work!)
- Use of both “on behalf of user” and “app-only”
Calling custom API
(AAD) from client-side
which calls the Graph
Reference:
Connect to API
secured with AAD -
http://cob-
sp.com/SPFx-AAD
Cheat sheet - custom APIs/Azure Functions
with AAD
ADAL.js
• CORS – define rule for each
calling page
• Code - Ensure asking for
token for your resource
(AAD client ID)
SPO auth cookie approach
• Empty CORS rules
• Code:
• Pass “credentials” :
“include” header, and sure
API/Function can receive..
• IFrame onto Function URL
Reference:
Connect to API
secured with AAD -
http://cob-
sp.com/SPFx-AAD
CONSIDER:
• Each web part/extension on
page must sign-in
• AAD reply URL needed for
each page with WP (max 10!)
CONSIDER:
• Sign-in applies to entire
page/session
• Cannot access user
identity (app-only)
Future option – Graph/customAPIs
Graph - Specify additional permission
scopes for GraphHttpClient
e.g. I’m OK with all SPFx web parts having access to
more than Groups and Reports
Your APIs/Azure Functions
Specify additional custom APIs for same token
Benefit – no need for sign-in button in your
WP/extension
Dev preview late 2017?
{
"WebApiPermissionRequest": {
"ResourceId": “GUID goes here",
"Scope": “GUID goes here",
}
"WebApiPermissionRequest": {
"ResourceId": “GUID goes here",
"Scope": “GUID goes here",
}
"WebApiPermissionRequest": {
"ResourceId": “GUID goes here",
"Scope": “GUID goes here",
}
Recommendations – coding
Pitfall How avoided More reading
Office UI Fabric
issues
Get familiar with:
• Fabric Core vs. Fabric React components
• SPFx 1.3.4/sp-office-ui-fabric-core package
• Using mixins in your SCSS
http://cob-sp.com/SPFx-
OUIF
Graph/custom API
issues
Get familiar with:
• Register AAD apps + adal.js
• SPO auth cookie approach
• Future SPFx option
http://cob-sp.com/SPFx-AAD
Async code issues Get familiar with:
• Promises
http://cob-sp.com/SPFX-
Promises
Security issues Avoid SPFX if sensitive data sent to client (page
or JS) - use Add-in parts/IFrames if needed
http://cob-sp.com/2ez9JNX
Pitfalls - deployment
Accidentally
bundling external
libraries/frameworks
Accidentally shipping
a debug build
Losing track of
remote JS code
Bundling considerations
Librariesare includedin your bundle BY DEFAULT
Update config.json if (e.g.) jQuery should be referenced from CDN
One bundleper web part BY DEFAULT - across your site
10 web parts = 10 different copies of jQuery being downloaded
GUID in bundleURL is regeneratedon each build
This is the versioning/cache-busting mechanism
TIP – delete unused JS files from CDN to keep things tidy
Bundling – rule #1
“Externalise” where possible (CDN):
Bundling – rule #2
Ensure any libs you ARE bundling are consolidated (with
SPFx component bundles):
WP1 WP2
cob-bothWebParts.js
Recommendations – deployment
Pitfall How avoided More reading
Accidental
bundling
Ensure libs loaded externally where possible
Update “externals” section of config.json
Waldek - http://cob-
sp.com/2frVMR3
Duplication of code
in bundle
Use SPFx component bundles Elio - http://cob-
sp.com/SPFx-
CompBundle
Losing track of
remote JS code
• Proactively track CDN locations (e.g. Excel?)
• Use SPCAF to help identify
www.spcaf.com
Key take-aways
It’s a new world, with different pitfalls!
Recommendations:
Get familiar with NPM especially
Plan for code re-use (e.g. modules) if appropriate
Practice “production” deployments
Dependencies/versioning e.g. dependency float
Coding e.g. OUIF, calling the Graph or custom APIs
Deployment e.g. accidental bundling, duplication in bundle
Thank you!! 
Any questions?
www.sharepointnutsandbolts.com
Bundling – how it goes wrong
Perhaps a 2nd web part is added..
Some libraries are installed using
npm (e.g. Angular)..
Bundling – how it goes wrong
gulp bundle --ship
gulp deploy-azure-storage
gulp package-solution --ship
SPFx deployment process:
Bundling – how it goes wrong
App package added to App Catalog:
Bundling – done wrong

Más contenido relacionado

La actualidad más candente

TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkBob German
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersNCCOMMS
 
COB ESPC18 - Rich PowerApps with offline support
COB ESPC18 - Rich PowerApps with offline supportCOB ESPC18 - Rich PowerApps with offline support
COB ESPC18 - Rich PowerApps with offline supportChris O'Brien
 
SharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint FrameworkSharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint FrameworkJoAnna Cheshire
 
SharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSean McLellan
 
Modern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio CodeModern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio CodeJared Matfess
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfNCCOMMS
 
Application innovation & Developer Productivity
Application innovation & Developer ProductivityApplication innovation & Developer Productivity
Application innovation & Developer ProductivityKushan Lahiru Perera
 
Azure Web Jobs
Azure Web JobsAzure Web Jobs
Azure Web JobsBizTalk360
 
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...NCCOMMS
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
Activate bots within SharePoint Framework
Activate bots within SharePoint FrameworkActivate bots within SharePoint Framework
Activate bots within SharePoint FrameworkKushan Lahiru Perera
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceRicardo Wilkins
 
SPUnite17 SPFx Extensions
SPUnite17 SPFx ExtensionsSPUnite17 SPFx Extensions
SPUnite17 SPFx ExtensionsNCCOMMS
 
SPUnite17 Introduction to the Office Dev PnP Core Libraries
SPUnite17 Introduction to the Office Dev PnP Core LibrariesSPUnite17 Introduction to the Office Dev PnP Core Libraries
SPUnite17 Introduction to the Office Dev PnP Core LibrariesNCCOMMS
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...NCCOMMS
 
COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018Chris O'Brien
 

La actualidad más candente (20)

TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
 
SPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event HandlersSPUnite17 Timer Jobs Event Handlers
SPUnite17 Timer Jobs Event Handlers
 
COB ESPC18 - Rich PowerApps with offline support
COB ESPC18 - Rich PowerApps with offline supportCOB ESPC18 - Rich PowerApps with offline support
COB ESPC18 - Rich PowerApps with offline support
 
SharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint FrameworkSharePoint Development with the SharePoint Framework
SharePoint Development with the SharePoint Framework
 
ECS19 Bert Jansen - Modernizing your existing sites
ECS19 Bert Jansen - Modernizing your existing sitesECS19 Bert Jansen - Modernizing your existing sites
ECS19 Bert Jansen - Modernizing your existing sites
 
SharePoint Framework - Developer Preview
SharePoint Framework - Developer PreviewSharePoint Framework - Developer Preview
SharePoint Framework - Developer Preview
 
Modern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio CodeModern SharePoint Development using Visual Studio Code
Modern SharePoint Development using Visual Studio Code
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio StruyfO365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
 
Application innovation & Developer Productivity
Application innovation & Developer ProductivityApplication innovation & Developer Productivity
Application innovation & Developer Productivity
 
Azure Web Jobs
Azure Web JobsAzure Web Jobs
Azure Web Jobs
 
[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions[Struyf] Automate Your Tasks With Azure Functions
[Struyf] Automate Your Tasks With Azure Functions
 
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
O365Con18 - Site Templates, Site Life Cycle Management and Modern SharePoint ...
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Activate bots within SharePoint Framework
Activate bots within SharePoint FrameworkActivate bots within SharePoint Framework
Activate bots within SharePoint Framework
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
 
SPUnite17 SPFx Extensions
SPUnite17 SPFx ExtensionsSPUnite17 SPFx Extensions
SPUnite17 SPFx Extensions
 
SPUnite17 Introduction to the Office Dev PnP Core Libraries
SPUnite17 Introduction to the Office Dev PnP Core LibrariesSPUnite17 Introduction to the Office Dev PnP Core Libraries
SPUnite17 Introduction to the Office Dev PnP Core Libraries
 
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
O365Con18 - Implementing Automated UI Testing for SharePoint Solutions - Elio...
 
COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018COB - PowerApps - the good, the bad and the ugly - early 2018
COB - PowerApps - the good, the bad and the ugly - early 2018
 

Similar a Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)

Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersSarah Dutkiewicz
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsDavid Amend
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkRapidValue
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Arun prasath
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukLohika_Odessa_TechTalks
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesRobert Lemke
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack SummitMiguel Zuniga
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPagesUlrich Krause
 
Simplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APISimplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APIVictorSzoltysek
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01Scott Miao
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopVivek Krishnakumar
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudMatt Callanan
 
Getting started with CFEngine - Webinar
Getting started with CFEngine - WebinarGetting started with CFEngine - Webinar
Getting started with CFEngine - WebinarCFEngine
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Serge van den Oever
 
Cluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesCluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesQAware GmbH
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationDenys Vuika
 

Similar a Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx) (20)

Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript Developers
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.jsMulti modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular Framework
 
Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment Docker - Demo on PHP Application deployment
Docker - Demo on PHP Application deployment
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
 
Scaleable PHP Applications in Kubernetes
Scaleable PHP Applications in KubernetesScaleable PHP Applications in Kubernetes
Scaleable PHP Applications in Kubernetes
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
 
Simplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI APISimplified DevOps Bliss -with OpenAI API
Simplified DevOps Bliss -with OpenAI API
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer Workshop
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the Cloud
 
Getting started with CFEngine - Webinar
Getting started with CFEngine - WebinarGetting started with CFEngine - Webinar
Getting started with CFEngine - Webinar
 
Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript Building an Ionic hybrid mobile app with TypeScript
Building an Ionic hybrid mobile app with TypeScript
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
Cluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards KubernetesCluster-as-code. The Many Ways towards Kubernetes
Cluster-as-code. The Many Ways towards Kubernetes
 
Using and extending Alfresco Content Application
Using and extending Alfresco Content ApplicationUsing and extending Alfresco Content Application
Using and extending Alfresco Content Application
 

Más de Chris O'Brien

Chris O'Brien - Building AI into Power Platform solutions
Chris O'Brien - Building AI into Power Platform solutionsChris O'Brien - Building AI into Power Platform solutions
Chris O'Brien - Building AI into Power Platform solutionsChris O'Brien
 
Chris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing workChris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing workChris O'Brien
 
Chris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmapsChris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmapsChris O'Brien
 
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)Chris O'Brien
 
Chris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentChris O'Brien
 
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...Chris O'Brien
 
Deep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrienDeep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrienChris O'Brien
 
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrienCustomizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrienChris O'Brien
 
SP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'BrienSP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'BrienChris O'Brien
 
Getting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'BrienGetting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'BrienChris O'Brien
 
SharePoint Ribbon Deep Dive
SharePoint Ribbon Deep DiveSharePoint Ribbon Deep Dive
SharePoint Ribbon Deep DiveChris O'Brien
 
Automated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 DevelopmentAutomated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 DevelopmentChris O'Brien
 
Optimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet SitesOptimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet SitesChris O'Brien
 
Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2Chris O'Brien
 
Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1Chris O'Brien
 
SharePoint workflow deep-dive
SharePoint workflow deep-dive SharePoint workflow deep-dive
SharePoint workflow deep-dive Chris O'Brien
 
SharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tipsSharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tipsChris O'Brien
 

Más de Chris O'Brien (18)

Chris O'Brien - Building AI into Power Platform solutions
Chris O'Brien - Building AI into Power Platform solutionsChris O'Brien - Building AI into Power Platform solutions
Chris O'Brien - Building AI into Power Platform solutions
 
Chris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing workChris OBrien - Azure DevOps for managing work
Chris OBrien - Azure DevOps for managing work
 
Chris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmapsChris O'Brien - Ignite 2019 announcements and selected roadmaps
Chris O'Brien - Ignite 2019 announcements and selected roadmaps
 
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
Chris O'Brien - Intro to Power BI for Office 365 devs (March 2017)
 
Chris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developersChris O'Brien - Introduction to the SharePoint Framework for developers
Chris O'Brien - Introduction to the SharePoint Framework for developers
 
Do's and don'ts for Office 365 development
Do's and don'ts for Office 365 developmentDo's and don'ts for Office 365 development
Do's and don'ts for Office 365 development
 
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
Chris O'Brien - Customizing the SharePoint/Office 365 UI with JavaScript (ESP...
 
Deep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrienDeep dive into SharePoint 2013 hosted apps - Chris OBrien
Deep dive into SharePoint 2013 hosted apps - Chris OBrien
 
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrienCustomizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
Customizing the SharePoint 2013 user interface with JavaScript - Chris OBrien
 
SP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'BrienSP2013 for Developers - Chris O'Brien
SP2013 for Developers - Chris O'Brien
 
Getting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'BrienGetting to grips with SharePoint 2013 apps - Chris O'Brien
Getting to grips with SharePoint 2013 apps - Chris O'Brien
 
SharePoint Ribbon Deep Dive
SharePoint Ribbon Deep DiveSharePoint Ribbon Deep Dive
SharePoint Ribbon Deep Dive
 
Automated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 DevelopmentAutomated Builds And UI Testing in SharePoint 2010 Development
Automated Builds And UI Testing in SharePoint 2010 Development
 
Optimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet SitesOptimizing SharePoint 2010 Internet Sites
Optimizing SharePoint 2010 Internet Sites
 
Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2Managing the SharePoint 2010 Application Lifecycle - Part 2
Managing the SharePoint 2010 Application Lifecycle - Part 2
 
Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1Managing the SharePoint 2010 Application Lifecycle - Part 1
Managing the SharePoint 2010 Application Lifecycle - Part 1
 
SharePoint workflow deep-dive
SharePoint workflow deep-dive SharePoint workflow deep-dive
SharePoint workflow deep-dive
 
SharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tipsSharePoint Web Content Management - Lessons Learnt/top 5 tips
SharePoint Web Content Management - Lessons Learnt/top 5 tips
 

Último

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 

Último (20)

Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 

Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)

  • 1. Pitfalls when developing with the SharePoint Framework (SPFx) Chris O’Brien (MVP) Independent/Content and Code, UK Add Speaker Photo here
  • 2. Notes on this presentation If you have previously seen this presentation/slide deck before, note the following updates: Content Slides Pitfalls around Office UI Fabric 27-30 Pitfalls around calling the Microsoft Graph or custom APIs secured with Azure Active Directory 31-35 Use of SPFx component bundles 40-42
  • 3.
  • 4. Fundamentals – how it all works Packages installed/updated using npm • .NET analogy = NuGet Dependent JS libraries stored in node_modules • .NET analogy = the BIN directory • Gets bundled/deployed with your app Package.json records your top-level dependencies • .NET analogy = packages.config • Allows other devs to build app from source control • N.B. Each dependency may have IT’S OWN dependencies and package.json
  • 5. COB App - node_modules - jQuery - node_modules - cache-swap - node_modules - React - node_modules …… Simplified node_modules hierarchy
  • 6. Fundamentals - how to add a library Use npm install command e.g: npm install jquery Installs library to your app (in node_modules) Important parameter: --save OR --save-exact Usually add TypeScript typings (for auto-complete) npm install @types/jquery -–save
  • 7. Understanding package.json dependencies node • Lists all 3rd party libraries needed to run devDependencies node • Lists all 3rd party libraries needed to develop/build
  • 8. Semantic versioning (semver) Example Known as Meaning ^1.2.1 Caret dependency Greater than or equal to 1.2.1, but less than 2.0.0 ~1.2.1 Tilde dependency Greater than or equal to 1.2.1, but less than 1.3.0 1.2.1 Exact dependency 1.2.1 only Fundamentals 3 part version number – e.g. 1.0.0 Major.Minor.Patch Major = breaking change/substantial differences Minor = non-breaking e.g. new methods Patch = no interface changes e.g. optimisations, documentation
  • 9. Versioning/dependency pitfalls Using caret dependencies (the default) Not specifying – save on npm install Dev: Not locking dependencies down Shipping: Will change in npm 5!
  • 11. Dependencies and shipping The problem – “dependency float” • Your app has many JS dependencies (the node_modules tree) • node_modules should not be checked-in • Different version somewhere in tree -> Broken app The solution – npm shrinkwrap • Generates npm-shrinkwrap.json file Critical to getting a “100% reproducible build” • Locks down dependencies – for entire node_modules tree
  • 12. npm shrinkwrap Tip - check-in npm-shrinkwrap.json for each shipped release • Allows exact build to be recreated • Allows other devs to build exact app from source control Better than save-exact – deals with full dependency tree • save-exact only deals with top-level dependencies
  • 13.
  • 14. Remember the rule: = OK ^ = Not OK
  • 15. Recommendations – versioning etc. Pitfall How avoided More reading Avoid dependency issues in dev Ensure devs *save* packages properly – use npm install --save/--save-exact. Consider custom .npmrc file across team http://cob- sp.com/2fOtApJ Avoid dependency issues when shipping Use npm shrinkwrap for each release https://docs.npmjs. com/cli/shrinkwrap
  • 16.
  • 17. Code re-use pitfall Copy/pasting JS code into each app, because not clear how to re-use properly
  • 18. Re-using existing JS code Create a module for your code • Expose each method with exports statement: module.exports = { CheckRealValue: COB.CORE.Utilities.CheckRealValue, StringIsEmpty: COB.CORE.Utilities.StringIsEmpty } Create package.json file • Specify entry point (file)
  • 19. Re-using existing JS code Access module with ‘require’ • var cobUtil = require('cob-utility') • cobUtil.StringIsEmpty("foo");
  • 20.
  • 21. So, now you have a module. How to include/reference that?
  • 22. Some popular options Use npm LOCAL packages • Install from file path (COPY) or use NPM LINK Use node_modules higher up filesystem • Take advantage of “recurse upwards” approach of npm- See http://cob- sp.com/2eXDJOI Use private package hosting • npm private packages - $7 pm/user • VSTO private hosting - $4 pm/user Also consider: https://www.visualstudio.co m/en- us/docs/package/install
  • 23. Recommendations – code re-use Pitfall How More reading Copy/pasting JS code into each project Create modules for existing code Consider module strategy: • npm install [filepath] • npm link (for “parallel dev” of client and utility code) • Use of npm private packages etc. http://nicksellen.co. uk/2015/04/17/ho w-to-manage- private-npm- modules.html http://stackoverflo w.com/questions/2 1233108/cross- project-references- between-two- projects
  • 24.
  • 25. SPFX coding pitfalls Dealing with async code/ promises Calling the Microsoft Graph (permutations) Calling secure APIs (AAD)Office UI Fabric Adding a library TypeScript issues
  • 26. Pitfall – Office UI Fabric issues Problem: You want to use Fabric but are confused..
  • 27. Office UI Fabric • Office UI Fabric Core a.k.a. Fabric Core - this is a set of core styles, typography, a responsive grid, animations, icons, and other fundamental building blocks of the overall design language. • Office UI Fabric React a.k.a. Fabric React - this package contains a set of React components built on top of the Fabric design language.
  • 28. Pitfall – Office UI Fabric issues Problem: You want to use Fabric but are confused.. Solution: • To use Fabric Core easily, use SPFx v1.3.4 or later ( • Using React? Can use Fabric React components – use individual static links (for bundle size) Key npm packages: • office-ui-fabric- react • @microsoft/sp- office-ui-fabric- core (new)
  • 29. Correct use of Fabric React (bundling approach) WARNING – React styles are bundled with EACH web part in this approach. Mitigate with SPFx component bundles if you need to (e.g. expecting many of your web parts on page). See http://cob-sp.com/2hPVmUc
  • 30. Pitfall – calling the Graph/custom APIs Problem: You need to call the Graph or a custom API from SPFx (i.e. AAD-secured) Solution: • Understand today’s options: • GraphHttpClient (limited scenarios!) • AAD app + adal.js • AAD app + SPO auth cookie/IFrame approach • Understand a future option: • AAD app + tell SPFx to trust it
  • 31. Graph/custom API permutations - GraphHttpClient - or more likely, use of adal.js Calling the Graph from client-side - adal.js - SPO auth cookie/IFrame Calling custom API (AAD) from client-side •- adal.js from client (SPO auth cookie approach gives token which cannot be used with Graph) - adal.NET within custom API OR - New Azure Functions bindings (preview – can’t get to work!) - Use of both “on behalf of user” and “app-only” Calling custom API (AAD) from client-side which calls the Graph Reference: Connect to API secured with AAD - http://cob- sp.com/SPFx-AAD
  • 32. Cheat sheet - custom APIs/Azure Functions with AAD ADAL.js • CORS – define rule for each calling page • Code - Ensure asking for token for your resource (AAD client ID) SPO auth cookie approach • Empty CORS rules • Code: • Pass “credentials” : “include” header, and sure API/Function can receive.. • IFrame onto Function URL Reference: Connect to API secured with AAD - http://cob- sp.com/SPFx-AAD CONSIDER: • Each web part/extension on page must sign-in • AAD reply URL needed for each page with WP (max 10!) CONSIDER: • Sign-in applies to entire page/session • Cannot access user identity (app-only)
  • 33. Future option – Graph/customAPIs Graph - Specify additional permission scopes for GraphHttpClient e.g. I’m OK with all SPFx web parts having access to more than Groups and Reports Your APIs/Azure Functions Specify additional custom APIs for same token Benefit – no need for sign-in button in your WP/extension Dev preview late 2017? { "WebApiPermissionRequest": { "ResourceId": “GUID goes here", "Scope": “GUID goes here", } "WebApiPermissionRequest": { "ResourceId": “GUID goes here", "Scope": “GUID goes here", } "WebApiPermissionRequest": { "ResourceId": “GUID goes here", "Scope": “GUID goes here", }
  • 34. Recommendations – coding Pitfall How avoided More reading Office UI Fabric issues Get familiar with: • Fabric Core vs. Fabric React components • SPFx 1.3.4/sp-office-ui-fabric-core package • Using mixins in your SCSS http://cob-sp.com/SPFx- OUIF Graph/custom API issues Get familiar with: • Register AAD apps + adal.js • SPO auth cookie approach • Future SPFx option http://cob-sp.com/SPFx-AAD Async code issues Get familiar with: • Promises http://cob-sp.com/SPFX- Promises Security issues Avoid SPFX if sensitive data sent to client (page or JS) - use Add-in parts/IFrames if needed http://cob-sp.com/2ez9JNX
  • 35.
  • 36. Pitfalls - deployment Accidentally bundling external libraries/frameworks Accidentally shipping a debug build Losing track of remote JS code
  • 37. Bundling considerations Librariesare includedin your bundle BY DEFAULT Update config.json if (e.g.) jQuery should be referenced from CDN One bundleper web part BY DEFAULT - across your site 10 web parts = 10 different copies of jQuery being downloaded GUID in bundleURL is regeneratedon each build This is the versioning/cache-busting mechanism TIP – delete unused JS files from CDN to keep things tidy
  • 38.
  • 39. Bundling – rule #1 “Externalise” where possible (CDN):
  • 40. Bundling – rule #2 Ensure any libs you ARE bundling are consolidated (with SPFx component bundles): WP1 WP2 cob-bothWebParts.js
  • 41. Recommendations – deployment Pitfall How avoided More reading Accidental bundling Ensure libs loaded externally where possible Update “externals” section of config.json Waldek - http://cob- sp.com/2frVMR3 Duplication of code in bundle Use SPFx component bundles Elio - http://cob- sp.com/SPFx- CompBundle Losing track of remote JS code • Proactively track CDN locations (e.g. Excel?) • Use SPCAF to help identify www.spcaf.com
  • 42. Key take-aways It’s a new world, with different pitfalls! Recommendations: Get familiar with NPM especially Plan for code re-use (e.g. modules) if appropriate Practice “production” deployments Dependencies/versioning e.g. dependency float Coding e.g. OUIF, calling the Graph or custom APIs Deployment e.g. accidental bundling, duplication in bundle
  • 43. Thank you!!  Any questions? www.sharepointnutsandbolts.com
  • 44. Bundling – how it goes wrong Perhaps a 2nd web part is added.. Some libraries are installed using npm (e.g. Angular)..
  • 45. Bundling – how it goes wrong gulp bundle --ship gulp deploy-azure-storage gulp package-solution --ship SPFx deployment process:
  • 46. Bundling – how it goes wrong App package added to App Catalog: