Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Ethan-Arrowood
Copy link
Contributor

Adds support for auto injection into Gatsby's new ESM config format. Only injects if the gatsby-config.mjs is present, and continues to default generation of gatsby-config.js

expect(contents.some(name => name === 'gatsby-config.mjs')).toBeTruthy();
// using `import` causes a seg fault.
expect(await fs.readFile(path.join(workPath, 'gatsby-config.mjs'), 'utf-8'))
.toBe(`import userConfig from "./gatsby-config.mjs.__vercel_builder_backup__.mjs";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): make assertion less specific

This test assertion is brittle when we want to change the injected code. What do you think about asserting only the first line, which captures the core of the difference between this type of injection vs. the others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the other test which utilize snapshots. This stuff rarely changes so I'm fine with leaving as is. Maybe using some other form of snapshotting will work better too

"use": "@vercel/static-build",
"config": {
"zeroConfig": true,
"framework": "gatsby"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe vercel.json can be simplified to a single line now that we support framework

https://vercel.com/docs/project-configuration#project-configuration/framework

{
  "framework": "gatsby"
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:true-dat: I'm going to merge as is since this copies the other ones and I don't want to gold plate in this PR. Going to be modifying static-build including tests soon so I'll make sure to incorporate this recommended change then

@Ethan-Arrowood Ethan-Arrowood added the pr: automerge Automatically merge the PR when checks pass label Jan 9, 2023
@kodiakhq kodiakhq bot merged commit e28c5f9 into main Jan 9, 2023
@kodiakhq kodiakhq bot deleted the ethan/vccli-397-support-gatsby-configmjs-for-analytics branch January 9, 2023 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: static-build pr: automerge Automatically merge the PR when checks pass semver: minor PR contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants