From 41ba7c3025ae2fcdda980b3cd968f00b49a05216 Mon Sep 17 00:00:00 2001 From: Michael Kriese Date: Wed, 13 Nov 2024 15:55:29 +0100 Subject: [PATCH] fix: overide `punycode` built-in module (#32502) --- lib/config-validator.ts | 1 + lib/punycode.cjs | 10 ++++++++++ lib/renovate.ts | 1 + package.json | 2 ++ pnpm-lock.yaml | 11 +++++++++++ 5 files changed, 25 insertions(+) create mode 100644 lib/punycode.cjs diff --git a/lib/config-validator.ts b/lib/config-validator.ts index bc298c6c23b0bd..c8ff6bfc4a564f 100644 --- a/lib/config-validator.ts +++ b/lib/config-validator.ts @@ -1,6 +1,7 @@ #!/usr/bin/env node // istanbul ignore file import 'source-map-support/register'; +import './punycode.cjs'; import { dequal } from 'dequal'; import { pathExists, readFile } from 'fs-extra'; import { configFileNames } from './config/app-strings'; diff --git a/lib/punycode.cjs b/lib/punycode.cjs new file mode 100644 index 00000000000000..40e97f8dcba0df --- /dev/null +++ b/lib/punycode.cjs @@ -0,0 +1,10 @@ +/** + * punycode workaround + * + * Load punycode.js module to cache and override node built-in. + * + * See + */ +// eslint-disable-next-line @typescript-eslint/no-require-imports +require('punycode/'); +require.cache.punycode = require.cache[require.resolve('punycode/')]; diff --git a/lib/renovate.ts b/lib/renovate.ts index 4a618b9a385f83..d60ae5b2d7dec1 100644 --- a/lib/renovate.ts +++ b/lib/renovate.ts @@ -1,6 +1,7 @@ #!/usr/bin/env node import 'source-map-support/register'; +import './punycode.cjs'; import { instrument, shutdown as telemetryShutdown } from './instrumentation'; // has to be imported before logger and other libraries which are instrumentalised import { logger } from './logger'; import { bootstrap } from './proxy'; diff --git a/package.json b/package.json index a07f8474824381..a7a00d8946b382 100644 --- a/package.json +++ b/package.json @@ -231,6 +231,7 @@ "parse-link-header": "2.0.0", "prettier": "3.3.3", "protobufjs": "7.4.0", + "punycode": "2.3.1", "redis": "4.7.0", "remark": "13.0.0", "remark-github": "10.1.0", @@ -300,6 +301,7 @@ "@types/ms": "0.7.34", "@types/node": "20.17.6", "@types/parse-link-header": "2.0.3", + "@types/punycode": "2.1.4", "@types/semver": "7.5.8", "@types/semver-stable": "3.0.2", "@types/semver-utils": "1.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9de7f7b455ce75..9dad89c1438b4b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -275,6 +275,9 @@ importers: protobufjs: specifier: 7.4.0 version: 7.4.0 + punycode: + specifier: 2.3.1 + version: 2.3.1 redis: specifier: 4.7.0 version: 4.7.0 @@ -472,6 +475,9 @@ importers: '@types/parse-link-header': specifier: 2.0.3 version: 2.0.3 + '@types/punycode': + specifier: 2.1.4 + version: 2.1.4 '@types/semver': specifier: 7.5.8 version: 7.5.8 @@ -2113,6 +2119,9 @@ packages: '@types/parse-link-header@2.0.3': resolution: {integrity: sha512-ffLAxD6Xqcf2gSbtEJehj8yJ5R/2OZqD4liodQvQQ+hhO4kg1mk9ToEZQPMtNTm/zIQj2GNleQbsjPp9+UQm4Q==} + '@types/punycode@2.1.4': + resolution: {integrity: sha512-trzh6NzBnq8yw5e35f8xe8VTYjqM3NE7bohBtvDVf/dtUer3zYTLK1Ka3DG3p7bdtoaOHZucma6FfVKlQ134pQ==} + '@types/responselike@1.0.3': resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} @@ -8641,6 +8650,8 @@ snapshots: '@types/parse-link-header@2.0.3': {} + '@types/punycode@2.1.4': {} + '@types/responselike@1.0.3': dependencies: '@types/node': 20.17.6