Bundling and "externals"
My current project uses jQuery and sp-pnp-js, and I have moved these to a document library in a "cdn" site collection in my tenant (it's not a *real* CDN, I just call it that -- it really is just a document library). This has worked pretty well so far:
...snip... "externals": { "jquery": "https://tenant.sharepoint.com/sites/CDN/Libraries/jQuery/v3.2.1/jquery.min.js", "sp-pnp-js": "https://tenant.sharepoint.com/sites/CDN/Libraries/pnp/v2.0.5/pnp.min.js" }, ...snip...
My question is related to something I see in a lot of blog posts on the topic - many times I see examples (hello, Waldek Mastykarz) where the following is also in the externals section of config.json, like so:
"externals": { "@microsoft/sp-client-base": "node_modules/@microsoft/sp-client-base/dist/sp-client-base.js", "@microsoft/sp-client-preview": "node_modules/@microsoft/sp-client-preview/dist/sp-client-preview.js", "@microsoft/sp-lodash-subset": "node_modules/@microsoft/sp-lodash-subset/dist/sp-lodash-subset.js", "office-ui-fabric-react": "node_modules/office-ui-fabric-react/dist/office-ui-fabric-react.js", "react": "node_modules/react/dist/react.min.js", "react-dom": "node_modules/react-dom/dist/react-dom.min.js", "react-dom/server": "node_modules/react-dom/dist/react-dom-server.min.js" },
Should I be doing this as well? Also, this doesn't really make sense to me; if these files are in a sub-folder of the project itself, how are they "external"? I'd love to know what's actually going on here and whether it is something I need to be aware of for my own solutions. Thanks.
You don't need to do this. What you're looking at is a project created an older version of the SharePoint Framework, where more packages have been listed as external. In the latest version it's not required anymore which is why you're not seeing them anymore.