From fce937c930face7fbbcdf57b95dc9a9d13e115b9 Mon Sep 17 00:00:00 2001 From: Tessa Thornton Date: Thu, 12 Oct 2023 12:16:21 -0400 Subject: [PATCH] Revert "[CORL-2384] Upgrade to Node 18" --- .github/workflows/build-and-test.yml | 10 +- .github/workflows/build-test-deploy.yml | 8 +- Dockerfile | 7 +- client/.nvmrc | 2 +- client/config/webpackDevServer.config.ts | 5 +- client/package-lock.json | 669 +- client/package.json | 15 +- client/scripts/precommitLint.js | 4 +- client/scripts/start.ts | 20 +- client/src/core/build/createWebpackConfig.ts | 31 + client/src/core/client/embed/amp.html | 2 +- client/src/core/client/embed/index.html | 6 +- client/src/core/client/embed/story.html | 4 +- client/src/core/client/embed/storyAMP.html | 2 +- client/src/core/client/embed/storyButton.html | 4 +- client/src/types/terser-webpack-plugin.d.ts | 44 + server/.nvmrc | 2 +- server/config/jest/client.baseConfig.js | 11 + server/config/jest/server.cache.config.js | 19 +- server/config/jest/server.config.js | 19 +- server/package-lock.json | 14294 ++++++++-------- server/package.json | 38 +- server/scripts/generateEventDocs.ts | 2 +- server/scripts/precommitLint.js | 4 +- server/scripts/testServer.js | 1 - .../core/server/app/helpers/manifestLoader.ts | 2 +- .../request/__snapshots__/body.spec.ts.snap | 2 +- .../src/core/server/cron/scheduled/group.ts | 2 +- .../core/server/events/listeners/analytics.ts | 2 +- .../server/queue/tasks/mailer/processor.ts | 5 +- .../createServerWordListRegExp.spec.ts | 38 +- .../comments/pipeline/phases/tagMember.ts | 2 +- .../core/server/services/jwt/index.spec.ts | 3 +- .../services/stories/scraper/scraper.ts | 8 +- .../server/services/tenant/tenant.spec.ts | 4 +- .../services/users/permissions/index.ts | 2 +- 36 files changed, 7860 insertions(+), 7433 deletions(-) create mode 100644 client/src/types/terser-webpack-plugin.d.ts diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 67b407ed36..fb5e8be124 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,7 +14,7 @@ env: jobs: build-and-test: name: Build and Test - runs-on: coral-ci + runs-on: ubuntu-22.04 steps: - name: Checkout @@ -43,10 +43,10 @@ jobs: name: Define SHORT_SHA with commit short sha run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV - - name: Setup Node18.x + name: Setup Node14.x uses: actions/setup-node@v3 with: - node-version: '18.16.x' + node-version: '14.x' - name: Install npm 8 run: npm i -g npm@8.0.0 --registry=https://registry.npmjs.org @@ -108,7 +108,7 @@ jobs: npx @coralproject/package-version-lint - name: Run Server Unit Tests - run: cd server && npm run test:server -- --ci --reporters=default --reporters=jest-junit + run: cd server && npm run test:server -- --ci --runInBand --reporters=default --reporters=jest-junit - name: Run Client Stream Unit Tests run: cd client && npm run test:client:stream -- --ci --runInBand --reporters=default --reporters=jest-junit @@ -121,7 +121,7 @@ jobs: - name: Build env: - NODE_OPTIONS: "--max-old-space-size=14336" + NODE_OPTIONS: "--max-old-space-size=8192" run: sh scripts/build.sh - name: Verify Bundle Size diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index f7e5311c6a..893e15740d 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -17,7 +17,7 @@ env: jobs: build-and-test: name: Build, Test, and Deploy - runs-on: coral-ci + runs-on: ubuntu-22.04 steps: - name: Checkout @@ -51,10 +51,10 @@ jobs: name: Define RC_TAG run: echo "RC_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - name: Setup Node18.x + name: Setup Node14.x uses: actions/setup-node@v3 with: - node-version: '18.16.x' + node-version: '14.x' - name: Install npm 8 run: npm i -g npm@8.0.0 --registry=https://registry.npmjs.org @@ -121,7 +121,7 @@ jobs: - name: Build env: - NODE_OPTIONS: "--max-old-space-size=14336" + NODE_OPTIONS: "--max-old-space-size=8192" run: sh scripts/build.sh - name: Verify Bundle Size diff --git a/Dockerfile b/Dockerfile index de63efe1e7..68ce9fd9f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,9 @@ -FROM node:18-alpine +FROM node:14-alpine -ENV NODE_OPTIONS="--max-old-space-size=8192 --openssl-legacy-provider --no-experimental-fetch" +ENV NODE_OPTIONS=--max-old-space-size=8192 # Install build dependancies. -RUN apk --no-cache --update add g++ make git python3 \ - && rm -rf /var/cache/apk/* +RUN apk --no-cache add git python3 RUN npm install -g npm@8.0.0 diff --git a/client/.nvmrc b/client/.nvmrc index 3c032078a4..8351c19397 100644 --- a/client/.nvmrc +++ b/client/.nvmrc @@ -1 +1 @@ -18 +14 diff --git a/client/config/webpackDevServer.config.ts b/client/config/webpackDevServer.config.ts index ac44d03880..dff9ea177a 100644 --- a/client/config/webpackDevServer.config.ts +++ b/client/config/webpackDevServer.config.ts @@ -82,8 +82,7 @@ export default function ({ disableDotRule: true, rewrites: [], }, - allowedHosts: ["127.0.0.1:8080", "127.0.0.1:3000"], - public: "127.0.0.1:8080", + public: allowedHost, index: "embed.html", sockPort: devPort, proxy: [ @@ -106,7 +105,7 @@ export default function ({ "/graphiql", ].some((p) => p === lc || lc.startsWith(`${p}/`)); }, - target: `127.0.0.1:${serverPort}`, + target: `http://localhost:${serverPort}`, onError: (err, req, res) => { res.writeHead(500, { "Content-Type": "text/html", diff --git a/client/package-lock.json b/client/package-lock.json index 159e3f526f..939da05989 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -113,7 +113,7 @@ "@babel/preset-typescript": "^7.10.1", "@babel/runtime-corejs3": "^7.10.3", "@coralproject/npm-run-all": "^4.1.5", - "@coralproject/rte": "^2.2.4", + "@coralproject/rte": "^2.2.2", "@fluent/react": "^0.12.0", "@giphy/js-fetch-api": "^4.1.2", "@giphy/react-components": "^5.4.0", @@ -324,6 +324,7 @@ "strip-ansi": "^6.0.0", "style-loader": "^2.0.0", "subscriptions-transport-ws": "^0.9.16", + "terser-webpack-plugin": "^4.2.3", "thread-loader": "^2.1.3", "timekeeper": "^2.2.0", "ts-jest": "26.3.0", @@ -351,8 +352,8 @@ "whatwg-fetch": "^3.4.0" }, "engines": { - "node": "^18.16.0", - "npm": "8.0.0" + "node": "^14.18", + "npm": "^8.0.0" } }, "../common/dist": {}, @@ -2632,21 +2633,16 @@ } }, "node_modules/@coralproject/rte": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-2.2.4.tgz", - "integrity": "sha512-neIIoH6BarMZPzLGqVW4CkzD1t+CZrhvcQWjwMIW/Jv9txwSL7jCL/dMRysvXX+yXB7IJ5Pot57VI0SVQxFUEg==", + "version": "2.2.2", "dev": true, + "license": "Apache-2.0", "dependencies": { "classnames": "^2.2.6", "squire-rte": "1.11.0" }, - "engines": { - "node": "^18.16.0", - "npm": "^8.0.0" - }, "peerDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0" + "react": "^16.0.0", + "react-dom": "^16.0.0" } }, "node_modules/@csstools/convert-colors": { @@ -2896,6 +2892,11 @@ "@fluent/bundle": ">= 0.13.0" } }, + "node_modules/@gar/promisify": { + "version": "1.1.2", + "dev": true, + "license": "MIT" + }, "node_modules/@giphy/js-analytics": { "version": "4.0.7", "dev": true, @@ -7165,6 +7166,48 @@ "node": ">= 8" } }, + "node_modules/@npmcli/fs": { + "version": "1.1.0", + "dev": true, + "license": "ISC", + "dependencies": { + "@gar/promisify": "^1.0.1", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } + }, + "node_modules/@npmcli/fs/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@npmcli/fs/node_modules/semver": { + "version": "7.3.5", + "dev": true, + "license": "ISC", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@npmcli/fs/node_modules/yallist": { + "version": "4.0.0", + "dev": true, + "license": "ISC" + }, "node_modules/@npmcli/move-file": { "version": "1.1.2", "license": "MIT", @@ -42526,6 +42569,14 @@ "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", "dev": true }, + "node_modules/serialize-javascript": { + "version": "5.0.1", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/serve-index": { "version": "1.9.1", "dev": true, @@ -45097,6 +45148,351 @@ "node": ">=6.0.0" } }, + "node_modules/terser-webpack-plugin": { + "version": "4.2.3", + "dev": true, + "license": "MIT", + "dependencies": { + "cacache": "^15.0.5", + "find-cache-dir": "^3.3.1", + "jest-worker": "^26.5.0", + "p-limit": "^3.0.2", + "schema-utils": "^3.0.0", + "serialize-javascript": "^5.0.1", + "source-map": "^0.6.1", + "terser": "^5.3.4", + "webpack-sources": "^1.4.3" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^4.0.0 || ^5.0.0" + } + }, + "node_modules/terser-webpack-plugin/node_modules/cacache": { + "version": "15.3.0", + "dev": true, + "license": "ISC", + "dependencies": { + "@npmcli/fs": "^1.0.0", + "@npmcli/move-file": "^1.0.1", + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "glob": "^7.1.4", + "infer-owner": "^1.0.4", + "lru-cache": "^6.0.0", + "minipass": "^3.1.1", + "minipass-collect": "^1.0.2", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.2", + "mkdirp": "^1.0.3", + "p-map": "^4.0.0", + "promise-inflight": "^1.0.1", + "rimraf": "^3.0.2", + "ssri": "^8.0.1", + "tar": "^6.0.2", + "unique-filename": "^1.1.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/terser-webpack-plugin/node_modules/chownr": { + "version": "2.0.0", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/terser-webpack-plugin/node_modules/commander": { + "version": "2.20.3", + "dev": true, + "license": "MIT" + }, + "node_modules/terser-webpack-plugin/node_modules/find-cache-dir": { + "version": "3.3.1", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/terser-webpack-plugin/node_modules/find-up": { + "version": "4.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/glob": { + "version": "7.2.0", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/terser-webpack-plugin/node_modules/locate-path": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/lru-cache": { + "version": "6.0.0", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser-webpack-plugin/node_modules/make-dir": { + "version": "3.0.2", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser-webpack-plugin/node_modules/mkdirp": { + "version": "1.0.4", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser-webpack-plugin/node_modules/p-limit": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser-webpack-plugin/node_modules/p-locate": { + "version": "4.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser-webpack-plugin/node_modules/p-map": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "aggregate-error": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser-webpack-plugin/node_modules/p-try": { + "version": "2.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/terser-webpack-plugin/node_modules/path-exists": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/pkg-dir": { + "version": "4.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/rimraf": { + "version": "3.0.2", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/terser-webpack-plugin/node_modules/schema-utils": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/terser-webpack-plugin/node_modules/semver": { + "version": "6.3.0", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/terser-webpack-plugin/node_modules/source-map": { + "version": "0.6.1", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/terser-webpack-plugin/node_modules/ssri": { + "version": "8.0.1", + "dev": true, + "license": "ISC", + "dependencies": { + "minipass": "^3.1.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/terser": { + "version": "5.10.0", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "acorn": "^8.5.0" + }, + "peerDependenciesMeta": { + "acorn": { + "optional": true + } + } + }, + "node_modules/terser-webpack-plugin/node_modules/terser/node_modules/source-map": { + "version": "0.7.3", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 8" + } + }, + "node_modules/terser-webpack-plugin/node_modules/webpack-sources": { + "version": "1.4.3", + "dev": true, + "license": "MIT", + "dependencies": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + }, + "node_modules/terser-webpack-plugin/node_modules/yallist": { + "version": "4.0.0", + "dev": true, + "license": "ISC" + }, "node_modules/terser/node_modules/commander": { "version": "2.20.3", "dev": true, @@ -50822,9 +51218,7 @@ } }, "@coralproject/rte": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/@coralproject/rte/-/rte-2.2.4.tgz", - "integrity": "sha512-neIIoH6BarMZPzLGqVW4CkzD1t+CZrhvcQWjwMIW/Jv9txwSL7jCL/dMRysvXX+yXB7IJ5Pot57VI0SVQxFUEg==", + "version": "2.2.2", "dev": true, "requires": { "classnames": "^2.2.6", @@ -51006,6 +51400,10 @@ "dev": true, "requires": {} }, + "@gar/promisify": { + "version": "1.1.2", + "dev": true + }, "@giphy/js-analytics": { "version": "4.0.7", "dev": true, @@ -54122,6 +54520,34 @@ "fastq": "^1.6.0" } }, + "@npmcli/fs": { + "version": "1.1.0", + "dev": true, + "requires": { + "@gar/promisify": "^1.0.1", + "semver": "^7.3.5" + }, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.3.5", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "dev": true + } + } + }, "@npmcli/move-file": { "version": "1.1.2", "requires": { @@ -78902,6 +79328,13 @@ } } }, + "serialize-javascript": { + "version": "5.0.1", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "serve-index": { "version": "1.9.1", "dev": true, @@ -80662,6 +81095,212 @@ } } }, + "terser-webpack-plugin": { + "version": "4.2.3", + "dev": true, + "requires": { + "cacache": "^15.0.5", + "find-cache-dir": "^3.3.1", + "jest-worker": "^26.5.0", + "p-limit": "^3.0.2", + "schema-utils": "^3.0.0", + "serialize-javascript": "^5.0.1", + "source-map": "^0.6.1", + "terser": "^5.3.4", + "webpack-sources": "^1.4.3" + }, + "dependencies": { + "cacache": { + "version": "15.3.0", + "dev": true, + "requires": { + "@npmcli/fs": "^1.0.0", + "@npmcli/move-file": "^1.0.1", + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "glob": "^7.1.4", + "infer-owner": "^1.0.4", + "lru-cache": "^6.0.0", + "minipass": "^3.1.1", + "minipass-collect": "^1.0.2", + "minipass-flush": "^1.0.5", + "minipass-pipeline": "^1.2.2", + "mkdirp": "^1.0.3", + "p-map": "^4.0.0", + "promise-inflight": "^1.0.1", + "rimraf": "^3.0.2", + "ssri": "^8.0.1", + "tar": "^6.0.2", + "unique-filename": "^1.1.1" + } + }, + "chownr": { + "version": "2.0.0", + "dev": true + }, + "commander": { + "version": "2.20.3", + "dev": true + }, + "find-cache-dir": { + "version": "3.3.1", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "4.1.0", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "glob": { + "version": "7.2.0", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lru-cache": { + "version": "6.0.0", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "make-dir": { + "version": "3.0.2", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "mkdirp": { + "version": "1.0.4", + "dev": true + }, + "p-limit": { + "version": "3.1.0", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + }, + "dependencies": { + "p-limit": { + "version": "2.3.0", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + } + } + }, + "p-map": { + "version": "4.0.0", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, + "p-try": { + "version": "2.2.0", + "dev": true + }, + "path-exists": { + "version": "4.0.0", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "rimraf": { + "version": "3.0.2", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "schema-utils": { + "version": "3.1.1", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + }, + "semver": { + "version": "6.3.0", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "dev": true + }, + "ssri": { + "version": "8.0.1", + "dev": true, + "requires": { + "minipass": "^3.1.1" + } + }, + "terser": { + "version": "5.10.0", + "dev": true, + "requires": { + "commander": "^2.20.0", + "source-map": "~0.7.2", + "source-map-support": "~0.5.20" + }, + "dependencies": { + "source-map": { + "version": "0.7.3", + "dev": true + } + } + }, + "webpack-sources": { + "version": "1.4.3", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" + } + }, + "yallist": { + "version": "4.0.0", + "dev": true + } + } + }, "test-exclude": { "version": "6.0.0", "dev": true, diff --git a/client/package.json b/client/package.json index 852a598327..6773fa946a 100644 --- a/client/package.json +++ b/client/package.json @@ -12,8 +12,8 @@ "url": "git://github.com/coralproject/talk.git" }, "engines": { - "node": "^18.16.0", - "npm": "8.0.0" + "node": "^14.18", + "npm": "^8.0.0" }, "bugs": "https://github.com/coralproject/talk/issues", "contributors": [ @@ -21,10 +21,10 @@ ], "description": "A better commenting experience from Vox Media.", "scripts": { - "build:client": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" ts-node --transpile-only ./scripts/build.ts", - "build:development": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development npm-run-all generate --parallel build:client", + "build:client": "ts-node --transpile-only ./scripts/build.ts", + "build:development": "NODE_ENV=development npm-run-all generate --parallel build:client", "build:withProfiler": "NODE_ENV=production REACT_PROFILER=true npm-run-all generate --parallel build:client", - "build": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=production npm-run-all generate-persist --parallel build:client", + "build": "NODE_ENV=production npm-run-all generate-persist --parallel build:client", "docs:css-variables": "ts-node ./scripts/generateCSSVariablesDocs.ts ./src/core/client/ui/theme/streamVariables.ts ./CSS_VARIABLES.md", "docs:events": "ts-node ./scripts/generateEventDocs.ts ./src/core/client/stream/events.ts ./CLIENT_EVENTS.md", "doctoc": "doctoc --maxlevel=3 --title '## Table of Contents' CLIENT_EVENTS.md ../CONTRIBUTING.md", @@ -54,7 +54,7 @@ "tscheck:client": "tsc --project ./src/core/client/tsconfig.json --noEmit", "tscheck:scripts": "tsc --project ./tsconfig.json --noEmit", "tscheck": "npm-run-all --parallel tscheck:*", - "watch": "NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\" NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" + "watch": "NODE_ENV=development ts-node --transpile-only ./scripts/watcher/bin/watcher.ts --config ./config/watcher.ts" }, "license": "Apache-2.0", "dependencies": { @@ -162,7 +162,7 @@ "@babel/preset-typescript": "^7.10.1", "@babel/runtime-corejs3": "^7.10.3", "@coralproject/npm-run-all": "^4.1.5", - "@coralproject/rte": "^2.2.4", + "@coralproject/rte": "^2.2.2", "@fluent/react": "^0.12.0", "@giphy/js-fetch-api": "^4.1.2", "@giphy/react-components": "^5.4.0", @@ -373,6 +373,7 @@ "strip-ansi": "^6.0.0", "style-loader": "^2.0.0", "subscriptions-transport-ws": "^0.9.16", + "terser-webpack-plugin": "^4.2.3", "thread-loader": "^2.1.3", "timekeeper": "^2.2.0", "ts-jest": "26.3.0", diff --git a/client/scripts/precommitLint.js b/client/scripts/precommitLint.js index 140103e604..ebb883f587 100644 --- a/client/scripts/precommitLint.js +++ b/client/scripts/precommitLint.js @@ -26,12 +26,12 @@ sgf((err, results) => { const eslintFiles = []; for (const item of results) { - const { filename, status } = item; + const { filename } = item; // only include valid, filtered extensions // this is primarily to keep eslint rampaging // over non-source files - if (!matchesExtension(extensions, filename) || status === "Deleted") { + if (!matchesExtension(extensions, filename)) { continue; } diff --git a/client/scripts/start.ts b/client/scripts/start.ts index 348b4dc2bb..26656a4678 100644 --- a/client/scripts/start.ts +++ b/client/scripts/start.ts @@ -1,18 +1,19 @@ #!/usr/bin/env ts-node -import chalk from "chalk"; import dotenv from "dotenv"; + +// Apply all the configuration provided in the .env file if it isn't already in +// the environment. +dotenv.config(); + +import chalk from "chalk"; import webpack from "webpack"; import WebpackDevServer from "webpack-dev-server"; +import { createCompiler, prepareUrls } from "./WebpackDevServerUtils"; import createDevServerConfig from "../config/webpackDevServer.config"; import config from "../src/core/build/config"; import createWebpackConfig from "../src/core/build/createWebpackConfig"; -import { createCompiler, prepareUrls } from "./WebpackDevServerUtils"; - -// Apply all the configuration provided in the .env file if it isn't already in -// the environment. -dotenv.config(); /* eslint-disable no-console */ @@ -31,7 +32,6 @@ process.on("unhandledRejection", (err) => { }); const PORT = config.get("dev_port"); -const SERVER_PORT = 3000; const HOST = "0.0.0.0"; if (process.env.HOST) { @@ -78,7 +78,7 @@ const compiler = createCompiler({ // Serve webpack assets generated by the compiler over a web sever. const serverConfig = createDevServerConfig({ allowedHost: urls.lanUrlForConfig, - serverPort: SERVER_PORT, + serverPort: config.get("port"), devPort: PORT, publicPath: webpackConfig[0].output!.publicPath!, }); @@ -94,7 +94,9 @@ devServer.listen(PORT, HOST, (err: Error) => { return console.log(err); } console.log(chalk.cyan("Starting the development server...\n")); - console.log(chalk.yellow(`devPort: ${PORT}, serverPort: ${SERVER_PORT}`)); + console.log( + chalk.yellow(`devPort: ${PORT}, serverPort: ${serverConfig.port}`) + ); }); ["SIGINT", "SIGTERM"].forEach((sig: any) => { diff --git a/client/src/core/build/createWebpackConfig.ts b/client/src/core/build/createWebpackConfig.ts index cb50e7534b..a0b2fc30f2 100644 --- a/client/src/core/build/createWebpackConfig.ts +++ b/client/src/core/build/createWebpackConfig.ts @@ -9,6 +9,7 @@ import { identity, uniq } from "lodash"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import path from "path"; import WatchMissingNodeModulesPlugin from "react-dev-utils/WatchMissingNodeModulesPlugin"; +import TerserPlugin from "terser-webpack-plugin"; import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"; import webpack, { Configuration, Plugin } from "webpack"; import WebpackAssetsManifest from "webpack-assets-manifest"; @@ -192,6 +193,36 @@ export default function createWebpackConfig( chunks: config.get("disableChunkSplitting") ? "async" : "all", }, minimize: minimize || treeShake, + minimizer: [ + // Minify the code. + new TerserPlugin({ + terserOptions: { + compress: minimize + ? {} + : { + defaults: false, + dead_code: true, + pure_getters: true, + side_effects: true, + unused: true, + passes: 2, + }, + mangle: minimize, + keep_classnames: profilerSupport, + keep_fnames: profilerSupport, + output: { + comments: !minimize, + // Turned on because emoji and regex is not minified properly using default + // https://github.com/facebookincubator/create-react-app/issues/2488 + ascii_only: true, + }, + safari10: true, + }, + cache: enableBuildCache, + parallel: 4, + sourceMap: !disableSourcemaps, + }), + ], }, devtool, // These are the "entry points" to our application. diff --git a/client/src/core/client/embed/amp.html b/client/src/core/client/embed/amp.html index 1e361ef214..6dfe2c1d5c 100644 --- a/client/src/core/client/embed/amp.html +++ b/client/src/core/client/embed/amp.html @@ -16,7 +16,7 @@