GithubHelp home page GithubHelp logo

Comments (11)

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

This syntax works for me:

/// <reference path="pnp.d.ts" />
import PnP = require("pnp");

The first line gives the ref to the typings file and the second is the actual "import" into your code. Please confirm and we can close the issue.

from pnp-js-core.

alex-randall avatar alex-randall commented on June 11, 2024

Thanks Patrick, will try and report back.

from pnp-js-core.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

So it looks to me that we would have to produce a set of es6 *.js files in the lib package and then have a separate build path for the pnp.js file that produces UMD. I guess I'll take a look at this one, which puts samples on the back burner unfortunately.

from pnp-js-core.

alex-randall avatar alex-randall commented on June 11, 2024

Cool thanks @patrick-rodgers. Sounds like that might handle the es6 side of things. We'll see how it goes.

Maybe related questions:

  1. I could be wrong and old school, but doesn't the import PnP = require("pnp"); syntax requires a (typing and runtime) dependency on requirejs? I thought we didn't have any dependencies (at runtime) other than things that SharePoint itself provides on a SharePoint page?

  2. Also shouldn't the naming of the alias in something like: import {$pnp} = from 'whateverwenameit';
    be $pnp so it can be used in all TypeScript documentation/samples since that's what is the global name ends up being in JavaScript? Reason being: it make samples and documentation much easier to write for both TypeScript and JavaScript because the same $pnp entity can be referenced from whatever way you are including it. Otherwise, the JavaScript and TypeScript samples and documentation will deviate radically with different "root variables" (PnP, $pnp). Thoughts?

from pnp-js-core.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024
  1. Updated in #75, now supports:

import pnp from "sp-pnp-js";

Please validated with latest npm package 0.0.10.

  1. You can name it whatever you want when you import.

from pnp-js-core.

mike-morr avatar mike-morr commented on June 11, 2024

@patrick-rodgers New package is not working in jspm (and I suspect npm as well since jspm is simply downloading the npm package).

Here is the top of pnp.js that was downloaded from the 0.10 (confirmed in package.json) npm package.

It doesn't look like it got transpiled to ES5

/* */ 
"format cjs";
"use strict";
import * as Util from "./utils/Util";
import { SharePoint } from "./SharePoint/SharePoint";
import { PnPClientStorage } from "./utils/Storage";
import * as Configuration from "./configuration/configuration";
import { Logger } from "./utils/logging";
import { Rest } from "./SharePoint/Rest/rest";

from pnp-js-core.

mike-morr avatar mike-morr commented on June 11, 2024

Forgot to mention, Intellisense was working out of the box this time though.

from pnp-js-core.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

The code in /lib is es6 to support the es6 syntax. The code in the dist folder is es5 in a umd module and should be used in the browser.

from pnp-js-core.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

package updated to maintain the default export we desire for umd modules in the browser in #80. @alex-randall please test, would like to get this one closed.

from pnp-js-core.

pr0peller avatar pr0peller commented on June 11, 2024

Hi,
I just want to say that I test the library in ASP.Net application:

///<reference path="../node_modules/sp-pnp-js/dist/pnp.d.ts"/>
import * as Pnp from "pnp";
works,

///<reference path="../node_modules/sp-pnp-js/dist/pnp.d.ts"/>
import Pnp = require("pnp");
works also.
I have tested it also in Nodejs typescript application and it works the same way.
Dev env: Visual Studio 2015 Enterprise Update 2
Would be great if somebody else confirm the results.

from pnp-js-core.

patrick-rodgers avatar patrick-rodgers commented on June 11, 2024

This appears to be fixed, thanks all.

from pnp-js-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.