Skip to content
New issue

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

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

Already on GitHub? # to your account

Support nbind binary lookups #132

Closed
cztomsik opened this issue Dec 7, 2018 · 3 comments
Closed

Support nbind binary lookups #132

cztomsik opened this issue Dec 7, 2018 · 3 comments

Comments

@cztomsik
Copy link

cztomsik commented Dec 7, 2018

yoga-layout does not work with ncc, I'm not really sure what's wrong, but it looks like build/Release/nbind.node is not emitted to dist/yoga-layout which is then required during run

I've made repo where you can replicate this.
Running ncc run test.js yields this:

Emitting directory /Users/cztomsik/Desktop/playground/ncc-test/node_modules/yoga-layout as yoga-layout
  0kB  yoga-layout/.babelrc
  0kB  yoga-layout/.flowconfig
  0kB  yoga-layout/.hgignore
  0kB  yoga-layout/auto-top.gypi
  0kB  yoga-layout/auto.gypi
  0kB  yoga-layout/autogypi.json
  0kB  yoga-layout/binding.gyp
  1kB  yoga-layout/final-flags.gypi
  3kB  yoga-layout/package.json
 21kB  index.js
 81kB  yoga-layout/yarn.lock
106kB  [824ms]

/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/node_modules/nbind/dist/nbind.js:83
    var err = new Error('Could not locate the bindings file. Tried:\n' +
^
Error: Could not locate the bindings file. Tried:
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/Debug/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/Release/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/out/Debug/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/Debug/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/out/Release/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/Release/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/default/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/compiled/10.14.1/darwin/x64/nbind.node
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/Debug/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/Release/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/out/Debug/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/Debug/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/out/Release/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/Release/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/build/default/nbind.js
/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/yoga-layout/compiled/10.14.1/darwin/x64/nbind.js
    at findCompiledModule (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/node_modules/nbind/dist/nbind.js:83:1)
    at find (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/node_modules/nbind/dist/nbind.js:93:1)
    at Object.init (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/node_modules/nbind/dist/nbind.js:104:1)
    at Object.module.exports._extends (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/node_modules/yoga-layout/dist/entry-node.js:18:1)
    at __webpack_require__ (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/webpack/bootstrap:19:1)
    at Object.<anonymous> (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/test.js:1:1)
    at __webpack_require__ (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/webpack/bootstrap:19:1)
    at module.exports.webpackEmptyContext.keys (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/webpack:/webpack/bootstrap:83:1)
    at Object.<anonymous> (/private/var/folders/22/ghpldbvx6jvbkx9bv29x2py80000gp/T/804f5374cf20d/index.js:88:10)
    at Module._compile (internal/modules/cjs/loader.js:688:30)

I've tried to copy nbind.node to dist/yoga-layout but it doesn't seem to help either:

/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1
(function (exports, require, module, __filename, __dirname) { module.exports=function(e){var t={};function __webpack_require__(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,__webpack_require__),n.l=!0,n.exports}return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,r){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,t){if(1&t&&(e=__webpack_require__(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(__webpack_require__.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)__webpack_require__.d(r,n,function(t){ret

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
    at Module.require (internal/modules/cjs/loader.js:630:11)
    at require (internal/modules/cjs/helpers.js:20:18)
    at webpackEmptyContext (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:1387)
    at initNode (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:9081)
    at /Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:9330
    at findCompiledModule (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:8357)
    at find (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:8473)
    at Object.init (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:8727)
    at Object.<anonymous> (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:1787)
    at __webpack_require__ (/Users/cztomsik/Desktop/playground/ncc-test/dist/index.js:1:204)
@guybedford
Copy link
Contributor

I can verify that the build issue Could not locate the bindings file. Tried: seems to be fixed with #159.

The runtime issue TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string still remains though as a bug with this library.

@cztomsik
Copy link
Author

I think it's now a bug with nbind library (it works if I exclude nbind dependency with ncc build -e nbind test.js)

It seems nbind tries to find path of compiled module which will bail to some weird version of webpackEmptyContext which also has .resolve set to itself and so it will actually require the file instead of just resolving the path (or throwing an error)

@guybedford guybedford changed the title bindings yoga-layout Support nbind binary lookups Dec 16, 2018
@guybedford
Copy link
Contributor

Yes that sounds about right then. We specifically include support for bindings and node-pre-gyp so adding nbind support would be another one to be built into core here.

I've changed the title to reflect this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants