Comments (9)
Thanks for that background. Unfortunately, this is an external issue to this library and a limitation of that tooling. It reads that there is a workaround, not sure if it is viable in your case.
from pnpjs.
Did you try using an async import? At this point the library should be fully compatible with node, even when running in commonjs - but you need to follow the node import resolution rules, which we can't control. Our packages export esm modules and have type set to "module".
from pnpjs.
As @patrick-rodgers is saying you have to get your package.json/tsconfig.jsonn set up properly based on weather you're going to go commonjs or es modules... if you're doing commonjs modules then you're going to probably have to go to async imports... which work but you lose IntelliSense. I have elected to go with es modules and therefore in my projects my package.json file has
...
"type": "module",
...
And my tsconfig.json looks like this:
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": false,
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"typeRoots": [
"./node_modules/@types"
],
}
}
In my experience getting the balance just right is a lot of testing and figuring out what all these switches mean and how the apply to the project you're working on. We'll have a more robust sample of an Azure Function v4 switched up to use esm and pnpjs v4 in the upcoming documentation release.
from pnpjs.
We're really looking forward to the Azure Function v4 and pnpjs v 4 release. We dont want to rely on node 16 and pnpjs v 2 for new projects, and node 18+ with pnpjs 3 in Azure Functions is a real pain.
from pnpjs.
@ElinKolloen - There isn't really much that's going to change for v4 with regard to this, it's more about knowing how to set up your project and how to change the Azure Function configurations to work with ES Modules... so you just have to know how to tweak your package.json and tsconfig correctly, which I shared above.
Same configuration works for
- Azure Functions v3 + PnPjs v3
- Azure Functions v4 + PnPjs v3
- Azure Functions v3 + PnPjs v4
- Azure Functions v4 + PnPjs v4
from pnpjs.
Thanks @juliemturner and @patrick-rodgers for your answers. I gave it a try. Unfortunately because of the build environment my Node project is using it didn't work for me. Our project use Nx build tools, which does not support ESM only modules per our platform team. Thanks anyways for your support.
from pnpjs.
@vishalshitole - while I am not familiar with Nx build tools or "NestJS", but I can find nothing that says Nx tools don't work with es modules. Can you point to the article describing the limitation? Es modules are not something we made up and are widely supported, if your build tools can't support their use I am unclear how you are using many of the packages available on npm.
from pnpjs.
@patrick-rodgers I also have a very little understanding of the Nx. My platform team shared the below link saying -
Nx executors does not support esm and they actually have an open issue on that...
Please let me know if that makes sense, or I will ask my platform team member to jump in here. Thanks.
from pnpjs.
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
from pnpjs.
Related Issues (20)
- Parsing verbose JSON HOT 3
- Adding Excel workbook support HOT 3
- TypeError: Failed to fetch at c when trying to attach files in SPFx HOT 6
- @pnp/graph - spfx msal v3 single sign on redirect HOT 5
- copyByPath can return an unuseable object HOT 6
- Async Iterator Pattern Type Error HOT 3
- Getfilebyserverrelativeurl return corrupted file for .docx file HOT 3
- Batching multiple lists fail HOT 4
- Custom Http request to pull RateLimit-Reset header HOT 3
- Why use the .js extension in imports? HOT 3
- Email Notification delays while send email using @pnp/sp/utilities HOT 9
- Get Version History of a List Item in one request. HOT 3
- v4 - How do I get paged items using async iterator and break only when ALL items are retrieved? HOT 3
- sendEmail from property not working HOT 3
- Update Content Type from List endpoint and not web HOT 2
- Next on cached pagination request HOT 3
- Uploading data into an Excel Spreadsheet. HOT 8
- Add/Update methods no longer returning data as of V4 HOT 3
- How can I get a list of all folders in a document library? HOT 3
- Cannot read property 'Content-Type' of undefined HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnpjs.