Move provisioning to own package, split types and move Util to a class #78
Conversation
Oh and a note, it's not actually 2 modules right now - I think everything is in both. It's still a WIP :) Edit: Or did I fix that? Not sure. I'l update when I get back. |
This breaks one of the core goals of the project, being the ability to include pnp and begin using it directly. The entire library is the "core" so we want to be able to require(), function(pnp) { pnp.* }. For changes this big we really need some discussion in the future as you've obviously put in a lot of effort but I don't want to merge it because I feel it breaks one of the core use cases. |
I don't necessarily think that including lot's of code that someone might not want to use (i.e provisioning) every time should be a goal of the project. What I'm after (in the long run) is being able to select just the parts of the library that I need for the specific application that I'm building. From my understanding it's only the way we expose the library that's the issue here? I guess we could expose an already newed Core() and that problem would go away. The PR mainly splits core and provisioning into separate folders and built files. It seems like It's worth discussing a change like this now though rather than later seeing as when it launches there will be no way to change anything without breaking backwards compability. In my head not exposing a constructor is a bad thing. I would like to see for instance Edit: And effort really shouldn't be a factor here, it just took less time to actually write the code then an issue detailing everything. |
@patrick-rodgers I thought that entire provisioning module broke that core goal because it relies on JSOM. Doesn't that make it only run inside the context of SharePoint? So SharePoint add-ins only. @pbjorklund I started looking at how hard it would be to refactor that code out too. Seems like every packaging experiment I have tried always fails to build in that code. ObjectHandlerBase and schema I am looking directly at you whatever you are. Maybe we could introduce that functionality back in on top of the REST API later? Assuming the JSOM code is covered by the REST API of course. I am still not clear on what that code does. |
@pbjorklund Here is my understanding of es6 modules.
|
@mike-morrison thanks, but I was more talking about why in the browser when we use requirejs to load the referenced file it comes out as |
The real issue is this:
That is from the TypeScript docs. In changing the source code to support the es6 include syntax when you add the npm package it breaks the functionality we had to include and use the pnp object directly (which is key to usability in my opinion). I am working on what options we might have here but it looks like we can't support both es6 syntax and export = at the same time. |
From later on that same page:
I am pretty sure, we just need to write ES6 modules and let the compiler generate the packages we want to support. That "export =" syntax looks old. I haven't seen anyone using that syntax in a long time. I think the documentation was written to say if the code you are consuming is old and looks like that, you have to import it a different way. I remember having to write syntax like that in the TS earlier days. I'll see if I can get some clarification from the TS team. |
You're missing the issue. Yes we can use the compiler to build the different module types. The problem is that we want to support the ability in JavaScript to require/include in a script tag the code and be able to go pnp.sp.* etc. That is what the export = X syntax supports, the replacement of the exports with the object itself. I am working on just replacing the script during package to work how we want in the browser while still supporting the es6 syntax when using the npm module. |
acb3333
to
99efb57
Compare
I guess the whole Reverted those changes in this PR and moved over to the .replace() solution already in dev. Can open a new issue to discuss the best way to expose the I rebased this on split-types before, can extract that into a separate PR if needed. We dont' need 2 that touch the same things. |
Edit: See comments below.
I was playing around with why PnP was loading as pnp.default and ended up trying out using a pnp.Core namespace and moving provisioning to pnp.Provisioning with separate dist files.
Now this is a major change, but it was easier to just do it then write a long issue for it.
Check it out and let me know what you think, I'm not even 100% sold myself.
Changed the served index.html to do this