nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: mapbox/batfish
Pull request #265 (2018-03-27 20:35:26)

Prevent new default 404 page from breaking SPA mode


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b5515b..61943dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## Head
+
+- **Fix:** Prevent new default 404 page from breaking SPA mode.
+
 ## 1.7.4
 
 - **Fix:** Add `babel-core` to `dependencies`, since it's a peer dependency of `babel-loader`.
diff --git a/examples/spa-minimum-static-build/batfish.config.js b/examples/spa-minimum-static-build/batfish.config.js
index 345cd2f..0f3c1a5 100644
--- a/examples/spa-minimum-static-build/batfish.config.js
+++ b/examples/spa-minimum-static-build/batfish.config.js
@@ -2,6 +2,8 @@ const path = require('path');
 
 module.exports = () => {
   return {
+    siteBasePath: 'spa',
+    spa: true,
     stylesheets: [path.join(__dirname, 'src/style.css')],
     webpackStaticStubReactComponent: [path.join(__dirname, 'src/app.js')],
     staticHtmlInlineDeferCss: false
diff --git a/src/node/get-pages-data.js b/src/node/get-pages-data.js
index bb76a54..44db856 100644
--- a/src/node/get-pages-data.js
+++ b/src/node/get-pages-data.js
@@ -97,7 +97,11 @@ function getPagesData(
       return Promise.all(pageFilePaths.map(registerPage));
     })
     .then(() => {
-      if (!pagesData['/404/'] && !batfishConfig.production) {
+      if (
+        !pagesData['/404/'] &&
+        !batfishConfig.production &&
+        !batfishConfig.spa
+      ) {
         pagesData['/404/'] = {
           filePath: path.join(__dirname, '../webpack/default-not-found.js'),
           path: '/404/',


Test patch:
diff --git a/test/fixtures/get-pages-data-spa/index.js b/test/fixtures/get-pages-data-spa/index.js
new file mode 100644
index 0000000..5dc93fa
--- /dev/null
+++ b/test/fixtures/get-pages-data-spa/index.js
@@ -0,0 +1,1 @@
+// Nothing to see
diff --git a/test/get-pages-data.test.js b/test/get-pages-data.test.js
index ac59d85..5ce7ee7 100644
--- a/test/get-pages-data.test.js
+++ b/test/get-pages-data.test.js
@@ -199,6 +199,17 @@ describe('getPagesData', () => {
     });
   });
 
+  test('does not include the default 404 page in SPA mode', () => {
+    const config = validateConfig({
+      pagesDirectory: path.join(__dirname, 'fixtures/get-pages-data-spa'),
+      spa: true,
+      production: false
+    });
+    return getPagesData(config).then(result => {
+      expect(result['/404/']).toBeUndefined();
+    });
+  });
+
   test('does not include the default 404 page if there is a custom 404 JS page', () => {
     const config = validateConfig({
       pagesDirectory: path.join(__dirname, 'fixtures/get-pages-data-404-js')
Repository: mapbox/batfish
Pull request #317 (2019-09-09 19:07:07)

increase maxAsyncRequests and maxInitialRequests
While rolling out Webpack 4 in Batfish, we hit a stopping point with mapbox-gl-js-docs where JavaScript would run out of memory on `build`.

* We fixed one problem where the site was burning memory to generate the stats.json file. #307 
* The build script appears to fail at the terser plugin (minification) because the chunks are too large. This PR attempts to fix that by increasing `maxInitialRequests` and `maxAsyncRequests` to 10 - this will create more chunks at manageable size.
  - https://engineering.wingify.com/posts/demystifying-split-chunks-plugin/
  - https://engineering.seagroup.com/shopee-webpack4/

Testing to do:

* [x] mapbox-gl-js-docs, start and build/serve-static
* [x] android-docs, start and build/serve-static
* [x] traffic-data-docs, start and build/serve-static
* [x] open built site in IE11
* [x] test examples/


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27dbc07..985d75f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## Master
+
+- **Fix:** Increase `maxAsyncRequests` and `maxInitialRequests` in `splitChunks` to prevent JavaScript from running out of memory.
+
 ## 1.11.0
 
 - **Fix:** Prevent temporary build files from being written to the output directory.
diff --git a/src/node/create-webpack-config-client.js b/src/node/create-webpack-config-client.js
index 3a5cb24..3f6c6ee 100644
--- a/src/node/create-webpack-config-client.js
+++ b/src/node/create-webpack-config-client.js
@@ -123,6 +123,8 @@ function createWebpackConfigClient(
           name: 'manifest'
         },
         splitChunks: {
+          maxInitialRequests: 10,
+          maxAsyncRequests: 10,
           cacheGroups: {
             vendor: {
               chunks: 'initial',


Test patch:
diff --git a/test/__snapshots__/create-webpack-config-client.test.js.snap b/test/__snapshots__/create-webpack-config-client.test.js.snap
index 6a6b99c..819377c 100644
--- a/test/__snapshots__/create-webpack-config-client.test.js.snap
+++ b/test/__snapshots__/create-webpack-config-client.test.js.snap
@@ -39,6 +39,8 @@ Object {
           "test": "vendor",
         },
       },
+      "maxAsyncRequests": 10,
+      "maxInitialRequests": 10,
     },
   },
   "output": Object {
@@ -114,6 +116,8 @@ Object {
           "test": "vendor",
         },
       },
+      "maxAsyncRequests": 10,
+      "maxInitialRequests": 10,
     },
   },
   "output": Object {
@@ -192,6 +196,8 @@ Object {
           "test": "vendor",
         },
       },
+      "maxAsyncRequests": 10,
+      "maxInitialRequests": 10,
     },
   },
   "output": Object {
Repository: mapbox/batfish
Pull request #318 (2019-09-13 14:33:55)

Revert #317 
Per https://github.com/mapbox/batfish/pull/317#discussion_r323396653 the previous commit and release which increased `maxAsyncRequests` and `maxInitialRequests` in `splitChunks` to prevent JavaScript from running out of memory is not an ideal long term solution as it deteriorates performance on older devices. 

This PR reverts that commit. We'll be looking for a better solution that will not affect build times on the client and prevent running out of memory on `build`. 

In the meantime, we can increase node's memory with:

```
 "build": "NODE_OPTIONS=--max-old-space-size=2048 batfish build"
```


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 44bb6b5..59be96f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## Head
+
+- **Fix**: Revert increase `maxAsyncRequests` and `maxInitialRequests` in `splitChunks` to prevent JavaScript from running out of memory.
+
 ## 1.11.1
 
 - **Fix:** Increase `maxAsyncRequests` and `maxInitialRequests` in `splitChunks` to prevent JavaScript from running out of memory.
diff --git a/src/node/create-webpack-config-client.js b/src/node/create-webpack-config-client.js
index 3f6c6ee..3a5cb24 100644
--- a/src/node/create-webpack-config-client.js
+++ b/src/node/create-webpack-config-client.js
@@ -123,8 +123,6 @@ function createWebpackConfigClient(
           name: 'manifest'
         },
         splitChunks: {
-          maxInitialRequests: 10,
-          maxAsyncRequests: 10,
           cacheGroups: {
             vendor: {
               chunks: 'initial',


Test patch:
diff --git a/test/__snapshots__/create-webpack-config-client.test.js.snap b/test/__snapshots__/create-webpack-config-client.test.js.snap
index 819377c..6a6b99c 100644
--- a/test/__snapshots__/create-webpack-config-client.test.js.snap
+++ b/test/__snapshots__/create-webpack-config-client.test.js.snap
@@ -39,8 +39,6 @@ Object {
           "test": "vendor",
         },
       },
-      "maxAsyncRequests": 10,
-      "maxInitialRequests": 10,
     },
   },
   "output": Object {
@@ -116,8 +114,6 @@ Object {
           "test": "vendor",
         },
       },
-      "maxAsyncRequests": 10,
-      "maxInitialRequests": 10,
     },
   },
   "output": Object {
@@ -196,8 +192,6 @@ Object {
           "test": "vendor",
         },
       },
-      "maxAsyncRequests": 10,
-      "maxInitialRequests": 10,
     },
   },
   "output": Object {
Repository: mapbox/batfish
Pull request #364 (2021-11-17 20:43:42)

Skip urls that begin with `%23clip` in postcss-absolute-urls
We found a bug where the Mapbox logo in Firefox appears warped:

![image](https://user-images.githubusercontent.com/2180540/142279236-d7012d71-6485-4f08-b977-230c00ed6092.png)

This is caused by postcss-absolute-urls appending the stylesheet url to `mask`. This PR will prevent the plugin from add an absolute url path to urls that begin with `%23clip`.

To see the bug in action, check out the snapshot in 9f829ca and then see how it removes the absolute url from `mask` in the snapshot: 6a9db10


Patch:
diff --git a/src/node/postcss-absolute-urls.js b/src/node/postcss-absolute-urls.js
index 4757f28..166d1e4 100644
--- a/src/node/postcss-absolute-urls.js
+++ b/src/node/postcss-absolute-urls.js
@@ -8,7 +8,7 @@ const postcssUrl = require('postcss-url');
 // PostCSS plugin that transforms all the URLs in some CSS to absolute URLs.
 function postcssAbsoluteUrls(options: { stylesheetUrl: string }): Function {
   const transformUrl = (originalUrl: string): string => {
-    if (/^data:/.test(originalUrl)) return originalUrl;
+    if (/^data:|^%23clip/.test(originalUrl)) return originalUrl;
     return url.resolve(options.stylesheetUrl, originalUrl);
   };
 


Test patch:
diff --git a/test/__snapshots__/postcss-absolute-urls.test.js.snap b/test/__snapshots__/postcss-absolute-urls.test.js.snap
index 4328912..bc0cd56 100644
--- a/test/__snapshots__/postcss-absolute-urls.test.js.snap
+++ b/test/__snapshots__/postcss-absolute-urls.test.js.snap
@@ -1,5 +1,20 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
+exports[`postcssAbsoluteUrls do not add absolute url to \`mask\` 1`] = `
+"
+    a.mapboxgl-ctrl-logo {
+      width: 88px;
+      height: 23px;
+      margin: 0 0 -4px -4px;
+      display: block;
+      background-repeat: no-repeat;
+      cursor: pointer;
+      overflow: hidden;
+      background-image: url(\\"data:image/svg+xml;charset=utf-8,%3Csvg mask='url(%23clip)'\\");
+    }    
+    "
+`;
+
 exports[`postcssAbsoluteUrls works 1`] = `
 "
       @font-face {
diff --git a/test/postcss-absolute-urls.test.js b/test/postcss-absolute-urls.test.js
index 7e76bef..09869ff 100644
--- a/test/postcss-absolute-urls.test.js
+++ b/test/postcss-absolute-urls.test.js
@@ -27,4 +27,30 @@ describe('postcssAbsoluteUrls', () => {
         expect(result.css).toMatchSnapshot();
       });
   });
+
+  test('do not add absolute url to `mask`', () => {
+    const css = `
+    a.mapboxgl-ctrl-logo {
+      width: 88px;
+      height: 23px;
+      margin: 0 0 -4px -4px;
+      display: block;
+      background-repeat: no-repeat;
+      cursor: pointer;
+      overflow: hidden;
+      background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg mask='url(%23clip)'");
+    }    
+    `;
+
+    return postcss()
+      .use(
+        postcssAbsoluteUrls({
+          stylesheetUrl: '/playground/assets/'
+        })
+      )
+      .process(css, { from: undefined })
+      .then((result) => {
+        expect(result.css).toMatchSnapshot();
+      });
+  });
 });