Skip to content

Commit 51d6a66

Browse files
authored
Merge pull request #680 from namecheap/feature/updatenode22
ilc: update to node 22
2 parents 31f89a8 + c1a9a22 commit 51d6a66

File tree

97 files changed

+12099
-4417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+12099
-4417
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
push:
55
branches:
6-
- master
6+
- '**'
77
tags-ignore:
88
- '**'
99
pull_request:

docs/multi-domains.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ ILC automatically updates canonical tags during client-side navigation.
185185

186186
## Additional information
187187

188-
- ILC detects a domain from the [**request.hostname** of Fastify](https://www.fastify.io/docs/latest/Reference/Request/) and checks whether this hostname is listed in the **Router domains**.
188+
- ILC detects a domain from the [**request.host** of Fastify](https://www.fastify.io/docs/latest/Reference/Request/) and checks whether this hostname is listed in the **Router domains**.
189189
- Each registered domain in the **Router domains** has its own set of routes that do not overlap.
190190
- For routes, the domain is optional. If the request goes from the domain that is not listed in the **Router domains**, the routes for the request will stay unassigned.

ilc/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
registry=https://registry.npmjs.org
2+
engine-strict=true

ilc/Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
FROM node:20.8.0-alpine
1+
FROM node:22-alpine
22

33
RUN apk update && apk add --no-cache bash git openssh python3 make g++ findutils
44

5-
# Legacy infrastructure support
6-
RUN npm install -g stdout-mq@^2.4.0
7-
85
WORKDIR /codebase
96

107
COPY package-lock.json package.json /codebase/
11-
RUN npm ci --no-package-lock --ignore-scripts
12-
RUN npm rebuild @newrelic/native-metrics
8+
RUN npm ci --prefer-offline --no-fund
9+
# Integrity check. Package @newrelic/native-metrics is an optional dependency and may be not installed on alpine
10+
RUN npm ls @newrelic/native-metrics
1311

1412
COPY ./ /codebase
1513

ilc/babel.config.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
/**
2+
* NOTE: We override `modules` to "commonjs" for Karma tests only.
3+
*
4+
* Our production build outputs ES modules (ESM). In ESM, named exports are
5+
* live, read-only bindings and the module namespace object is non-writable
6+
* and non-configurable by specification.
7+
*
8+
* Sinon stubs work by redefining properties on imported modules. When code
9+
* is compiled as ESM, attempting to stub a named export throws errors like:
10+
*
11+
* "Descriptor for property <fn> is non-configurable and non-writable"
12+
*
13+
* Forcing CommonJS here makes exports mutable again (matching the old
14+
* ts-loader behavior) so Sinon can safely stub exported functions in tests.
15+
*
16+
* This override is intentionally limited to Karma/test builds.
17+
* Production bundles remain ESM.
18+
*/
19+
const modules = process.env.NODE_ENV === 'test' ? 'commonjs' : 'auto';
20+
121
module.exports = {
2-
presets: ['@babel/preset-env'],
22+
presets: [['@babel/preset-env', { modules }], '@babel/preset-typescript'],
323
plugins: [
4-
'@babel/plugin-syntax-dynamic-import',
5-
'@babel/plugin-proposal-class-properties',
6-
'@babel/plugin-proposal-private-methods',
724
'babel-plugin-transform-async-to-promises',
825
[
926
'@babel/plugin-transform-for-of',
@@ -26,7 +43,7 @@ module.exports = {
2643
[
2744
'istanbul',
2845
{
29-
exclude: ['**/*.spec.js', 'tests/**'],
46+
exclude: ['**/*.spec.js', '**/*.spec.ts', 'tests/**', 'common/**/test/**'],
3047
},
3148
],
3249
],

ilc/build/webpack.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const fs = require('fs');
33
const path = require('path');
44
const { DefinePlugin, BannerPlugin, Compilation } = require('webpack');
55
const { DuplicateIlcPluginsWebpackPlugin, ResolveIlcDefaultPluginsWebpackPlugin } = require('ilc-plugins-sdk/webpack');
6+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
7+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
68

79
const { Environment } = require('../common/Environment');
810
const ilcPluginsPath = path.resolve(__dirname, '../../node_modules/');
@@ -23,12 +25,11 @@ module.exports = {
2325
rules: [
2426
{
2527
test: /\.(js|ts)$/,
26-
use: {
27-
loader: 'ts-loader',
28-
options: {
29-
configFile: 'tsconfig.client.json',
28+
use: [
29+
{
30+
loader: 'babel-loader',
3031
},
31-
},
32+
],
3233
exclude: /node_modules/,
3334
},
3435
{ parser: { System: false } },
@@ -58,6 +59,15 @@ module.exports = {
5859
new DefinePlugin({
5960
LEGACY_PLUGINS_DISCOVERY_ENABLED: JSON.stringify(environment.isLegacyPluginsDiscoveryEnabled()),
6061
}),
62+
new ForkTsCheckerWebpackPlugin({
63+
typescript: {
64+
configFile: 'tsconfig.client.json',
65+
},
66+
}),
67+
new BundleAnalyzerPlugin({
68+
analyzerMode: 'static',
69+
openAnalyzer: false,
70+
}),
6171
],
6272
devtool: 'source-map',
6373
externals: [],

ilc/build/webpack.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ const config = {
2222
},
2323
};
2424

25-
config.module.rules.push({
26-
test: /\.(js|ts)$/,
27-
/**
28-
* Control coveraage files
29-
*/
30-
exclude: /(node_modules|\.spec\.(js|ts)$|tests\/)/,
31-
loader: '@jsdevtools/coverage-istanbul-loader',
32-
enforce: 'post',
33-
options: { esModules: true },
34-
});
35-
3625
config.resolve.alias['nock'] = false;
3726
config.resolve.alias['timers'] = false;
3827

ilc/client/AsyncBootUp.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default class AsyncBootUp {
1010
#appsWaitingForSlot = {};
1111
#readySlots = [];
1212
#pageLoadingIsDone = false;
13+
#routingEventHandler;
1314

1415
constructor(logger = window.console, performance = window.performance) {
1516
this.#logger = logger;
@@ -21,7 +22,8 @@ export default class AsyncBootUp {
2122
}
2223

2324
window.ilcApps = { push: (id) => this.#markSlotAsReady(id) };
24-
window.addEventListener(singleSpaEvents.ROUTING_EVENT, () => (this.#afterRoutingEvent = true));
25+
this.#routingEventHandler = () => (this.#afterRoutingEvent = true);
26+
window.addEventListener(singleSpaEvents.ROUTING_EVENT, this.#routingEventHandler);
2527
}
2628

2729
async waitForSlot(slotName) {
@@ -87,6 +89,12 @@ export default class AsyncBootUp {
8789
return res;
8890
}
8991

92+
destroy() {
93+
if (this.#routingEventHandler) {
94+
window.removeEventListener(singleSpaEvents.ROUTING_EVENT, this.#routingEventHandler);
95+
}
96+
}
97+
9098
#markSlotAsReady = (id) => {
9199
setTimeout(() => {
92100
// All slots has been loaded

ilc/client/AsyncBootUp.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chai from 'chai';
1+
import * as chai from 'chai';
22
import sinon from 'sinon';
33
import html from 'nanohtml';
44

ilc/client/BundleLoader.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ interface MockRegistry {
2727
props?: Record<string, any>;
2828
wrappedWith?: string;
2929
kind?: string;
30+
ssr?: {
31+
src: string;
32+
};
33+
l10nManifest?: string;
3034
};
3135
};
3236
}

0 commit comments

Comments
 (0)