@vercel/next 3.9.2 → 3.9.4

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
@@ -41589,7 +41589,7 @@ const build = async ({ files, workPath, repoRootPath, entrypoint, config = {}, m
41589
41589
  });
41590
41590
  const canUsePreviewMode = Object.keys(pages).some(page => (0, utils_1.isApiPage)(pages[page].fsPath));
41591
41591
  const originalStaticPages = await (0, build_utils_1.glob)('**/*.html', pagesDir);
41592
- staticPages = await (0, utils_1.filterStaticPages)(originalStaticPages, dynamicPages, entryDirectory, exports.htmlContentType, prerenderManifest, routesManifest);
41592
+ staticPages = (0, utils_1.filterStaticPages)(originalStaticPages, dynamicPages, entryDirectory, exports.htmlContentType, prerenderManifest, routesManifest);
41593
41593
  hasStatic500 = !!staticPages[path_1.default.posix.join(entryDirectory, '500')];
41594
41594
  // this can be either 404.html in latest versions
41595
41595
  // or _errors/404.html versions while this was experimental
@@ -42708,6 +42708,7 @@ async function getServerlessPages(params) {
42708
42708
  ? Promise.all([
42709
42709
  (0, build_utils_1.glob)('**/page.js', path_1.default.join(params.pagesDir, '../app')),
42710
42710
  (0, build_utils_1.glob)('**/route.js', path_1.default.join(params.pagesDir, '../app')),
42711
+ (0, build_utils_1.glob)('**/_not-found.js', path_1.default.join(params.pagesDir, '../app')),
42711
42712
  ]).then(items => Object.assign(...items))
42712
42713
  : Promise.resolve({}),
42713
42714
  (0, utils_1.getMiddlewareManifest)(params.entryPath, params.outputDirectory),
@@ -44278,7 +44279,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44278
44279
  return (mod && mod.__esModule) ? mod : { "default": mod };
44279
44280
  };
44280
44281
  Object.defineProperty(exports, "__esModule", ({ value: true }));
44281
- exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0;
44282
+ exports.removeInlinedSourceMap = exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0;
44282
44283
  const convert_source_map_1 = __importDefault(__webpack_require__(7101));
44283
44284
  const fs_extra_1 = __importDefault(__webpack_require__(2650));
44284
44285
  const webpack_sources_1 = __webpack_require__(5013);
@@ -44325,7 +44326,7 @@ exports.raw = raw;
44325
44326
  */
