Closed maxschulmeister closed 5 months ago
I'm simply trying to import "pdf-lib" for usage in a figma plugin.
import { PDFDocument } from "pdf-lib";
ts outputs Could not resolve "pdf-lib"
a clean import
tsconfig.json
{ "compilerOptions": { "esModuleInterop": true, "isolatedModules": true, "jsx": "react", "jsxFactory": "h", "lib": ["DOM", "ES2020"], "module": "ES2020", "moduleResolution": "Node", "strict": true, "typeRoots": ["node_modules/@figma", "node_modules/@types"], "paths": { "@/*": ["./src/*"] }, "target": "es2017" }, "include": ["src/**/*.ts", "src/**/*.tsx"] }
latest
Browser
No response
this was an issue related to esbuild and its "platform" parameter.
setting mainFields for esbuild buildOptions to mainFields: ["module", "main", "browser"],
mainFields: ["module", "main", "browser"],
fixed the issue.
save to close this.
What were you trying to do?
I'm simply trying to import "pdf-lib" for usage in a figma plugin.
How did you attempt to do it?
import { PDFDocument } from "pdf-lib";
What actually happened?
ts outputs Could not resolve "pdf-lib"
What did you expect to happen?
a clean import
How can we reproduce the issue?
tsconfig.json
Version
latest
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
No response