Skip to content

Commit fcdaee6

Browse files
alvisKyleAMathews
authored andcommitted
fix(gatsby): remove .js suffixes in require() to allow transpilation (#5087)
In earlier v1, one could write files such as `gatsby-config` in typescript and use babel to transpile the file into js on the fly via `babel-node --presets @babel/preset-typescript --extensions '.ts' gatsby develop`. However, it's no longer possible in recent releases. The reason is that the current implementation put a `.js` suffix on each require(`gatsby-${env}.js`), which blocks `gatsby-{$env}` files being transpiled from other languages via babel. The PR addresses this problem by removing the unnecessary suffix and preserving the integrity. Signed-off-by: Alvis HT Tang <[email protected]>
1 parent 3f7c40c commit fcdaee6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/gatsby/src/bootstrap/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ module.exports = async (args: BootstrapArgs) => {
7272
activity.end()
7373

7474
// Try opening the site's gatsby-config.js file.
75-
activity = report.activityTimer(`open and validate gatsby-config.js`)
75+
activity = report.activityTimer(`open and validate gatsby-config`)
7676
activity.start()
7777
const config = await preferDefault(
78-
getConfigFile(program.directory, `gatsby-config.js`)
78+
getConfigFile(program.directory, `gatsby-config`)
7979
)
8080

8181
store.dispatch({
@@ -182,7 +182,7 @@ module.exports = async (args: BootstrapArgs) => {
182182

183183
const envAPIs = plugin[`${env}APIs`]
184184
if (envAPIs && Array.isArray(envAPIs) && envAPIs.length > 0) {
185-
return slash(path.join(plugin.resolve, `gatsby-${env}.js`))
185+
return slash(path.join(plugin.resolve, `gatsby-${env}`))
186186
}
187187
return undefined
188188
}

0 commit comments

Comments
 (0)