You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
Could you please suggest me with a solution, how to reference sp-pnp-js in typescript project without actual importing the library?
I have sp-pnp-js applied globally in a bundle script within custom action ScriptLink or masterpage, no matter, so it's already on the pages.
There are multiple solutions which use the library, some of them are written in TypeScript and packed with Webpack.
For convenient coding, sp-pnp-js is imported like this:
import{Web}from'sp-pnp-js';
But, as a result, sp-pnp-js "binaries" are placed to output .js and .map files.
I ended up with a temporary solution of impoting the lib druring development:
importpnpfrom'sp-pnp-js';declarelet$pnp=pnp;
and switching to declaring $pnp variable with any data type and without importing the lib before packing before delivering to the site there $pnp is deployed globally.
declarelet $pnp: any;
I wondering, can it be done in more elegant way with referencing (/// <reference path="./../node_modules/sp-pnp-js/dist/pnp.d.ts" />) only approach?
Thanks!
The text was updated successfully, but these errors were encountered:
This is really a duplicate of #330 and isn't a use case I thought would be very high. I anticipated most folks would want to use the library as an import and then mark it external for builds. But now it has come up twice in a week. There was a limitation in TS that was blocking this but I can't remember what that was now. I will have to go back and find that and see where things stand. Going to close this one as a duplicate - but you can follow #330 for updates.
No worries at all. But since two people brought it up figured worth investigating. If you get a chance try the proposed solution in the other thread #330.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi there,
Category
[ ] Enhancement
[ ] Bug
[x] Question
Question
Could you please suggest me with a solution, how to reference
sp-pnp-js
in typescript project without actual importing the library?I have
sp-pnp-js
applied globally in a bundle script within custom action ScriptLink or masterpage, no matter, so it's already on the pages.There are multiple solutions which use the library, some of them are written in TypeScript and packed with Webpack.
For convenient coding,
sp-pnp-js
is imported like this:But, as a result,
sp-pnp-js
"binaries" are placed to output .js and .map files.Adding references like:
seems like doesn't provide anything to use
$pnp
.I ended up with a temporary solution of impoting the lib druring development:
and switching to declaring $pnp variable with any data type and without importing the lib before packing before delivering to the site there
$pnp
is deployed globally.I wondering, can it be done in more elegant way with referencing (
/// <reference path="./../node_modules/sp-pnp-js/dist/pnp.d.ts" />
) only approach?Thanks!
The text was updated successfully, but these errors were encountered: