Repository: vercel/nft (javascript)

Issue:
Add support for `argon2`
This integration test fails:

```js
const argon2 = require('argon2');
console.log('argon is ' + typeof argon2);
```

### Error

```
/private/var/folders/v7/6kzxdgb93x328tk9pg633s200000gn/T/node-file-trace-2963026860021942/node_modules/node-gyp-build/index.js:56
  throw new Error('No native build was found for ' + target)
  ^

Error: No native build was found for platform=darwin arch=x64 runtime=node abi=64 uv=1 libc=glibc
    at Function.load.path (/private/var/folders/v7/6kzxdgb93x328tk9pg633s200000gn/T/node-file-trace-2963026860021942/node_modules/node-gyp-build/index.js:56:9)
    at load (/private/var/folders/v7/6kzxdgb93x328tk9pg633s200000gn/T/node-file-trace-2963026860021942/node_modules/node-gyp-build/index.js:20:30)
    at Object.<anonymous> (/private/var/folders/v7/6kzxdgb93x328tk9pg633s200000gn/T/node-file-trace-2963026860021942/node_modules/argon2/argon2.js:5:81)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
```

Related to https://github.com/zeit/now-builders/issues/929

This is likely an issue with argon2's dependency [node-gyp-build](https://www.npmjs.com/package/node-gyp-build) (related to #1) which will likely have to be special cased.


Discussion:
Hey @styfle, any ETA for this? Been trying to deployed with Now for a month now... Would love to see it available soon. Thank you for your work.

Patch:
diff --git a/package.json b/package.json
--- a/package.json
+++ b/package.json
@@ -39,6 +39,7 @@
     "@zeit/ncc": "^0.17.0",
     "analytics-node": "^3.4.0-beta.1",
     "apollo-server-express": "^2.6.7",
+    "argon2": "^0.24.0",
     "auth0": "^2.18.0",
     "axios": "^0.19.0",
     "azure-storage": "^2.10.3",
diff --git a/src/utils/special-cases.js b/src/utils/special-cases.js
--- a/src/utils/special-cases.js
+++ b/src/utils/special-cases.js
@@ -8,6 +8,12 @@ const specialCases = {
       emitAssetDirectory(path.resolve(path.dirname(id), 'runtime/'));
     }
   },
