zowe / zowe-cli

Zowe CLI
Eclipse Public License 2.0
114 stars 86 forks source link

vsce package cannot be built with vscode and eslint #1577

Closed kraabrsg closed 1 year ago

kraabrsg commented 1 year ago

Describe the bug

since Version 7.7.0 (i think) several modules cannot be built in a vscode extension (eslint) and have to be defined external (keytar way longer )

> xxxxxxx@0.0.1 esbuild-base
> esbuild  ./client/src/extension.ts --outdir=./client/out --bundle --external:vscode --external:keytar --format=cjs --platform=node && esbuild  ./server/src/server.ts --outdir=./server/out --bundle --external:vscode --external:keytar --format=cjs --platform=node --minify

X [ERROR] No loader is configured for ".node" files: node_modules/@zowe/cli/node_modules/cpu-features/build/Release/cpufeatures.node

    node_modules/@zowe/cli/node_modules/cpu-features/lib/index.js:3:24:
      3 │ const binding = require('../build/Release/cpufeatures.node');
        ╵                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

X [ERROR] No loader is configured for ".node" files: node_modules/@zowe/cli/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node

    node_modules/@zowe/cli/node_modules/ssh2/lib/protocol/crypto.js:30:20:
      30 │   binding = require('./crypto/build/Release/sshcrypto.node');
         ╵                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2 errors
node:child_process:910
    throw err;
    ^

Error: Command failed: C:\Entwicklung\tools\vscodeDevWorkspace\zowe\node_modules\esbuild-windows-64\esbuild.exe ./client/src/extension.ts --outdir=./client/out --bundle --external:vscode --external:keytar --format=cjs --platform=node
    at checkExecSyncError (node:child_process:871:11)
    at Object.execFileSync (node:child_process:907:15)
    at Object.<anonymous> (C:\Entwicklung\tools\vscodeDevWorkspace\zowe\node_modules\esbuild\bin\esbuild:211:28)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 24432,
  stdout: null,
  stderr: null
}

build script (via "vsce package" runs "esbuild-base" and then minify) :

"vscode:prepublish": "npm run esbuild-base -- --minify",
....
"esbuild-base": "esbuild  ./client/src/extension.ts --outdir=./client/out --bundle --external:vscode --external:keytar --format=cjs --platform=node && esbuild  ./server/src/server.ts --outdir=./server/out --bundle --external:vscode --external:keytar --format=cjs --platform=node"

dependencies (we tried: 7.7.0, 7,8,0 and 7.9.0 ) :

        "@zowe/cli": "^7.7.0",
        "@zowe/imperative": "^5.7.2",
        "@zowe/zos-files-for-zowe-sdk": "^7.7.0",
        "@zowe/zos-ftp-for-zowe-cli": "2.1.0",
        "@zowe/zos-jobs-for-zowe-sdk": "^7.7.0",
        "@zowe/zos-tso-for-zowe-sdk": "^7.7.0",
        "@zowe/zosmf-for-zowe-sdk": "^7.7.0",
        "active-win": "^7.7.2",
        "await-notify": "^1.0.1",
        "axios": "0.27.2",
        "keytar": "7.9.0",

To fix this errors we declared these libs as external and included the node packages, which raises the size of vsix file from 6 mb to 48 mb (this could be reduce, by manually tryouts what is needed).

Maybe related to: https://github.com/zowe/zowe-cli/issues/1295

https://github.com/zowe/zowe-cli/blob/master/packages/cli/scripts/preinstall.js

Expected and actual results

how to avoid bundling these libraries (keytar, cpufeatures, sshcrpypto) as external with eslint ?

Describe your environment

WIN 10: node: 18.12.1 vscode extension

Additional context

Thank you!

github-actions[bot] commented 1 year ago

Thank you for creating a bug report. We will investigate the bug and evaluate its impact on the product. If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.