Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility Issue with pptxgenjs and Vite #1325

Open
11HiteshK01 opened this issue Apr 22, 2024 · 1 comment
Open

Compatibility Issue with pptxgenjs and Vite #1325

11HiteshK01 opened this issue Apr 22, 2024 · 1 comment
Assignees

Comments

@11HiteshK01
Copy link

I'm trying to use pptxgenjs (version [3.12.0]) within a Quasar project that utilizes Vite for building. However, I'm encountering an error during the build process due to pptxgenjs's reliance on Node.js-style require statements (specifically for the https module).

Expected Behavior:
The Quasar/Vite build process should successfully bundle the project without errors.

Actual Behavior:
The build fails with an error message similar to:
Error: The plugin "vite:dep-pre-bundle" was triggered by this import
node_modules/pptxgenjs/dist/pptxgen.es.js:4883:90:
4883 │ ... require !== 'undefined' && typeof window === 'undefined' ? require('https') : null; // NodeJS
Error: Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-0a035c79.js:40970:10: ERROR: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json.

Additional Information:
@quasar/app-vite: 1.3.0
vue: 3.0.0
quasar: 2.6.0

Request:

  1. Is there a known workaround or compatibility information for using pptxgenjs in Vite projects?
  2. Are there any plans to make pptxgenjs more compatible with modern build tools like Vite?

Thank you for your time and assistance.

@MurhafSousli
Copy link

We are having the same issue, we are getting the following error in Angular 18 project. it looks like pptxgenjs relies on https package which causes the issue

 Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json.
 
 node_modules/esbuild/lib/main.js:1225:21:
      1225 │         let result = await callback({
           ╵                      ^

    at packageEntryFailure (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47164:15)
    at resolvePackageEntry (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47161:3)
    at tryNodeResolve (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:46977:16)
    at ResolveIdContext.resolveId (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:46727:19)
    at PluginContainer.resolveId (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:49506:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:66556:15
    at async file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47480:28
    at async requestCallbacks.on-resolve (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1225:22)
    at async handleRequest (C:\nds\ng-18\node_modules\esbuild\lib\main.js:647:11)

  This error came from the "onResolve" callback registered here:

    node_modules/esbuild/lib/main.js:1150:20:
      1150 │       let promise = setup({
           ╵                     ^

    at setup (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47463:13)
    at handlePlugins (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1150:21)
    at buildOrContextImpl (C:\nds\ng-18\node_modules\esbuild\lib\main.js:873:5)
    at Object.buildOrContext (C:\nds\ng-18\node_modules\esbuild\lib\main.js:699:5)
    at C:\nds\ng-18\node_modules\esbuild\lib\main.js:2032:68
    at new Promise (<anonymous>)
    at Object.context (C:\nds\ng-18\node_modules\esbuild\lib\main.js:2032:27)
    at Object.context (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1874:58)
    at prepareEsbuildOptimizerRun (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:51405:33)

  The plugin "vite:dep-pre-bundle" was triggered by this import

    node_modules/pptxgenjs/dist/pptxgen.es.js:4715:88:
      4715 │   var https = typeof require !== 'undefined' && typeof window === 'undefined' ? require('https') : null; // NodeJS
           ╵                                                                                         ~~~~~~~

X [ERROR] Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json. [plugin vite:dep-pre-bundle]

    node_modules/esbuild/lib/main.js:1225:21:
      1225 │         let result = await callback({
           ╵                      ^

    at packageEntryFailure (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47164:15)
    at resolvePackageEntry (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47161:3)
    at tryNodeResolve (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:46977:16)
    at ResolveIdContext.resolveId (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:46727:19)
    at PluginContainer.resolveId (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:49506:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:66556:15
    at async file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47480:28
    at async requestCallbacks.on-resolve (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1225:22)
    at async handleRequest (C:\nds\ng-18\node_modules\esbuild\lib\main.js:647:11)

  This error came from the "onResolve" callback registered here:

    node_modules/esbuild/lib/main.js:1150:20:
      1150 │       let promise = setup({
           ╵                     ^

    at setup (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:47463:13)
    at handlePlugins (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1150:21)
    at buildOrContextImpl (C:\nds\ng-18\node_modules\esbuild\lib\main.js:873:5)
    at Object.buildOrContext (C:\nds\ng-18\node_modules\esbuild\lib\main.js:699:5)
    at C:\nds\ng-18\node_modules\esbuild\lib\main.js:2032:68
    at new Promise (<anonymous>)
    at Object.context (C:\nds\ng-18\node_modules\esbuild\lib\main.js:2032:27)
    at Object.context (C:\nds\ng-18\node_modules\esbuild\lib\main.js:1874:58)
    at prepareEsbuildOptimizerRun (file:///C:/nds/ng-18/node_modules/vite/dist/node/chunks/dep-C1-ZB6nQ.js:51405:33)

  The plugin "vite:dep-pre-bundle" was triggered by this import

    node_modules/xhr2/lib/xhr2.js:117:18:
      117 │   https = require('https');
          ╵                   ~~~~~~~

3:28:13 PM [vite] Pre-transform error: Build failed with 2 errors:
node_modules/esbuild/lib/main.js:1225:21: ERROR: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json.
node_modules/esbuild/lib/main.js:1225:21: ERROR: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "https". The package may have incorrect main/module/exports specified in its package.json.

@gitbrent gitbrent self-assigned this Oct 27, 2024
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

No branches or pull requests

3 participants