+  'argon2' ({ id, emitAssetDirectory }) {
+    if (id.endsWith('argon2/argon2.js')) {
+      emitAssetDirectory(path.resolve(path.dirname(id), 'build', 'Release'));
+      emitAssetDirectory(path.resolve(path.dirname(id), 'prebuilds'));
+    }
+  },
   'bull' ({ id, emitAssetDirectory }) {
     if (id.endsWith('bull/lib/commands/index.js')) {
       emitAssetDirectory(path.resolve(path.dirname(id)));
diff --git a/windows-prepare.js b/windows-prepare.js
--- a/windows-prepare.js
+++ b/windows-prepare.js
@@ -8,15 +8,17 @@ if (process.platform === 'win32') {
   const pkg = JSON.parse(pkgJson);
   unlinkSync(join(__dirname, 'yarn.lock'));
   unlinkSync(join(__dirname, 'test', 'integration', 'tensorflow.js'));
+  unlinkSync(join(__dirname, 'test', 'integration', 'argon2.js'));
   unlinkSync(join(__dirname, 'test', 'integration', 'highlights.js'));
   unlinkSync(join(__dirname, 'test', 'integration', 'hot-shots.js'));
   unlinkSync(join(__dirname, 'test', 'integration', 'yoga-layout.js'));
   unlinkSync(join(__dirname, 'test', 'integration', 'loopback.js'));
   delete pkg.devDependencies['@tensorflow/tfjs-node'];
+  delete pkg.devDependencies['argon2'];
   delete pkg.devDependencies['highlights'];
   delete pkg.devDependencies['hot-shots'];
   delete pkg.devDependencies['yoga-layout'];
   writeFileSync(join(__dirname, 'package.json'), JSON.stringify(pkg));
 } else {
-  console.log('[azure-prepare] Expected current platform to be win32 but found ' + process.platform);
+  console.log('[windows-prepare] Expected current platform to be win32 but found ' + process.platform);
 }
diff --git a/yarn.lock b/yarn.lock
--- a/yarn.lock
+++ b/yarn.lock
@@ -937,6 +937,13 @@
   dependencies:
     core-js "^2.5.7"
 
+"@phc/format@^0.5.0":
+  version "0.5.0"
+  resolved "https://registry.yarnpkg.com/@phc/format/-/format-0.5.0.tgz#a99d27a83d78b3100a191412adda04315e2e3aba"
+  integrity sha512-JWtZ5P1bfXU0bAtTzCpOLYHDXuxSVdtL/oqz4+xa97h8w9E5IlVN333wugXVFv8vZ1hbXObKQf1ptXmFFcMByg==
+  dependencies:
+    safe-buffer "^5.1.2"
+
 "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
   version "1.1.2"
   resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
@@ -1852,6 +1859,15 @@ are-we-there-yet@~1.1.2:
     delegates "^1.0.0"
     readable-stream "^2.0.6"
 
+argon2@^0.24.0:
+  version "0.24.0"
+  resolved "https://registry.yarnpkg.com/argon2/-/argon2-0.24.0.tgz#60a7d7e7ce2a0a3b93d4455446153546f01ca3aa"
+  integrity sha512-796movQU1LIW4egM+FH2mrgaTBtIhjEvuTx3sfw0W+Ijbk29IvKOh/i1IDAKCS9s6Y+2GdlPVU5q/gQZ3lyp5w==
+  dependencies:
+    "@phc/format" "^0.5.0"
+    node-addon-api "^1.6.3"
+    node-gyp-build "^4.1.0"
+
 argparse@^1.0.7:
   version "1.0.10"
   resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@@ -8979,6 +8995,11 @@ node-abi@^2.7.0:
   dependencies:
     semver "^5.4.1"
 
+node-addon-api@^1.6.3:
+  version "1.7.1"
+  resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.1.tgz#cf813cd69bb8d9100f6bdca6755fc268f54ac492"
+  integrity sha512-2+DuKodWvwRTrCfKOeR24KIc5unKjOh8mz17NCzVnHWfjAdDqbfbjqh7gUT+BkXBRQM52+xCHciKWonJ3CbJMQ==
+
 node-fetch-npm@^2.0.2:
   version "2.0.2"
   resolved "https://registry.yarnpkg.com/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz#7258c9046182dca345b4208eda918daf33697ff7"
@@ -9016,6 +9037,11 @@ node-forge@^0.8.0, node-forge@^0.8.1:
   resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.8.5.tgz#57906f07614dc72762c84cef442f427c0e1b86ee"
   integrity sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q==
 
+node-gyp-build@^4.1.0:
+  version "4.1.0"
+  resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.1.0.tgz#3bc3dd7dd4aafecaf64a2e3729e785bc3cdea565"
+  integrity sha512-rGLv++nK20BG8gc0MzzcYe1Nl3p3mtwJ74Q2QD0HTEDKZ6NvOFSelY6s2QBPWIHRR8h7hpad0LiwajfClBJfNg==
+
 node-gyp@^3.6.2, node-gyp@^3.8.0:
   version "3.8.0"
   resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.8.0.tgz#540304261c330e80d0d5edce253a68cb3964218c"


Test patch:
diff --git a/test/integration/argon2.js b/test/integration/argon2.js
new file mode 100644
--- /dev/null
+++ b/test/integration/argon2.js
@@ -0,0 +1,2 @@
+const argon2 = require('argon2');
+console.log('argon is ' + typeof argon2);
\ No newline at end of file