From 06598a0c000a217bd36950f9507c47f191d7fe8a Mon Sep 17 00:00:00 2001 From: Guillaume NICOLAS Date: Fri, 24 Nov 2023 10:25:16 +0100 Subject: [PATCH] fix(TDP-12694): jest and cdn script configs broken after pnpm use-case (#5006) --- .changeset/little-mangos-allow.md | 5 +++++ .changeset/tidy-peas-dress.md | 5 +++++ tools/scripts-config-cdn/cdn.js | 2 +- tools/scripts-config-jest/__tests__/utils.test.js | 15 +++++++++++++++ tools/scripts-config-jest/utils.js | 4 ++-- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .changeset/little-mangos-allow.md create mode 100644 .changeset/tidy-peas-dress.md create mode 100644 tools/scripts-config-jest/__tests__/utils.test.js diff --git a/.changeset/little-mangos-allow.md b/.changeset/little-mangos-allow.md new file mode 100644 index 00000000000..ccdf5aee99b --- /dev/null +++ b/.changeset/little-mangos-allow.md @@ -0,0 +1,5 @@ +--- +'@talend/scripts-config-cdn': patch +--- + +fix(TDP-12694): require valid package-lock file path diff --git a/.changeset/tidy-peas-dress.md b/.changeset/tidy-peas-dress.md new file mode 100644 index 00000000000..fbccaee3fb8 --- /dev/null +++ b/.changeset/tidy-peas-dress.md @@ -0,0 +1,5 @@ +--- +'@talend/scripts-config-jest': patch +--- + +fix(TDP-12694): broken applyBabelTransformOn after pnpm use-case diff --git a/tools/scripts-config-cdn/cdn.js b/tools/scripts-config-cdn/cdn.js index ab18a48bae0..0de8a48cba2 100644 --- a/tools/scripts-config-cdn/cdn.js +++ b/tools/scripts-config-cdn/cdn.js @@ -140,7 +140,7 @@ function getModulesFromLockFile(dir) { let infos = []; if (fs.existsSync(lockTypeMap.npm.path)) { - const packagelock = require(lockTypeMap.npm.lockfile); + const packagelock = require(lockTypeMap.npm.path); infos = getAllFlattenDependencies(packagelock) .map(({ name, version }) => moduleToCdn(name, version, { env: 'development' })) .map(addLocal); diff --git a/tools/scripts-config-jest/__tests__/utils.test.js b/tools/scripts-config-jest/__tests__/utils.test.js new file mode 100644 index 00000000000..5c1fcde8cf8 --- /dev/null +++ b/tools/scripts-config-jest/__tests__/utils.test.js @@ -0,0 +1,15 @@ +import { applyBabelTransformOn } from '../utils'; + +describe('utilities', () => { + describe('applyBabelTransformOn', () => { + it('should add babel transform directive', () => { + const config = { + transformIgnorePatterns: ['node_modules/(?!(?:.pnpm/)?(d3|internmap))'], + }; + applyBabelTransformOn(config, ['dexie']); + expect(config.transformIgnorePatterns[0]).toBe( + 'node_modules/(?!(?:.pnpm/)?(d3|internmap|dexie))', + ); + }); + }); +}); diff --git a/tools/scripts-config-jest/utils.js b/tools/scripts-config-jest/utils.js index 2f38fa81802..8e8ecd5a72e 100644 --- a/tools/scripts-config-jest/utils.js +++ b/tools/scripts-config-jest/utils.js @@ -1,7 +1,7 @@ function applyBabelTransformOn(config, pkgs) { config.transformIgnorePatterns[0] = config.transformIgnorePatterns[0].replace( - ')', - `|${pkgs.join('|')})`, + /(\)\)$)/, + `|${pkgs.join('|')}$1`, ); }