-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arcgis-rest-fetch / arcgis-rest-form-data is missing "main" in package.json #993
Comments
I'm currently trying to migrate from v3 to v4 and getting the following errors when running our Jest (ts-jest) test suite:
Could this be related? We are using arcgis-rest-js in node.js. |
@sandromartis I was running into the same issue during a migration. Adding this to the Jest configuration fixed the issue: "moduleNameMapper": {
"@esri/arcgis-rest-(fetch|form-data)": "<rootDir>/node_modules/@esri/arcgis-rest-$1/browser-ponyfill.js"
} You might have to change the file to |
@ReneU Thanks Rene, that helped, I'm one step further :) |
Not sure I fully understand what's going but bumping Jest and Typescript also solved the issue for me. |
There are 3 separate issues here.
I'll address each of these separately.
The lack of a I thought I also removed the This does have the potential to break some things if people were using older versions of bundlers that either didn't support conditional exports or were looking at
Jest only added support for conditional exports in
Specifically once you are running Jest 28+, jest will properly load The solution to the first 2 issues to to add The only way to solve the final issue with the segmentation fault would be to not use dynamic imports in Common JS modules. This would require either:
The only other things to do would be:
Right now we only have confirmed that this impacts people using Jest it might impact people using Babel (based on the issue in nodejs/node#35889). So the question is this: Is it worth it to split |
Oof. I'm not sure I'm qualified to read this let alone have an opinion on how to move forward. If splitting the package solves the issue then that seems reasonable. |
I think we should do this. Re: final issue, I'm wondering about:
Do they need to switch their apps or just their test files? Looking at Jest's ESM support it still looks pretty experimental. Still, I'd say we should consider doing nothing for now and seeing how many people are affected by this, b/c the other options, going back to node-fetch@2 either entirely or in a parallel (split) package sounds pretty bad. |
Thanks for pointing that out. Actually to problem for the vercel pkg issue seems to be dependent on external dependencies which have been migrated to ESM as described above:
Having dependencies on various major release versions seems like unnecessary complexity to me. How many people are using pkg anyways? Seems like I'm going back to fiddling with plain old rest requests silently hoping the pkg guys are adding ESM support :( |
When building packages with pkg it is assumed, that property "main" is defined in package.json (which it is in arcgis-rest-portal / arcgis-rest-request / arcigs-rest-auth: eg.:
"main": "dist/cjs/index.js"
)Probably the structure of arcgis-rest-fetch / arcgis-rest-form-data differs and maybe no cjs version exists, which is why no "main" property is defined.
But if a cjs version existed it would be awesome if it was specified in "main"...
The text was updated successfully, but these errors were encountered: