Skip to content

Commit

Permalink
Merge pull request #374 from marp-team/bundle-pdf-lib
Browse files Browse the repository at this point in the history
Bundle a minified pdf-lib module to Marp CLI
  • Loading branch information
yhatt committed Aug 12, 2021
2 parents 00dcd24 + 65ef618 commit f062d46
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- 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))

## v1.3.0 - 2021-08-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"nanoid": "^3.1.23",
"npm-run-all": "^4.1.5",
"os-locale": "^6.0.0",
"pdf-lib": "^1.16.0",
"pkg": "^5.3.1",
"pkg-up": "^3.1.0",
"portfinder": "^1.0.28",
Expand Down Expand Up @@ -141,7 +142,6 @@
"cosmiconfig": "^7.0.0",
"express": "^4.17.1",
"import-from": "^4.0.0",
"pdf-lib": "^1.16.0",
"pptxgenjs": "^3.7.1",
"puppeteer-core": "10.2.0",
"serve-index": "^1.9.1",
Expand Down
7 changes: 6 additions & 1 deletion src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ export class Converter {

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

pdfDoc.setCreator(CREATED_BY_MARP)
Expand Down
4 changes: 4 additions & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ declare module '*.scss' {
const scss: string
export default scss
}

declare module 'pdf-lib/dist/pdf-lib.min.js' {
export * from 'pdf-lib'
}

0 comments on commit f062d46

Please sign in to comment.