Friday, 11 February 2022

How do node_modules packages read config files in the project root?

I am creating an npm package that needs to be able to read config files from the project root. I'm not sure how to do this.

For example,

  • Next.js is able to read ./pages/ and ./next.config.js from the project root
  • Jest is able to read ./jest.config.js from the project root
  • ESLint is able to read ./.eslintrc.json from the project root
  • Prettier is able to read ./.prettierrc.js from the project root
  • Typescript is able to read ./tsconfig.json from the project root
  • Babel is able to read ./.babelrc from the project root

I've tried looking at their source code to see how they do it but the projects are so large that I can't find the relevant section.

How do they achieve this?



from How do node_modules packages read config files in the project root?

No comments:

Post a Comment