Skip to content

Commit c3f2277

Browse files
Update Node version to 16 and fix other config / API usage for newly-broken deps (#6775)
* Update Node version to 16 * Explicitly drop the `node:process` module in the Playground's webpack config * Fix pixi webpack config * Correctly set htmlparser2 in Cheerio
1 parent e2cbd5b commit c3f2277

File tree

12 files changed

+32
-13
lines changed

12 files changed

+32
-13
lines changed

.github/workflows/lint-js.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setting up Node.js
1717
uses: actions/setup-node@v4
1818
with:
19-
node-version: 14
19+
node-version: 16
2020
cache: npm
2121

2222
- name: Installing Node.js packages

.github/workflows/lint-yaml.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setting up Node.js
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 14
21+
node-version: 16
2222
cache: npm
2323

2424
- name: Installing Node.js packages

.github/workflows/release-static-production.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Setting up Node.js
3131
uses: actions/setup-node@v4
3232
with:
33-
node-version: 14
33+
node-version: 16
3434
cache: npm
3535

3636
- name: Installing Node.js packages
@@ -53,7 +53,7 @@ jobs:
5353
- name: Setting up Node.js
5454
uses: actions/setup-node@v4
5555
with:
56-
node-version: 14
56+
node-version: 16
5757
cache: npm
5858

5959
- name: Installing Node.js packages
@@ -104,7 +104,7 @@ jobs:
104104
- name: Setting up Node.js
105105
uses: actions/setup-node@v4
106106
with:
107-
node-version: 14
107+
node-version: 16
108108
cache: npm
109109

110110
- name: Installing Node.js packages
@@ -154,7 +154,7 @@ jobs:
154154
- name: Setting up Node.js
155155
uses: actions/setup-node@v4
156156
with:
157-
node-version: 14
157+
node-version: 16
158158
cache: npm
159159

160160
- name: Installing Node.js packages

.github/workflows/test-platform.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setting up Node.js
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 14
21+
node-version: 16
2222
cache: npm
2323

2424
- name: Installing Node.js packages

.github/workflows/test-playground.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Setting up Node.js
1919
uses: actions/setup-node@v4
2020
with:
21-
node-version: 14
21+
node-version: 16
2222
cache: npm
2323

2424
- name: Installing Node.js packages

Dockerfile.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN \
1111
rm -rf /var/lib/apt/lists/*
1212

1313
RUN \
14-
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
14+
curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
1515
apt-get install -y nodejs && \
1616
npm i -g npm && \
1717
npm install -g gulp

gulpfile.js/staticify.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const {
3636
FORMAT_WEBSITES,
3737
SUPPORTED_FORMATS,
3838
} = require('@lib/amp/formatHelper.js');
39+
const {cheerioOptions} = require('../platform/lib/common/cheerioOptions');
3940
const coursesPath = '/documentation/courses';
4041
const coursesRegex = new RegExp(`^(.+)(?:${coursesPath})(.*)$`);
4142

@@ -208,7 +209,7 @@ async function staticify(done) {
208209
through.obj(function (file, enc, callback) {
209210
let renderedPage = file.contents.toString();
210211

211-
const $ = Cheerio.load(renderedPage);
212+
const $ = Cheerio.load(renderedPage, cheerioOptions);
212213
const $links = $('.nav-link');
213214
const $levelToggle = $('.toggle-button input');
214215

pixi/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ module.exports = (env, argv) => {
144144
},
145145

146146
devServer: {
147-
writeToDisk: true,
147+
devMiddleware: {
148+
writeToDisk: true,
149+
},
148150
},
149151
};
150152
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
/** @type {import('cheerio').CheerioOptions} */
3+
cheerioOptions: {
4+
// Simply setting an `xml` key here forces Cheerio to use htmlparser2 instead of the more strict parse5.
5+
// https://cheerio.js.org/docs/advanced/configuring-cheerio#parsing-xml-with-htmlparser2
6+
xml: {
7+
// Our tests were written with this setting in mind.
8+
decodeEntities: false,
9+
// This indicates that we expect to parse HTML, not XML.
10+
// https://cheerio.js.org/docs/advanced/configuring-cheerio#using-htmlparser2-for-html
11+
xmlMode: false,
12+
},
13+
},
14+
};

platform/lib/format-transform/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const amphtmlValidator = require('amphtml-validator');
1919
const {htmlContent} = require('@lib/utils/cheerioHelper');
2020
const config = require('@lib/config.js');
2121
const formats = require('./formats');
22+
const {cheerioOptions} = require('../common/cheerioOptions');
2223

2324
const host = config.hosts.platform;
2425
const FORMATS_REGEXP = /@formats\(([^)]+)\)/;
@@ -49,7 +50,7 @@ class FormatTransform {
4950
throw new Error(`Unsupported transform format: ${target}`);
5051
}
5152
const {transforms, validatorRuntime} = this.formats[target];
52-
const $ = cheerio.load(input, {decodeEntities: false});
53+
const $ = cheerio.load(input, cheerioOptions);
5354
this.applyCommentFormatFilters_($, target);
5455
for (const selector of Object.keys(transforms)) {
5556
const elements = $(selector);

0 commit comments

Comments
 (0)