@vercel/next 2.7.9 → 2.8.66

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.
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // The Next.js builder can emit the project in a subdirectory depending on how
4
+ // many folder levels of `node_modules` are traced. To ensure `process.cwd()`
5
+ // returns the proper path, we change the directory to the folder with the
6
+ // launcher. This mimics `yarn workspace run` behavior.
7
+ process.chdir(__dirname);
8
+ const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
9
+ if (!process.env.NODE_ENV) {
10
+ process.env.NODE_ENV = region === 'dev1' ? 'development' : 'production';
11
+ }
12
+ if (process.env.NODE_ENV !== 'production' && region !== 'dev1') {
13
+ console.warn(`Warning: NODE_ENV was incorrectly set to "${process.env.NODE_ENV}", this value is being overridden to "production"`);
14
+ process.env.NODE_ENV = 'production';
15
+ }
16
+ // eslint-disable-next-line
17
+ const NextServer = require('__NEXT_SERVER_PATH__').default;
18
+ const nextServer = new NextServer({
19
+ // @ts-ignore __NEXT_CONFIG__ value is injected
20
+ conf: __NEXT_CONFIG__,
21
+ dir: '.',
22
+ minimalMode: true,
23
+ customServer: false,
24
+ });
25
+ const requestHandler = nextServer.getRequestHandler();
26
+ module.exports = async (req, res) => {
27
+ try {
28
+ // entryDirectory handler
29
+ await requestHandler(req, res);
30
+ }
31
+ catch (err) {
32
+ console.error(err);
33
+ // crash the lambda immediately to clean up any bad module state,
34
+ // this was previously handled in ___vc_bridge on an unhandled rejection
35
+ // but we can do this quicker by triggering here
36
+ process.exit(1);
37
+ }
38
+ };
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0;
7
+ const convert_source_map_1 = __importDefault(require("convert-source-map"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const webpack_sources_1 = require("webpack-sources");
10
+ /**
11
+ * A template literal tag that preserves existing source maps, if any. This
12
+ * allows to compose multiple sources and preserve the source maps, so we can
13
+ * resolve the correct line numbers in the stack traces later on.
14
+ *
15
+ * @param strings The string literals.
16
+ * @param sources All the sources that may optionally have source maps. Use
17
+ * `raw` to pass a string that should be inserted raw (with no source map
18
+ * attached).
19
+ */
20
+ function sourcemapped(strings, ...sources) {
21
+ const concat = new webpack_sources_1.ConcatSource();
22
+ for (let i = 0; i < Math.max(strings.length, sources.length); i++) {
23
+ const string = strings[i];
24
+ const source = sources[i];
25
+ if (string)
26
+ concat.add(raw(string));
27
+ if (source)
28
+ concat.add(source);
29
+ }
30
+ return concat;
31
+ }
32
+ exports.sourcemapped = sourcemapped;
33
+ /**
34
+ * A helper to create a Source from a string with no source map.
35
+ * This allows to obfuscate the source code from the user and print `[native code]`
36
+ * when resolving the stack trace.
37
+ */
38
+ function raw(value) {
39
+ return new webpack_sources_1.OriginalSource(value, '[native code]');
40
+ }
41
+ exports.raw = raw;
42
+ /**
43
+ * Takes a file with contents and tries to extract its source maps it will
44
+ * first try to use a `${fullFilePath}.map` file if it exists. Then, it will
45
+ * try to use the inline source map comment.
46
+ *
47
+ * @param content The file contents.
48
+ * @param sourceName the name of the source.
49
+ * @param fullFilePath The full path to the file.
50
+ */
51
+ async function fileToSource(content, sourceName, fullFilePath) {
52
+ const sourcemap = await getSourceMap(content, fullFilePath);
53
+ const cleanContent = convert_source_map_1.default.removeComments(content);
54
+ return sourcemap
55
+ ? new webpack_sources_1.SourceMapSource(cleanContent, sourceName, sourcemap)
56
+ : new webpack_sources_1.OriginalSource(cleanContent, sourceName);
57
+ }
58
+ exports.fileToSource = fileToSource;
59
+ /**
60
+ * Finds a source map for a given content and file path. First it will try to
61
+ * use a `${fullFilePath}.map` file if it exists. Then, it will try to use
62
+ * the inline source map comment.
63
+ */
64
+ async function getSourceMap(content, fullFilePath) {
65
+ try {
66
+ if (fullFilePath && (await fs_extra_1.default.pathExists(`${fullFilePath}.map`))) {
67
+ const mapJson = await fs_extra_1.default.readFile(`${fullFilePath}.map`, 'utf8');
68
+ return convert_source_map_1.default.fromJSON(mapJson).toObject();
69
+ }
70
+ return convert_source_map_1.default.fromComment(content).toObject();
71
+ }
72
+ catch (_a) {
73
+ return null;
74
+ }
75
+ }
76
+ /**
77
+ * Stringifies a source map, removing unnecessary data:
78
+ * * `sourcesContent` is not needed to trace back frames.
79
+ */
80
+ function stringifySourceMap(sourceMap) {
81
+ if (!sourceMap)
82
+ return;
83
+ const obj = typeof sourceMap === 'object'
84
+ ? { ...sourceMap }
85
+ : convert_source_map_1.default.fromJSON(sourceMap).toObject();
86
+ delete obj.sourcesContent;
87
+ return JSON.stringify(obj);
88
+ }
89
+ exports.stringifySourceMap = stringifySourceMap;
@@ -1,23 +1,22 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  // The Next.js builder can emit the project in a subdirectory depending on how
4
3
  // many folder levels of `node_modules` are traced. To ensure `process.cwd()`
5
4
  // returns the proper path, we change the directory to the folder with the
6
5
  // launcher. This mimics `yarn workspace run` behavior.
7
6
  process.chdir(__dirname);
7
+ const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
8
8
  if (!process.env.NODE_ENV) {
9
- const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
10
9
  process.env.NODE_ENV = region === 'dev1' ? 'development' : 'production';
11
10
  }
12
- const http_1 = require("http");
13
- const now__bridge_1 = require("./now__bridge");
11
+ if (process.env.NODE_ENV !== 'production' && region !== 'dev1') {
12
+ console.warn(`Warning: NODE_ENV was incorrectly set to "${process.env.NODE_ENV}", this value is being overridden to "production"`);
13
+ process.env.NODE_ENV = 'production';
14
+ }
15
+ // @ts-ignore
14
16
  // eslint-disable-next-line
15
17
  let page = {};
16
18
  // __LAUNCHER_PAGE_HANDLER__
17
19
  // page.render is for React rendering
18
20
  // page.default is for /api rendering
19
21
  // page is for module.exports in /api
20
- const server = new http_1.Server(page.render || page.default || page);
21
- const bridge = new now__bridge_1.Bridge(server);
22
- bridge.listen();
23
- exports.launcher = bridge.launcher;
22
+ module.exports = page.render || page.default || page;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  // The Next.js builder can emit the project in a subdirectory depending on how
4
3
  // many folder levels of `node_modules` are traced. To ensure `process.cwd()`
5
4
  // returns the proper path, we change the directory to the folder with the
@@ -9,15 +8,10 @@ if (!process.env.NODE_ENV) {
9
8
  const region = process.env.VERCEL_REGION || process.env.NOW_REGION;
10
9
  process.env.NODE_ENV = region === 'dev1' ? 'development' : 'production';
11
10
  }
12
- const http_1 = require("http");
13
- const now__bridge_1 = require("./now__bridge");
14
11
  // @ts-ignore
15
12
  // eslint-disable-next-line @typescript-eslint/no-var-requires
16
13
  const page = require(__LAUNCHER_PAGE_PATH__);
17
14
  // page.render is for React rendering
18
15
  // page.default is for /api rendering
19
16
  // page is for module.exports in /api
20
- const server = new http_1.Server(page.render || page.default || page);
21
- const bridge = new now__bridge_1.Bridge(server);
22
- bridge.listen();
23
- exports.launcher = bridge.launcher;
17
+ module.exports = page.render || page.default || page;