@vercel/static-build 0.23.1 → 0.23.2-canary.2
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.
package/dist/index.js
CHANGED
|
@@ -13731,7 +13731,8 @@ const frameworks_1 = __importDefault(__webpack_require__(8438));
|
|
|
13731
13731
|
const fs_1 = __webpack_require__(5747);
|
|
13732
13732
|
const os_1 = __webpack_require__(2087);
|
|
13733
13733
|
const build_utils_1 = __webpack_require__(3445);
|
|
13734
|
-
const
|
|
13734
|
+
const BuildOutputV1 = __importStar(__webpack_require__(5497));
|
|
13735
|
+
const BuildOutputV3 = __importStar(__webpack_require__(8939));
|
|
13735
13736
|
const GatsbyUtils = __importStar(__webpack_require__(8573));
|
|
13736
13737
|
const NuxtUtils = __importStar(__webpack_require__(431));
|
|
13737
13738
|
const sleep = (n) => new Promise(resolve => setTimeout(resolve, n));
|
|
@@ -13896,7 +13897,7 @@ async function fetchBinary(url, framework, version) {
|
|
|
13896
13897
|
throw new build_utils_1.NowBuildError({
|
|
13897
13898
|
code: 'STATIC_BUILD_BINARY_NOT_FOUND',
|
|
13898
13899
|
message: `Version ${version} of ${framework} does not exist. Please specify a different one.`,
|
|
13899
|
-
link: 'https://vercel.
|
|
13900
|
+
link: 'https://vercel.link/framework-versioning',
|
|
13900
13901
|
});
|
|
13901
13902
|
}
|
|
13902
13903
|
await build_utils_1.spawnAsync(`curl -sSL ${url} | tar -zx -C /usr/local/bin`, [], {
|
|
@@ -13908,9 +13909,7 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
13908
13909
|
await build_utils_1.download(files, workPath, meta);
|
|
13909
13910
|
const mountpoint = path_1.default.dirname(entrypoint);
|
|
13910
13911
|
const entrypointDir = path_1.default.join(workPath, mountpoint);
|
|
13911
|
-
let distPath = path_1.default.join(workPath, path_1.default.dirname(entrypoint),
|
|
13912
|
-
config.outputDirectory ||
|
|
13913
|
-
'dist');
|
|
13912
|
+
let distPath = path_1.default.join(workPath, path_1.default.dirname(entrypoint), config.distDir || config.outputDirectory || 'dist');
|
|
13914
13913
|
const pkg = getPkg(entrypoint, workPath);
|
|
13915
13914
|
const devScript = pkg ? getScriptName(pkg, 'dev', config) : null;
|
|
13916
13915
|
const framework = getFramework(config, pkg);
|
|
@@ -13985,12 +13984,12 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
13985
13984
|
Node.js will load 'false' as a string, not a boolean, so it's truthy still.
|
|
13986
13985
|
This is to ensure we don't accidentally break other packages that check
|
|
13987
13986
|
if process.env.CI is true somewhere.
|
|
13988
|
-
|
|
13987
|
+
|
|
13989
13988
|
https://github.com/facebook/create-react-app/issues/2453
|
|
13990
13989
|
https://github.com/facebook/create-react-app/pull/2501
|
|
13991
13990
|
https://github.com/vercel/community/discussions/30
|
|
13992
13991
|
*/
|
|
13993
|
-
if (framework
|
|
13992
|
+
if ((framework === null || framework === void 0 ? void 0 : framework.slug) === 'create-react-app') {
|
|
13994
13993
|
if (!spawnOpts.env) {
|
|
13995
13994
|
spawnOpts.env = {};
|
|
13996
13995
|
}
|
|
@@ -14009,10 +14008,7 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
14009
14008
|
};
|
|
14010
14009
|
if (!config.zeroConfig) {
|
|
14011
14010
|
build_utils_1.debug('Detected "builds" - not zero config');
|
|
14012
|
-
printInstall();
|
|
14013
|
-
const installTime = Date.now();
|
|
14014
14011
|
await build_utils_1.runNpmInstall(entrypointDir, [], spawnOpts, meta, nodeVersion);
|
|
14015
|
-
build_utils_1.debug(`Install complete [${Date.now() - installTime}ms]`);
|
|
14016
14012
|
isNpmInstall = true;
|
|
14017
14013
|
}
|
|
14018
14014
|
else if (typeof installCommand === 'string') {
|
|
@@ -14076,11 +14072,7 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
14076
14072
|
isPipInstall = true;
|
|
14077
14073
|
}
|
|
14078
14074
|
if (pkg) {
|
|
14079
|
-
console.log('Detected package.json');
|
|
14080
|
-
printInstall();
|
|
14081
|
-
const installTime = Date.now();
|
|
14082
14075
|
await build_utils_1.runNpmInstall(entrypointDir, [], spawnOpts, meta, nodeVersion);
|
|
14083
|
-
build_utils_1.debug(`Install complete [${Date.now() - installTime}ms]`);
|
|
14084
14076
|
isNpmInstall = true;
|
|
14085
14077
|
}
|
|
14086
14078
|
}
|
|
@@ -14184,6 +14176,27 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
14184
14176
|
throw new Error(`Missing required "${buildCommand || 'vercel-build'}" script in "${entrypoint}"`);
|
|
14185
14177
|
}
|
|
14186
14178
|
const outputDirPrefix = path_1.default.join(workPath, path_1.default.dirname(entrypoint));
|
|
14179
|
+
// If the Build Command or Framework output files according to the
|
|
14180
|
+
// Build Output v3 API, then stop processing here in `static-build`
|
|
14181
|
+
// since the output is already in its final form.
|
|
14182
|
+
const buildOutputPath = await BuildOutputV3.getBuildOutputDirectory(outputDirPrefix);
|
|
14183
|
+
if (buildOutputPath) {
|
|
14184
|
+
// Ensure that `vercel build` is being used for this Deployment
|
|
14185
|
+
if (!meta.cliVersion) {
|
|
14186
|
+
let buildCommandName;
|
|
14187
|
+
if (buildCommand)
|
|
14188
|
+
buildCommandName = `"${buildCommand}"`;
|
|
14189
|
+
else if (framework)
|
|
14190
|
+
buildCommandName = framework.name;
|
|
14191
|
+
else
|
|
14192
|
+
buildCommandName = 'the "build" script';
|
|
14193
|
+
throw new Error(`Detected Build Output v3 from ${buildCommandName}, but this Deployment is not using \`vercel build\`.\nPlease set the \`ENABLE_VC_BUILD=1\` environment variable.`);
|
|
14194
|
+
}
|
|
14195
|
+
return {
|
|
14196
|
+
buildOutputVersion: 3,
|
|
14197
|
+
buildOutputPath,
|
|
14198
|
+
};
|
|
14199
|
+
}
|
|
14187
14200
|
if (framework) {
|
|
14188
14201
|
const outputDirName = config.outputDirectory
|
|
14189
14202
|
? config.outputDirectory
|
|
@@ -14199,7 +14212,7 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
|
|
|
14199
14212
|
distPath = publicPath;
|
|
14200
14213
|
}
|
|
14201
14214
|
}
|
|
14202
|
-
const extraOutputs = await
|
|
14215
|
+
const extraOutputs = await BuildOutputV1.readBuildOutputDirectory({
|
|
14203
14216
|
workPath,
|
|
14204
14217
|
nodeVersion,
|
|
14205
14218
|
});
|
|
@@ -14265,7 +14278,7 @@ exports.build = build;
|
|
|
14265
14278
|
const prepareCache = async ({ entrypoint, workPath, config, }) => {
|
|
14266
14279
|
const cacheFiles = {};
|
|
14267
14280
|
// File System API v1 cache files
|
|
14268
|
-
const buildConfig = await
|
|
14281
|
+
const buildConfig = await BuildOutputV1.readBuildOutputConfig({
|
|
14269
14282
|
workPath,
|
|
14270
14283
|
configFileName: 'build.json',
|
|
14271
14284
|
});
|
|
@@ -14337,141 +14350,7 @@ exports.isObjectEmpty = isObjectEmpty;
|
|
|
14337
14350
|
|
|
14338
14351
|
/***/ }),
|
|
14339
14352
|
|
|
14340
|
-
/***/
|
|
14341
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
14342
|
-
|
|
14343
|
-
"use strict";
|
|
14344
|
-
|
|
14345
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14346
|
-
if (k2 === undefined) k2 = k;
|
|
14347
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
14348
|
-
}) : (function(o, m, k, k2) {
|
|
14349
|
-
if (k2 === undefined) k2 = k;
|
|
14350
|
-
o[k2] = m[k];
|
|
14351
|
-
}));
|
|
14352
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14353
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14354
|
-
}) : function(o, v) {
|
|
14355
|
-
o["default"] = v;
|
|
14356
|
-
});
|
|
14357
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14358
|
-
if (mod && mod.__esModule) return mod;
|
|
14359
|
-
var result = {};
|
|
14360
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
14361
|
-
__setModuleDefault(result, mod);
|
|
14362
|
-
return result;
|
|
14363
|
-
};
|
|
14364
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14365
|
-
exports.injectVercelAnalyticsPlugin = void 0;
|
|
14366
|
-
const fs_1 = __webpack_require__(5747);
|
|
14367
|
-
const path = __importStar(__webpack_require__(5622));
|
|
14368
|
-
const _shared_1 = __webpack_require__(2229);
|
|
14369
|
-
const defaultConfig = {
|
|
14370
|
-
plugins: [
|
|
14371
|
-
{
|
|
14372
|
-
resolve: 'gatsby-plugin-vercel',
|
|
14373
|
-
options: {},
|
|
14374
|
-
},
|
|
14375
|
-
],
|
|
14376
|
-
};
|
|
14377
|
-
async function injectVercelAnalyticsPlugin(dir) {
|
|
14378
|
-
// Gatsby requires a special variable name for environment variables to be
|
|
14379
|
-
// exposed to the client-side JavaScript bundles:
|
|
14380
|
-
process.env.GATSBY_VERCEL_ANALYTICS_ID = process.env.VERCEL_ANALYTICS_ID;
|
|
14381
|
-
const gatsbyConfigName = 'gatsby-config.js';
|
|
14382
|
-
const gatsbyPluginPackageName = 'gatsby-plugin-vercel';
|
|
14383
|
-
const gatsbyConfigPath = path.join(dir, gatsbyConfigName);
|
|
14384
|
-
console.log(`Injecting Gatsby.js analytics plugin "${gatsbyPluginPackageName}" to \`${gatsbyConfigPath}\``);
|
|
14385
|
-
const pkgJson = (await _shared_1.readPackageJson(dir));
|
|
14386
|
-
if (!pkgJson.dependencies) {
|
|
14387
|
-
pkgJson.dependencies = {};
|
|
14388
|
-
}
|
|
14389
|
-
if (!pkgJson.dependencies[gatsbyPluginPackageName]) {
|
|
14390
|
-
console.log(`Adding "${gatsbyPluginPackageName}" to \`package.json\` "dependencies"`);
|
|
14391
|
-
pkgJson.dependencies[gatsbyPluginPackageName] = 'latest';
|
|
14392
|
-
await _shared_1.writePackageJson(dir, pkgJson);
|
|
14393
|
-
}
|
|
14394
|
-
if (await _shared_1.fileExists(gatsbyConfigPath)) {
|
|
14395
|
-
await fs_1.promises.rename(gatsbyConfigPath, gatsbyConfigPath + '.__vercel_builder_backup__.js');
|
|
14396
|
-
await fs_1.promises.writeFile(gatsbyConfigPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
|
|
14397
|
-
|
|
14398
|
-
// https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
|
|
14399
|
-
const preferDefault = m => (m && m.default) || m;
|
|
14400
|
-
|
|
14401
|
-
const vercelConfig = Object.assign(
|
|
14402
|
-
{},
|
|
14403
|
-
|
|
14404
|
-
// https://github.com/gatsbyjs/gatsby/blob/a6ecfb2b01d761e8a3612b8ea132c698659923d9/packages/gatsby/src/services/initialize.ts#L113-L117
|
|
14405
|
-
preferDefault(userConfig)
|
|
14406
|
-
);
|
|
14407
|
-
if (!vercelConfig.plugins) {
|
|
14408
|
-
vercelConfig.plugins = [];
|
|
14409
|
-
}
|
|
14410
|
-
|
|
14411
|
-
const hasPlugin = vercelConfig.plugins.find(
|
|
14412
|
-
(p) =>
|
|
14413
|
-
p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
|
|
14414
|
-
);
|
|
14415
|
-
if (!hasPlugin) {
|
|
14416
|
-
vercelConfig.plugins = vercelConfig.plugins.slice();
|
|
14417
|
-
vercelConfig.plugins.push({
|
|
14418
|
-
resolve: "gatsby-plugin-vercel",
|
|
14419
|
-
options: {},
|
|
14420
|
-
});
|
|
14421
|
-
}
|
|
14422
|
-
|
|
14423
|
-
module.exports = vercelConfig;
|
|
14424
|
-
`);
|
|
14425
|
-
}
|
|
14426
|
-
else {
|
|
14427
|
-
await fs_1.promises.writeFile(gatsbyConfigPath, `module.exports = ${JSON.stringify(defaultConfig)}`);
|
|
14428
|
-
}
|
|
14429
|
-
}
|
|
14430
|
-
exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
/***/ }),
|
|
14434
|
-
|
|
14435
|
-
/***/ 431:
|
|
14436
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
14437
|
-
|
|
14438
|
-
"use strict";
|
|
14439
|
-
|
|
14440
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14441
|
-
exports.injectVercelAnalyticsPlugin = void 0;
|
|
14442
|
-
const path_1 = __webpack_require__(5622);
|
|
14443
|
-
const rc9_1 = __webpack_require__(6649);
|
|
14444
|
-
const _shared_1 = __webpack_require__(2229);
|
|
14445
|
-
// https://github.com/nuxt-community/web-vitals-module
|
|
14446
|
-
const ANALYTICS_PLUGIN_PACKAGE = '@nuxtjs/web-vitals';
|
|
14447
|
-
async function injectVercelAnalyticsPlugin(dir) {
|
|
14448
|
-
// First update the `.nuxtrc` file to inject the analytics plugin.
|
|
14449
|
-
// See: https://gist.github.com/pi0/23b5253ac19b4ed5a70add3b971545c9
|
|
14450
|
-
const nuxtrcPath = path_1.join(dir, '.nuxtrc');
|
|
14451
|
-
console.log(`Injecting Nuxt.js analytics plugin "${ANALYTICS_PLUGIN_PACKAGE}" to \`${nuxtrcPath}\``);
|
|
14452
|
-
rc9_1.update({
|
|
14453
|
-
'modules[]': ANALYTICS_PLUGIN_PACKAGE,
|
|
14454
|
-
}, {
|
|
14455
|
-
name: nuxtrcPath,
|
|
14456
|
-
});
|
|
14457
|
-
// The dependency needs to be listed in `package.json` as well so
|
|
14458
|
-
// that `npm i` installs the package.
|
|
14459
|
-
const pkgJson = (await _shared_1.readPackageJson(dir));
|
|
14460
|
-
if (!pkgJson.dependencies) {
|
|
14461
|
-
pkgJson.dependencies = {};
|
|
14462
|
-
}
|
|
14463
|
-
if (!pkgJson.dependencies[ANALYTICS_PLUGIN_PACKAGE]) {
|
|
14464
|
-
pkgJson.dependencies[ANALYTICS_PLUGIN_PACKAGE] = 'latest';
|
|
14465
|
-
console.log(`Adding "${ANALYTICS_PLUGIN_PACKAGE}" to \`package.json\` "dependencies"`);
|
|
14466
|
-
await _shared_1.writePackageJson(dir, pkgJson);
|
|
14467
|
-
}
|
|
14468
|
-
}
|
|
14469
|
-
exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
/***/ }),
|
|
14473
|
-
|
|
14474
|
-
/***/ 315:
|
|
14353
|
+
/***/ 5497:
|
|
14475
14354
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
14476
14355
|
|
|
14477
14356
|
"use strict";
|
|
@@ -14671,6 +14550,173 @@ async function readBuildOutputConfig({ workPath, configFileName, }) {
|
|
|
14671
14550
|
exports.readBuildOutputConfig = readBuildOutputConfig;
|
|
14672
14551
|
|
|
14673
14552
|
|
|
14553
|
+
/***/ }),
|
|
14554
|
+
|
|
14555
|
+
/***/ 8939:
|
|
14556
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
14557
|
+
|
|
14558
|
+
"use strict";
|
|
14559
|
+
|
|
14560
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14561
|
+
exports.getBuildOutputDirectory = void 0;
|
|
14562
|
+
const path_1 = __webpack_require__(5622);
|
|
14563
|
+
const fs_1 = __webpack_require__(5747);
|
|
14564
|
+
const BUILD_OUTPUT_DIR = '.vercel/output';
|
|
14565
|
+
/**
|
|
14566
|
+
* Returns the path to the Build Output v3 directory when the
|
|
14567
|
+
* `config.json` file was created by the framework / build script,
|
|
14568
|
+
* or `undefined` if the framework did not create the v3 output.
|
|
14569
|
+
*/
|
|
14570
|
+
async function getBuildOutputDirectory(path) {
|
|
14571
|
+
try {
|
|
14572
|
+
const outputDir = path_1.join(path, BUILD_OUTPUT_DIR);
|
|
14573
|
+
const configPath = path_1.join(outputDir, 'config.json');
|
|
14574
|
+
await fs_1.promises.stat(configPath);
|
|
14575
|
+
return outputDir;
|
|
14576
|
+
}
|
|
14577
|
+
catch (err) {
|
|
14578
|
+
if (err.code !== 'ENOENT')
|
|
14579
|
+
throw err;
|
|
14580
|
+
}
|
|
14581
|
+
return undefined;
|
|
14582
|
+
}
|
|
14583
|
+
exports.getBuildOutputDirectory = getBuildOutputDirectory;
|
|
14584
|
+
|
|
14585
|
+
|
|
14586
|
+
/***/ }),
|
|
14587
|
+
|
|
14588
|
+
/***/ 8573:
|
|
14589
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
14590
|
+
|
|
14591
|
+
"use strict";
|
|
14592
|
+
|
|
14593
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14594
|
+
if (k2 === undefined) k2 = k;
|
|
14595
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
14596
|
+
}) : (function(o, m, k, k2) {
|
|
14597
|
+
if (k2 === undefined) k2 = k;
|
|
14598
|
+
o[k2] = m[k];
|
|
14599
|
+
}));
|
|
14600
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14601
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14602
|
+
}) : function(o, v) {
|
|
14603
|
+
o["default"] = v;
|
|
14604
|
+
});
|
|
14605
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14606
|
+
if (mod && mod.__esModule) return mod;
|
|
14607
|
+
var result = {};
|
|
14608
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
14609
|
+
__setModuleDefault(result, mod);
|
|
14610
|
+
return result;
|
|
14611
|
+
};
|
|
14612
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14613
|
+
exports.injectVercelAnalyticsPlugin = void 0;
|
|
14614
|
+
const fs_1 = __webpack_require__(5747);
|
|
14615
|
+
const path = __importStar(__webpack_require__(5622));
|
|
14616
|
+
const _shared_1 = __webpack_require__(2229);
|
|
14617
|
+
const defaultConfig = {
|
|
14618
|
+
plugins: [
|
|
14619
|
+
{
|
|
14620
|
+
resolve: 'gatsby-plugin-vercel',
|
|
14621
|
+
options: {},
|
|
14622
|
+
},
|
|
14623
|
+
],
|
|
14624
|
+
};
|
|
14625
|
+
async function injectVercelAnalyticsPlugin(dir) {
|
|
14626
|
+
// Gatsby requires a special variable name for environment variables to be
|
|
14627
|
+
// exposed to the client-side JavaScript bundles:
|
|
14628
|
+
process.env.GATSBY_VERCEL_ANALYTICS_ID = process.env.VERCEL_ANALYTICS_ID;
|
|
14629
|
+
const gatsbyConfigName = 'gatsby-config.js';
|
|
14630
|
+
const gatsbyPluginPackageName = 'gatsby-plugin-vercel';
|
|
14631
|
+
const gatsbyConfigPath = path.join(dir, gatsbyConfigName);
|
|
14632
|
+
console.log(`Injecting Gatsby.js analytics plugin "${gatsbyPluginPackageName}" to \`${gatsbyConfigPath}\``);
|
|
14633
|
+
const pkgJson = (await _shared_1.readPackageJson(dir));
|
|
14634
|
+
if (!pkgJson.dependencies) {
|
|
14635
|
+
pkgJson.dependencies = {};
|
|
14636
|
+
}
|
|
14637
|
+
if (!pkgJson.dependencies[gatsbyPluginPackageName]) {
|
|
14638
|
+
console.log(`Adding "${gatsbyPluginPackageName}" to \`package.json\` "dependencies"`);
|
|
14639
|
+
pkgJson.dependencies[gatsbyPluginPackageName] = 'latest';
|
|
14640
|
+
await _shared_1.writePackageJson(dir, pkgJson);
|
|
14641
|
+
}
|
|
14642
|
+
if (await _shared_1.fileExists(gatsbyConfigPath)) {
|
|
14643
|
+
await fs_1.promises.rename(gatsbyConfigPath, gatsbyConfigPath + '.__vercel_builder_backup__.js');
|
|
14644
|
+
await fs_1.promises.writeFile(gatsbyConfigPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
|
|
14645
|
+
|
|
14646
|
+
// https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
|
|
14647
|
+
const preferDefault = m => (m && m.default) || m;
|
|
14648
|
+
|
|
14649
|
+
const vercelConfig = Object.assign(
|
|
14650
|
+
{},
|
|
14651
|
+
|
|
14652
|
+
// https://github.com/gatsbyjs/gatsby/blob/a6ecfb2b01d761e8a3612b8ea132c698659923d9/packages/gatsby/src/services/initialize.ts#L113-L117
|
|
14653
|
+
preferDefault(userConfig)
|
|
14654
|
+
);
|
|
14655
|
+
if (!vercelConfig.plugins) {
|
|
14656
|
+
vercelConfig.plugins = [];
|
|
14657
|
+
}
|
|
14658
|
+
|
|
14659
|
+
const hasPlugin = vercelConfig.plugins.find(
|
|
14660
|
+
(p) =>
|
|
14661
|
+
p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
|
|
14662
|
+
);
|
|
14663
|
+
if (!hasPlugin) {
|
|
14664
|
+
vercelConfig.plugins = vercelConfig.plugins.slice();
|
|
14665
|
+
vercelConfig.plugins.push({
|
|
14666
|
+
resolve: "gatsby-plugin-vercel",
|
|
14667
|
+
options: {},
|
|
14668
|
+
});
|
|
14669
|
+
}
|
|
14670
|
+
|
|
14671
|
+
module.exports = vercelConfig;
|
|
14672
|
+
`);
|
|
14673
|
+
}
|
|
14674
|
+
else {
|
|
14675
|
+
await fs_1.promises.writeFile(gatsbyConfigPath, `module.exports = ${JSON.stringify(defaultConfig)}`);
|
|
14676
|
+
}
|
|
14677
|
+
}
|
|
14678
|
+
exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
|
|
14679
|
+
|
|
14680
|
+
|
|
14681
|
+
/***/ }),
|
|
14682
|
+
|
|
14683
|
+
/***/ 431:
|
|
14684
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
14685
|
+
|
|
14686
|
+
"use strict";
|
|
14687
|
+
|
|
14688
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14689
|
+
exports.injectVercelAnalyticsPlugin = void 0;
|
|
14690
|
+
const path_1 = __webpack_require__(5622);
|
|
14691
|
+
const rc9_1 = __webpack_require__(6649);
|
|
14692
|
+
const _shared_1 = __webpack_require__(2229);
|
|
14693
|
+
// https://github.com/nuxt-community/web-vitals-module
|
|
14694
|
+
const ANALYTICS_PLUGIN_PACKAGE = '@nuxtjs/web-vitals';
|
|
14695
|
+
async function injectVercelAnalyticsPlugin(dir) {
|
|
14696
|
+
// First update the `.nuxtrc` file to inject the analytics plugin.
|
|
14697
|
+
// See: https://gist.github.com/pi0/23b5253ac19b4ed5a70add3b971545c9
|
|
14698
|
+
const nuxtrcPath = path_1.join(dir, '.nuxtrc');
|
|
14699
|
+
console.log(`Injecting Nuxt.js analytics plugin "${ANALYTICS_PLUGIN_PACKAGE}" to \`${nuxtrcPath}\``);
|
|
14700
|
+
rc9_1.update({
|
|
14701
|
+
'modules[]': ANALYTICS_PLUGIN_PACKAGE,
|
|
14702
|
+
}, {
|
|
14703
|
+
name: nuxtrcPath,
|
|
14704
|
+
});
|
|
14705
|
+
// The dependency needs to be listed in `package.json` as well so
|
|
14706
|
+
// that `npm i` installs the package.
|
|
14707
|
+
const pkgJson = (await _shared_1.readPackageJson(dir));
|
|
14708
|
+
if (!pkgJson.dependencies) {
|
|
14709
|
+
pkgJson.dependencies = {};
|
|
14710
|
+
}
|
|
14711
|
+
if (!pkgJson.dependencies[ANALYTICS_PLUGIN_PACKAGE]) {
|
|
14712
|
+
pkgJson.dependencies[ANALYTICS_PLUGIN_PACKAGE] = 'latest';
|
|
14713
|
+
console.log(`Adding "${ANALYTICS_PLUGIN_PACKAGE}" to \`package.json\` "dependencies"`);
|
|
14714
|
+
await _shared_1.writePackageJson(dir, pkgJson);
|
|
14715
|
+
}
|
|
14716
|
+
}
|
|
14717
|
+
exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
|
|
14718
|
+
|
|
14719
|
+
|
|
14674
14720
|
/***/ }),
|
|
14675
14721
|
|
|
14676
14722
|
/***/ 5685:
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBuildOutputDirectory = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const BUILD_OUTPUT_DIR = '.vercel/output';
|
|
7
|
+
/**
|
|
8
|
+
* Returns the path to the Build Output v3 directory when the
|
|
9
|
+
* `config.json` file was created by the framework / build script,
|
|
10
|
+
* or `undefined` if the framework did not create the v3 output.
|
|
11
|
+
*/
|
|
12
|
+
async function getBuildOutputDirectory(path) {
|
|
13
|
+
try {
|
|
14
|
+
const outputDir = path_1.join(path, BUILD_OUTPUT_DIR);
|
|
15
|
+
const configPath = path_1.join(outputDir, 'config.json');
|
|
16
|
+
await fs_1.promises.stat(configPath);
|
|
17
|
+
return outputDir;
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err.code !== 'ENOENT')
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
exports.getBuildOutputDirectory = getBuildOutputDirectory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2-canary.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/build-step",
|
|
@@ -14,17 +14,28 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "node build",
|
|
17
|
-
"test-unit": "jest --env node --verbose --
|
|
17
|
+
"test-unit": "jest --env node --verbose --bail test/build.test.ts test/prepare-cache.test.ts",
|
|
18
18
|
"test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.js",
|
|
19
19
|
"prepublishOnly": "node build"
|
|
20
20
|
},
|
|
21
|
+
"jest": {
|
|
22
|
+
"preset": "ts-jest/presets/default",
|
|
23
|
+
"testEnvironment": "node",
|
|
24
|
+
"globals": {
|
|
25
|
+
"ts-jest": {
|
|
26
|
+
"diagnostics": true,
|
|
27
|
+
"isolatedModules": true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
21
31
|
"devDependencies": {
|
|
22
32
|
"@types/aws-lambda": "8.10.64",
|
|
23
33
|
"@types/cross-spawn": "6.0.0",
|
|
34
|
+
"@types/jest": "27.4.1",
|
|
24
35
|
"@types/ms": "0.7.31",
|
|
25
36
|
"@types/node-fetch": "2.5.4",
|
|
26
37
|
"@types/promise-timeout": "1.3.0",
|
|
27
|
-
"@vercel/build-utils": "2.15.
|
|
38
|
+
"@vercel/build-utils": "2.15.2-canary.2",
|
|
28
39
|
"@vercel/frameworks": "0.7.1",
|
|
29
40
|
"@vercel/ncc": "0.24.0",
|
|
30
41
|
"@vercel/routing-utils": "1.13.1",
|
|
@@ -34,5 +45,5 @@
|
|
|
34
45
|
"node-fetch": "2.6.1",
|
|
35
46
|
"rc9": "1.2.0"
|
|
36
47
|
},
|
|
37
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b61f049f1186ccc804cea35bcf61d16583ed6ca2"
|
|
38
49
|
}
|