Skip to content

Conversation

@yhatt
Copy link
Member

@yhatt yhatt commented Jul 29, 2025

Fix #676.

The latest pptxgenjs has improved support for hybrid environments, such as Web, Node.js, and other bundlers. If pptxgenjs detected running on Node.js, pptxgenjs will try to import node:fs and node:https dynamically with import statement.

// STEP 2: Lazy-load Node built-ins if needed
const loadNodeDeps = isNode
  ? async () => {
    ; ({ default: fs } = await import('node:fs')); ({ default: https } = await import('node:https'))
  }
  : async () => { }

https://github.com/gitbrent/PptxGenJS/blob/3c9ec1b687c174952166f6a34b5e87ebf69fa469/src/gen-media.ts#L23

However, a dyanamic import statement is known that it does not work as expected in the binary build packaged by pkg (@yao-pkg/pkg).

So I've updated the configuration of rollup output.dynamicImportInCjs to false, to apply downlevel transpiling for dynamic import() to use require().

This transpilation will break already ESM compatible import for the engine so I also have added the rollup plugin for keeping dynamic import() for the engine.

@yhatt yhatt changed the title Avoid using dynamic import() in the bundled output Avoid using dynamic import() in the bundled output as much as possible Jul 29, 2025
@yhatt yhatt merged commit 2d3efeb into main Jul 29, 2025
@yhatt yhatt deleted the pptxgenjs-dynamic-import branch July 29, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Standalone binary] Fail to import pptxgenjs when converting to pptx

2 participants