Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Opposite of ignore? #283

Open
iansu opened this issue Apr 19, 2022 · 7 comments
Open

Opposite of ignore? #283

iansu opened this issue Apr 19, 2022 · 7 comments
Labels
question Further information is requested

Comments

@iansu
Copy link

iansu commented Apr 19, 2022

Is there a way to specify a file or glob that should always be included in the traced file list? Basically the opposite of the ignore setting? I tried using a negated glob in ignore but that didn't give me the results I wanted and I don't see anything else in the docs that seems like what I need.

@styfle styfle added the question Further information is requested label Apr 19, 2022
@styfle
Copy link
Member

styfle commented Apr 19, 2022

No, there is no option for that.

I recommend adding a line like fs.readFile(path.join(__dirname, 'file.txt'))

@iansu
Copy link
Author

iansu commented Apr 22, 2022

What about exposing the special cases functionality? I think being able to add things to that list when calling nodeFileTrace would solve my issue. I see a lot of other issues related to adding things to that list as well. Is that something you'd be open to? I'd be willing to make a PR if it is.

@styfle
Copy link
Member

styfle commented Apr 22, 2022

Can you share your use case? Are you publishing a package to npm that you want to work with @vercel/nft?

@iansu
Copy link
Author

iansu commented Apr 22, 2022

I've built a plugin that uses NFT for bundling dependencies for Serverless Framework: https://github.com/neofinancial/serverless-plugin-neo

While upgrading Serverless projects to use this new plugin I've come across a couple packages that don't get traced properly. I've ended up building my own version of NFT's special cases functionality here: https://github.com/neofinancial/serverless-plugin-neo/blob/master/src/lib/dependencies.ts

What would be ideal is if I could just do something like this:

const tracedDependencies = await nodeFileTrace(entrypoints, {
  specialCases: {
    'datadog-lambda-js' ({ id, emitAssetDirectory }) {
      if (id.endsWith('datadog-lambda-js/dist/index.js')) {
        emitAssetDirectory(resolve(dirname(id), 'runtime/'));
      }
    },
  }
});

@styfle
Copy link
Member

styfle commented Apr 23, 2022

How about adding that special case to nft?

@iansu
Copy link
Author

iansu commented Apr 24, 2022

I can definitely do that. I've already added two in my project and I see a number of open issues about other cases which is why I suggested making that list extensible. I'm happy to just make a PR for these cases though.

@styfle
Copy link
Member

styfle commented Apr 24, 2022

A PR with an integration test would be welcome, thanks!

(see #262 for an example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants