box-node-sdk icon indicating copy to clipboard operation
box-node-sdk copied to clipboard

Compilation issues with box-node-sdk, webpack, and proxy-agent

Open taylorreece opened this issue 2 years ago • 1 comments

  • [X] I have checked that the SDK documentation doesn't solve my issue.
  • [X] I have checked that the API documentation doesn't solve my issue.
  • [X] I have searched the Box Developer Forums and my issue isn't already reported (or if it has been reported, I have attached a link to it, for reference).
  • [X] I have searched Issues in this repo and my issue isn't already reported.

Description of the Issue

Hi Box team, I'm struggling to compile a project that includes box-node-sdk with webpack, and I'm looking to see if you have any guidance or insight.

My project previously used 1.33.0, which compiled fine. Any version after that (1.34.0 up to latest 2.6.0) fails to compile. I've put together a minimal repro here: https://github.com/taylorreece/box-webpack-issue . If you bring the box-node-sdk version down to 1.33.0, you can npm install && npm run build fine. If you have any version past 1.33.0, compilation fails with this error:

ERROR in ./node_modules/source-map/lib/binary-search.js
Self-reference dependency has unused export name: This should not happen
Error: Self-reference dependency has unused export name: This should not happen
    at CommonJsSelfReferenceDependencyTemplate.apply (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js:102:10)
    at JavascriptGenerator.sourceDependency (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/javascript/JavascriptGenerator.js:206:12)
    at JavascriptGenerator.sourceModule (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/javascript/JavascriptGenerator.js:112:9)
    at JavascriptGenerator.generate (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/javascript/JavascriptGenerator.js:98:8)
    at NormalModule.codeGeneration (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/NormalModule.js:1204:22)
    at /Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/Compilation.js:3326:22
    at /Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/Cache.js:93:5
    at Hook.eval [as callAsync] (eval at create (/Users/treece/Desktop/box-webpack-issue/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Cache.get (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/Cache.js:75:18)
    at ItemCacheFacade.get (/Users/treece/Desktop/box-webpack-issue/node_modules/webpack/lib/CacheFacade.js:111:15)
 @ ./node_modules/source-map/lib/source-map-consumer.js 9:19-45
 @ ./node_modules/source-map/source-map.js 7:0-82
 @ ./node_modules/escodegen/escodegen.js 2571:29-61
 @ ./node_modules/degenerator/dist/src/index.js 3:20-40
 @ ./node_modules/pac-resolver/dist/index.js 6:22-44
 @ ./node_modules/pac-proxy-agent/dist/agent.js 26:39-62
 @ ./node_modules/pac-proxy-agent/dist/index.js 7:32-50
 @ ./node_modules/proxy-agent/index.js 16:20-46
 @ ./node_modules/box-node-sdk/lib/util/config.js 125:25-47
 @ ./node_modules/box-node-sdk/lib/box-node-sdk.js 59:13-37
 @ ./src/index.ts 1:0-34 2:16-22

It seems like it's related to the addition of the proxy-agent dependency, introduced in 1.34.0.

I really appreciate any insight you have - thanks!

Steps to Reproduce

  • Pull down https://github.com/taylorreece/box-webpack-issue
  • npm install && npm run build
  • See error

Expected Behavior

Successful compiliation

Versions Used

Node SDK: 1.34.0 - 2.6.0 Node version: 16.15.1 NPM version: 8.11.0

taylorreece avatar Sep 30 '22 19:09 taylorreece

Thanks for posting the issue. Let us investigate that and get back to you when we have more information

mhagmajer avatar Oct 07 '22 13:10 mhagmajer

This issue has been automatically marked as stale because it has not been updated in the last 30 days. It will be closed if no further activity occurs within the next 7 days. Feel free to reach out or mention Box SDK team member for further help and resources if they are needed.

stale[bot] avatar Dec 19 '22 19:12 stale[bot]

This issue still affects us, and we're stuck on 1.33.0 until we can use the box SDK with webpack. Bumping to keep this open.

taylorreece avatar Dec 19 '22 19:12 taylorreece

Hi @taylorreece , I'm closing this issue since box-node-sdk was not originally intended to be used in front-end applications, and we are not going to change this in the current version of the sdk.

However, we are intensively working on a new, refreshed version of our SDK, and we put our main emphasis on development there. So we are going to consider adding webpack support there.

arjankowski avatar Dec 22 '22 14:12 arjankowski

👍 It's not for a frontend app, but for an application connector on the Prismatic platform (https://prismatic.io/docs/components/box/), but point taken. I'm excited for the refreshed version of the SDK!

Have a great holiday season!

taylorreece avatar Dec 22 '22 19:12 taylorreece

If anyone else comes across this, it appears that you can safely add this to your webpack config to ignore the error:

optimization: {
    sideEffects: false,
},

taylorreece avatar Dec 30 '22 21:12 taylorreece