Skip to content

Commit f062d46

Browse files
authored
Merge pull request #374 from marp-team/bundle-pdf-lib
Bundle a minified pdf-lib module to Marp CLI
2 parents 00dcd24 + 65ef618 commit f062d46

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- A regression of PDF conversion in the standalone binary version ([#373](https://github.com/marp-team/marp-cli/issues/373), [#374](https://github.com/marp-team/marp-cli/pull/374))
8+
59
## v1.3.0 - 2021-08-11
610

711
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"nanoid": "^3.1.23",
103103
"npm-run-all": "^4.1.5",
104104
"os-locale": "^6.0.0",
105+
"pdf-lib": "^1.16.0",
105106
"pkg": "^5.3.1",
106107
"pkg-up": "^3.1.0",
107108
"portfinder": "^1.0.28",
@@ -141,7 +142,6 @@
141142
"cosmiconfig": "^7.0.0",
142143
"express": "^4.17.1",
143144
"import-from": "^4.0.0",
144-
"pdf-lib": "^1.16.0",
145145
"pptxgenjs": "^3.7.1",
146146
"puppeteer-core": "10.2.0",
147147
"serve-index": "^1.9.1",

src/converter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ export class Converter {
261261

262262
// Apply PDF metadata and annotations
263263
const creationDate = new Date()
264-
const { PDFDocument, PDFHexString, PDFString } = await import('pdf-lib')
264+
const { PDFDocument, PDFHexString, PDFString } = await import(
265+
// Use pre-bundled pdf-lib to avoid circular dependency warning. pdf-lib
266+
// as an external dependency will make failure in the standalone binary.
267+
// @see https://github.com/marp-team/marp-cli/issues/373
268+
'pdf-lib/dist/pdf-lib.min.js'
269+
)
265270
const pdfDoc = await PDFDocument.load(ret.buffer)
266271

267272
pdfDoc.setCreator(CREATED_BY_MARP)

src/typings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ declare module '*.scss' {
1414
const scss: string
1515
export default scss
1616
}
17+
18+
declare module 'pdf-lib/dist/pdf-lib.min.js' {
19+
export * from 'pdf-lib'
20+
}

0 commit comments

Comments
 (0)