inokawa / remark-pdf

remark plugin to compile markdown to pdf.

Home Page:https://inokawa.github.io/remark-pdf/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

export types may be wrong from remark-pdf/node

sr-skillmore opened this issue · comments

Describe the bug
Export types don't seem to be working correctly from remark-pdf/node when importing import pdf from "remark-pdf/node"; in a .ts file in a Vue 3 + Nuxt 3 application.

My remark-pdf version is 0.0.12.

Screenshot 2023-07-05 at 11 07 41 AM

My node_modules folder structure for the package remark-pdf is as below: (this is from my actual project node_modules folder and not from stackblitz recreation which does not show the node_modules folder at all)

Screenshot 2023-07-05 at 10 52 11 AM

When I add the lib to the import path, import pdf from "remark-pdf/lib/node"; the typescript error goes away. However, the terminal gives this warning:

WARN  "remark-pdf/lib/node" is imported by "server/api/md-to-pdf.post.ts", but could not be resolved – treating it as an external dependency.

So, assuming that I cannot use the lib in the import path, I am doing as below to ignore the typescript error.

// @ts-ignore: export types are wrong from remark-pdf/node
import pdf from "remark-pdf/node";

To Reproduce
Please see the stackblitz recreation here.

Expected behavior
The typescript error needs to be corrected when using the import import pdf from "remark-pdf/node";

Cannot find module 'remark-pdf/node' or its corresponding type declarations.

There may be some inconsistencies with the way exports are set up for this package and this needs to be updated.

Additional context
Add any other context about the problem here.

Noticed this in the network response:

{
    "url": "/api/markdown-to-pdf",
    "statusCode": 500,
    "statusMessage": "",
    "message": "Cannot find module '/app/.output/server/node_modules/remark-pdf/lib/node.js' imported from /app/.output/server/chunks/markdown-to-pdf.post.mjs",
    "stack": ""
}

When looking into /app/.output/server/node_modules/remark-pdf/lib/node.js there is no node.js file.

Screenshot 2023-07-31 at 3 02 36 PM