@vercel/static-build 1.0.45 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,12 +38,18 @@ async function injectVercelAnalyticsPlugin(dir) {
38
38
  // exposed to the client-side JavaScript bundles:
39
39
  process.env.GATSBY_VERCEL_ANALYTICS_ID = process.env.VERCEL_ANALYTICS_ID;
40
40
  const gatsbyConfigPathJs = path.join(dir, `${GATSBY_CONFIG_FILE}.js`);
41
+ const gatsbyConfigPathMjs = path.join(dir, `${GATSBY_CONFIG_FILE}.mjs`);
41
42
  const gatsbyConfigPathTs = path.join(dir, `${GATSBY_CONFIG_FILE}.ts`);
42
43
  if (await _shared_1.fileExists(gatsbyConfigPathTs)) {
43
44
  console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathTs}\``);
44
45
  await addGatsbyPackage(dir);
45
46
  return updateGatsbyTsConfig(gatsbyConfigPathTs);
46
47
  }
48
+ if (await _shared_1.fileExists(gatsbyConfigPathMjs)) {
49
+ console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathMjs}\``);
50
+ await addGatsbyPackage(dir);
51
+ return updateGatsbyMjsConfig(gatsbyConfigPathMjs);
52
+ }
47
53
  console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathJs}\``);
48
54
  await addGatsbyPackage(dir);
49
55
  if (await _shared_1.fileExists(gatsbyConfigPathJs)) {
@@ -96,6 +102,39 @@ if (!hasPlugin) {
96
102
  });
97
103
  }
98
104
 
105
+ export default vercelConfig;
106
+ `);
107
+ }
108
+ async function updateGatsbyMjsConfig(configPath) {
109
+ await fs_1.promises.rename(configPath, configPath + '.__vercel_builder_backup__.mjs');
110
+ await fs_1.promises.writeFile(configPath, `import userConfig from "./gatsby-config.mjs.__vercel_builder_backup__.mjs";
111
+
112
+ // https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
113
+ const preferDefault = (m) => (m && m.default) || m;
114
+
115
+ const vercelConfig = Object.assign(
116
+ {},
117
+
118
+ // https://github.com/gatsbyjs/gatsby/blob/a6ecfb2b01d761e8a3612b8ea132c698659923d9/packages/gatsby/src/services/initialize.ts#L113-L117
119
+ preferDefault(userConfig)
120
+ );
121
+ if (!vercelConfig.plugins) {
122
+ vercelConfig.plugins = [];
123
+ }
124
+
125
+ const hasPlugin = vercelConfig.plugins.find(
126
+ (p) =>
127
+ p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
128
+ );
129
+
130
+ if (!hasPlugin) {
131
+ vercelConfig.plugins = vercelConfig.plugins.slice();
132
+ vercelConfig.plugins.push({
133
+ resolve: "gatsby-plugin-vercel",
134
+ options: {},
135
+ });
136
+ }
137
+
99
138
  export default vercelConfig;
100
139
  `);
101
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "1.0.45",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -36,8 +36,8 @@
36
36
  "@types/ms": "0.7.31",
37
37
  "@types/node-fetch": "2.5.4",
38
38
  "@types/promise-timeout": "1.3.0",
39
- "@vercel/build-utils": "5.7.3",
40
- "@vercel/frameworks": "1.1.16",
39
+ "@vercel/build-utils": "5.7.4",
40
+ "@vercel/frameworks": "1.1.18",
41
41
  "@vercel/ncc": "0.24.0",
42
42
  "@vercel/routing-utils": "2.1.3",
43
43
  "@vercel/static-config": "2.0.6",
@@ -50,5 +50,5 @@
50
50
  "tree-kill": "1.2.2",
51
51
  "typescript": "4.3.4"
52
52
  },
53
- "gitHead": "d6cccd70f28969eec48b484b0e74b0942de9b6cd"
53
+ "gitHead": "721cd3afcbff994fa96704b4eb79e5f6da7ab73c"
54
54
  }