evenchange4 / graphql.macro

Compile GraphQL AST at build-time with babel-plugin-macros.
MIT License
239 stars 21 forks source link

Add tsconfig.json to `resolveImportPath.js` #114

Open mgs95 opened 4 years ago

mgs95 commented 4 years ago

Typescript users use a tsconfig.json file instead of a jsconfig.json file. Both contain the include field which is used to get the absolute path.

Inside resolveImportPath.js there should be something like this:

var jsconfigPath = path.resolve(CMD, 'jsconfig.json');
var tsconfigPath = path.resolve(CMD, 'tsconfig.json');
var jsconfigInclude;

if (fs.existsSync(jsconfigPath) || fs.existsSync(tsconfigPath)) {
  var config = fs.readFileSync(jsconfigPath, 'utf8') || fs.readFileSync(tsconfigPath, 'utf8');
  var jsconfig = JSON.parse(config);
  jsconfigInclude = jsconfig.include ? jsconfig.include[0] : null;
}

With this fix, issues regarding absolute paths should be resolved.

angelsanchez commented 4 years ago

I have the same problem.

Thanks for the solution @mgs95