Js-Brecht / gatsby-plugin-ts-config

Configure Gatsby to use typescript configuration files
MIT License
60 stars 5 forks source link

useGatsbyConfig requires .ts file extension #40

Closed orsi closed 3 years ago

orsi commented 3 years ago

As per the readme, I was under the assumption I could just use the filename without .ts ending:

// gatsby-config.js
const { useGatsbyConfig } = require('gatsby-plugin-ts-config');
module.exports = useGatsbyConfig('./gatsby-config');

However, I get errors relating specifically to the gatsby-theme-i18n plugin:

Screen Shot 2021-09-03 at 11 45 50 AM

Those errors are resolved when I specify .ts explicitly:

// gatsby-config.js
const { useGatsbyConfig } = require('gatsby-plugin-ts-config');
module.exports = useGatsbyConfig('./gatsby-config.ts');

No errors:

Screen Shot 2021-09-03 at 11 47 58 AM
Js-Brecht commented 3 years ago

What version are you using? That was fixed in 2.0.1

orsi commented 3 years ago

Just recently installed it at 2.0.1:

image

Js-Brecht commented 3 years ago

Ah, you are putting gatsby-config.ts right next to gatsby-config.js. It’s finding the .js file, because node automatically prioritizes them.

I suppose in the transpiler I could use the other module resolver, instead of require.resolve… that will make it prioritize .ts

I’ve also got a feature nearly done that will include a CLI, so no .js files needed at all.

orsi commented 3 years ago

Ahh, yes. Kind of thought that might be the case which is why I added the .ts.

Js-Brecht commented 3 years ago

@orsi care to try gatsby-plugin-ts-config@2.0.2-rc.1?

Js-Brecht commented 3 years ago

Did some tests, seems to work as expected. Published in gatsby-plugin-ts-config@2.0.2

orsi commented 3 years ago

Updated and works on my end now without the explicit .ts extension. Thanks!