44326
44327
  async function fileToSource(content, sourceName, fullFilePath) {
44327
44328
  const sourcemap = await getSourceMap(content, fullFilePath);
44328
- const cleanContent = convert_source_map_1.default.removeComments(content);
44329
+ const cleanContent = removeInlinedSourceMap(content);
44329
44330
  return sourcemap
44330
44331
  ? new webpack_sources_1.SourceMapSource(cleanContent, sourceName, sourcemap)
44331
44332
  : new webpack_sources_1.OriginalSource(cleanContent, sourceName);
@@ -44362,6 +44363,38 @@ function stringifySourceMap(sourceMap) {
44362
44363
  return JSON.stringify(obj);
44363
44364
  }
44364
44365
  exports.stringifySourceMap = stringifySourceMap;
44366
+ // Based on https://github.com/thlorenz/convert-source-map/blob/f1ed815b4edacfa9c3c5552dd342e71a3cffbb0a/index.js#L4 (MIT license)
44367
+ // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
44368
+ const SOURCE_MAP_COMMENT_REGEX = /^\s*?\/[/*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/gm;
44369
+ function isValidSourceMapData(encoding, data) {
44370
+ if (encoding !== 'base64') {
44371
+ // Unknown encoding. I think the comment is short (e.g. URL) if it's not
44372
+ // base64 encoded, so let's keep it to be safe.
44373
+ return false;
44374
+ }
44375
+ // Remove any spaces and "*/" of the source map comment. They should not be
44376
+ // considered as a part of the source map data.
44377
+ data = data.replace(/\s/g, '').replace(/\*\//g, '');
44378
+ // If it's an invalid base64 string, it must be a sourceMappingURL
44379
+ // inside a template literal like the follwoing.
44380
+ // https://github.com/webpack-contrib/style-loader/blob/16e401b17a39544d5c8ca47c9032f02e2b60d8f5/src/runtime/styleDomAPI.js#L35C1-L40C1
44381
+ return /^[a-zA-Z0-9+=/]+$/.test(data);
44382
+ }
44383
+ /*
44384
+ * Removes sourceMappingURL comments from a string.
44385
+ */
44386
+ function removeInlinedSourceMap(source) {
44387
+ for (const m of source.matchAll(SOURCE_MAP_COMMENT_REGEX)) {
44388
+ // Check if it's certainly a sourceMappingURL in a comment, not a part
44389
+ // of JavaScript code (e.g. template literal).
44390
+ if (!isValidSourceMapData(m[4], m[5])) {
44391
+ continue;
44392
+ }
44393
+ source = source.replace(m[0], '');
44394
+ }
44395
+ return source;
44396
+ }
44397
+ exports.removeInlinedSourceMap = removeInlinedSourceMap;
44365
44398
 
44366
44399
 
44367
44400
  /***/ }),
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0;
6
+ exports.removeInlinedSourceMap = exports.stringifySourceMap = exports.fileToSource = exports.raw = exports.sourcemapped = void 0;
7
7
  const convert_source_map_1 = __importDefault(require("convert-source-map"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const webpack_sources_1 = require("webpack-sources");
@@ -50,7 +50,7 @@ exports.raw = raw;
50
50
  */
51
51
  async function fileToSource(content, sourceName, fullFilePath) {
52
52
  const sourcemap = await getSourceMap(content, fullFilePath);
53
- const cleanContent = convert_source_map_1.default.removeComments(content);
53
+ const cleanContent = removeInlinedSourceMap(content);
54
54
  return sourcemap
55
55
  ? new webpack_sources_1.SourceMapSource(cleanContent, sourceName, sourcemap)
56
56
  : new webpack_sources_1.OriginalSource(cleanContent, sourceName);
@@ -87,3 +87,35 @@ function stringifySourceMap(sourceMap) {
87
87
  return JSON.stringify(obj);
88
88
  }
89
89
  exports.stringifySourceMap = stringifySourceMap;
90
+ // Based on https://github.com/thlorenz/convert-source-map/blob/f1ed815b4edacfa9c3c5552dd342e71a3cffbb0a/index.js#L4 (MIT license)
91
+ // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
92
+ const SOURCE_MAP_COMMENT_REGEX = /^\s*?\/[/*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/gm;
93
+ function isValidSourceMapData(encoding, data) {
94
+ if (encoding !== 'base64') {
95
+ // Unknown encoding. I think the comment is short (e.g. URL) if it's not
96
+ // base64 encoded, so let's keep it to be safe.
97
+ return false;
98
+ }
99
+ // Remove any spaces and "*/" of the source map comment. They should not be
100
+ // considered as a part of the source map data.
101
+ data = data.replace(/\s/g, '').replace(/\*\//g, '');
102
+ // If it's an invalid base64 string, it must be a sourceMappingURL
103
+ // inside a template literal like the follwoing.
104
+ // https://github.com/webpack-contrib/style-loader/blob/16e401b17a39544d5c8ca47c9032f02e2b60d8f5/src/runtime/styleDomAPI.js#L35C1-L40C1
105
+ return /^[a-zA-Z0-9+=/]+$/.test(data);
106
+ }
107
+ /*
108
+ * Removes sourceMappingURL comments from a string.
109
+ */
110
+ function removeInlinedSourceMap(source) {
111
+ for (const m of source.matchAll(SOURCE_MAP_COMMENT_REGEX)) {
112
+ // Check if it's certainly a sourceMappingURL in a comment, not a part
113
+ // of JavaScript code (e.g. template literal).
114
+ if (!isValidSourceMapData(m[4], m[5])) {
115
+ continue;
116
+ }
117
+ source = source.replace(m[0], '');
118
+ }
119
+ return source;
120
+ }
121
+ exports.removeInlinedSourceMap = removeInlinedSourceMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/next",
3
- "version": "3.9.2",
3
+ "version": "3.9.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
@@ -26,7 +26,7 @@
26
26
  "@types/semver": "6.0.0",
27
27
  "@types/text-table": "0.2.1",
28
28
  "@types/webpack-sources": "3.2.0",
29
- "@vercel/build-utils": "6.8.2",
29
+ "@vercel/build-utils": "6.8.3",
30
30
  "@vercel/nft": "0.22.5",
31
31
  "@vercel/routing-utils": "2.2.1",
32
32
  "async-sema": "3.0.1",