Brief bug description
When using this package in an Astro project, Astro throws this error
error Failed to resolve entry for package "@kontent-ai/delivery-node-parser". The package may have incorrect main/module/exports specified in its package.json.
It looks like
"module": "./dist/esm5/index.js",
"es2015": "./dist/esm/index.js",
in the package.json
should read
"module": "./dist/es6/index.js",
"es2015": "./dist/es6/index.js",
as there is no esm5 or esm folder in the package /dist
folder, only 'cjs, es6, es2020, esnext'.
Repro steps
There's quite a few steps to reproduce in our demo repo but I believe if you try and add this package to any Vite project, it should throw the same error (as Astro uses Vite under the hood).
If you need more details @Enngage I'm more than happy to record a quick demo video or jump on a Zoom call / Hangout.
Expected behavior
The module references in package.json
point to the correct output folder.
Additional context
In our demo Astro project we resolve rich text info from the Delivery API into an object, so that we can create a custom resolver component for outputting the HTML we need.
import { nodeParser } from "@kontent-ai/delivery-node-parser";
import { createRichTextObjectResolver, Elements, linkedItemsHelper } from "@kontent-ai/delivery-sdk";
export default async function resolveRichText(richTextElement: Elements.RichTextElement) {
const resolvedObject = createRichTextObjectResolver(nodeParser).resolveRichText({
element: richTextElement,
linkedItems: linkedItemsHelper.convertLinkedItemsToArray(richTextElement.linkedItems),
});
return resolvedObject;
}
but while our editor doesn't throw an error (it resolves the dist/cjs
files), the Vite dev server Astro runs under the hood throws an error
![Screen Shot 2023-01-11 at 15 27 14](https://user-images.githubusercontent.com/69491963/211724772-2d7988e0-cbda-4d97-9b6e-9dbcb08a639c.png)
Going into node_modules/@kontent-ai/delivery-node-parser/package.json
and changing module
and es2015
to the following resolves the issues
"module": "./dist/es6/index.js",
"es2015": "./dist/es6/index.js",