Giter Site home page Giter Site logo

ncc and prebuildify about ncc HOT 3 CLOSED

sroussey avatar sroussey commented on July 16, 2024
ncc and prebuildify

from ncc.

Comments (3)

styfle avatar styfle commented on July 16, 2024

require('./hello.node') will be statically analyzed properly

There's an integration test here https://github.com/vercel/ncc/blob/main/test/integration/binary-require.js

If you're running into a problem, its likely because you're doing dynamic require which can't be statically analyzed easily, something like function dynamic(str) { return require(str) }

The partially dynamic case should also work, something like function prebuildPath(str) { return path.join(__dirname, 'prebuild', str) } since the prefix is statically analyzable so the entire directory can be included.

from ncc.

sroussey avatar sroussey commented on July 16, 2024

Yes, stuff is dynamic. I was able to get around it by adding this:

// dummy code for ncc to include the native module
if (process.uptime() < 0) {
  require(__dirname + "/../../../prebuilds/darwin-arm64+x64/usearch.node");
  require(__dirname + "/../../../prebuilds/linux-arm64/usearch.node");
  require(__dirname + "/../../../prebuilds/linux-x64/usearch.node");
  require(__dirname + "/../../../prebuilds/win32-ia32/usearch.node");
  require(__dirname + "/../../../prebuilds/win32-x64/usearch.node");
  require(__dirname + "/../../../build/Release/usearch.node");
}

from ncc.

styfle avatar styfle commented on July 16, 2024

Great, I'll close this issue since its working πŸ‘

from ncc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.