Commit 214ac59e6c4 for woocommerce

commit 214ac59e6c43fedc2060c28783f9cc5221b048b5
Author: Ján Mikláš <neosinner@gmail.com>
Date:   Thu Nov 26 13:00:27 2026 +0100

    Replace small dependencies in published WooCommerce packages (#71411)

    * Replace small dependencies in published WooCommerce packages

    * Remove stale CSV download types and clarify package changelogs

    * Test the CSV download with non-ASCII product text

    * Fix CSV export test formatting and browser globals

    * Keep the cookie library for reading the experiment anonymous ID.

    The inline parser returned a lone double quote as the anonymous ID where
    cookie 0.7.2 returns null, so restore the library and its typings and keep
    the new tests, plus a regression case for that value.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01NM9YXuFWofeyujZojqgDiD

    * Fall back to a default filename for CSV downloads without a name.

    FileSaver used "download" when the filename was empty; keep that behavior.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01NM9YXuFWofeyujZojqgDiD

    * Freeze the date per test in the CSV filename suite.

    The download tests restore real timers, so under randomized order the
    filename tests read today's date instead of the fixed one.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01NM9YXuFWofeyujZojqgDiD

    * Remove the ExPlat cookie test and changelog entry

    ---------

    Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/packages/js/components/changelog/wooplug-8151-dependency-cleanup b/packages/js/components/changelog/wooplug-8151-dependency-cleanup
new file mode 100644
index 00000000000..683d0bea490
--- /dev/null
+++ b/packages/js/components/changelog/wooplug-8151-dependency-cleanup
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Remove calendar polyfills and declare the sortable controls’ runtime dependency.
diff --git a/packages/js/components/package.json b/packages/js/components/package.json
index d5015f460ee..0b951a9003f 100644
--- a/packages/js/components/package.json
+++ b/packages/js/components/package.json
@@ -112,7 +112,6 @@
 		"@wordpress/viewport": "catalog:wp-min",
 		"canvas-confetti": "^1.9.2",
 		"clsx": "2.1.x",
-		"core-js": "^3.34.0",
 		"d3-axis": "^1.0.12",
 		"d3-format": "^1.4.5",
 		"d3-scale": "^2.2.2",
@@ -129,7 +128,8 @@
 		"prop-types": "^15.8.1",
 		"react-dates": "^21.8.0",
 		"react-transition-group": "^4.4.5",
-		"react-window": "^1.8.11"
+		"react-window": "^1.8.11",
+		"uuid": "^11.1.1"
 	},
 	"peerDependencies": {
 		"@types/react": "18.3.x",
@@ -164,7 +164,6 @@
 		"@types/lodash": "^4.14.202",
 		"@types/prop-types": "^15.7.11",
 		"@types/testing-library__jest-dom": "^5.14.9",
-		"@types/uuid": "^8.3.4",
 		"@types/wordpress__viewport": "catalog:wp-min",
 		"@woocommerce/eslint-config": "workspace:*",
 		"@woocommerce/eslint-plugin": "workspace:*",
@@ -188,7 +187,6 @@
 		"sass-loader": "catalog:tooling",
 		"ts-jest": "catalog:tooling",
 		"typescript": "catalog:tooling",
-		"uuid": "^11.1.1",
 		"webpack": "catalog:tooling",
 		"webpack-cli": "catalog:tooling"
 	},
diff --git a/packages/js/components/src/calendar/date-picker.js b/packages/js/components/src/calendar/date-picker.js
index 9dbd2e046e2..03597d2885d 100644
--- a/packages/js/components/src/calendar/date-picker.js
+++ b/packages/js/components/src/calendar/date-picker.js
@@ -1,8 +1,6 @@
 /**
  * External dependencies
  */
-import 'core-js/features/object/assign';
-import 'core-js/features/array/from';
 import { __, sprintf } from '@wordpress/i18n';
 import { createElement, Component } from '@wordpress/element';
 import { Dropdown, DatePicker as WpDatePicker } from '@wordpress/components';
diff --git a/packages/js/components/src/calendar/date-range.js b/packages/js/components/src/calendar/date-range.js
index e55f006092b..848aa9f7357 100644
--- a/packages/js/components/src/calendar/date-range.js
+++ b/packages/js/components/src/calendar/date-range.js
@@ -1,8 +1,6 @@
 /**
  * External dependencies
  */
-import 'core-js/features/object/assign';
-import 'core-js/features/array/from';
 import { __, sprintf } from '@wordpress/i18n';
 import clsx from 'clsx';
 import { createElement, Component, createRef } from '@wordpress/element';
diff --git a/packages/js/csv-export/changelog/wooplug-8151-dependency-cleanup b/packages/js/csv-export/changelog/wooplug-8151-dependency-cleanup
new file mode 100644
index 00000000000..7bdf8e6c045
--- /dev/null
+++ b/packages/js/csv-export/changelog/wooplug-8151-dependency-cleanup
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Use browser download APIs for CSV exports.
diff --git a/packages/js/csv-export/package.json b/packages/js/csv-export/package.json
index 5f914a18f2f..f89446b100f 100644
--- a/packages/js/csv-export/package.json
+++ b/packages/js/csv-export/package.json
@@ -59,8 +59,7 @@
 		"watch:build:project:esm": "node build.mjs --watch"
 	},
 	"dependencies": {
-		"@types/node": "^24.1.0",
-		"browser-filesaver": "^1.1.1"
+		"@types/node": "^24.1.0"
 	},
 	"devDependencies": {
 		"@babel/core": "catalog:tooling",
diff --git a/packages/js/csv-export/src/index.ts b/packages/js/csv-export/src/index.ts
index c74b589a29c..b0535c84c72 100644
--- a/packages/js/csv-export/src/index.ts
+++ b/packages/js/csv-export/src/index.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { saveAs } from 'browser-filesaver'; // TODO: Replace this with https://www.npmjs.com/package/file-saver since browser-filesaver is not maintained anymore.
-
 export type Header = {
 	label: string;
 	key: string;
@@ -137,7 +132,16 @@ export function generateCSVFileName(
  * @param {string} content  Contents of the file to download
  */
 export function downloadCSVFile( fileName: string, content: BlobPart ) {
-	const blob = new Blob( [ content ], { type: 'text/csv;charset=utf-8' } );
-
-	saveAs( blob, fileName );
+	// Preserve the UTF-8 byte order mark so spreadsheet apps read the encoding correctly.
+	const blob = new Blob( [ '\uFEFF', content ], {
+		type: 'text/csv;charset=utf-8',
+	} );
+	const url = URL.createObjectURL( blob );
+	const link = document.createElement( 'a' );
+	link.href = url;
+	link.download = fileName || 'download';
+	link.click();
+
+	// Browsers can begin reading the URL after the click handler has returned.
+	setTimeout( () => URL.revokeObjectURL( url ), 40_000 );
 }
diff --git a/packages/js/csv-export/src/test/index.ts b/packages/js/csv-export/src/test/index.ts
index 5205e192b60..d4aca7d4904 100644
--- a/packages/js/csv-export/src/test/index.ts
+++ b/packages/js/csv-export/src/test/index.ts
@@ -1,9 +1,4 @@
 /* eslint-disable jest/no-mocks-import */
-/**
- * External dependencies
- */
-import { saveAs } from 'browser-filesaver';
-
 /**
  * Internal dependencies
  */
@@ -16,10 +11,6 @@ import mockCSVData from './__mocks__/mock-csv-data';
 import mockHeaders from './__mocks__/mock-headers';
 import mockRows from './__mocks__/mock-rows';

-jest.mock( 'browser-filesaver', () => ( {
-	saveAs: jest.fn(),
-} ) );
-
 describe( 'generateCSVDataFromTable', () => {
 	it( 'should not crash when parameters are not arrays', () => {
 		// @ts-expect-error generateCSVDataFromTable() should only accept arrays.
@@ -87,7 +78,13 @@ describe( 'generateCSVDataFromTable', () => {
 } );

 describe( 'generateCSVFileName', () => {
-	jest.useFakeTimers().setSystemTime( new Date( '2024-12-23' ) );
+	beforeEach( () => {
+		jest.useFakeTimers().setSystemTime( new Date( '2024-12-23' ) );
+	} );
+
+	afterEach( () => {
+		jest.useRealTimers();
+	} );

 	it( 'should generate a file name with the date when no params are provided', () => {
 		const fileName = generateCSVFileName();
@@ -111,24 +108,86 @@ describe( 'generateCSVFileName', () => {
 } );

 describe( 'downloadCSVFile', () => {
-	it( "should download a CSV file name to users' browser", () => {
-		const fileName = 'test.csv';
-		downloadCSVFile( fileName, mockCSVData );
+	it( 'downloads UTF-8 CSV with the requested filename and releases the object URL', async () => {
+		const originalURL = window.URL;
+		const createObjectURL = jest.fn< string, [ Blob ] >(
+			() => 'blob:test'
+		);
+		const revokeObjectURL = jest.fn();
+		const click = jest
+			.spyOn( window.HTMLAnchorElement.prototype, 'click' )
+			.mockImplementation( function (
+				this: InstanceType< typeof window.HTMLAnchorElement >
+			) {
+				expect( this.download ).toBe( 'test.csv' );
+				expect( this.href ).toBe( 'blob:test' );
+			} );
+
+		jest.useFakeTimers();
+		window.URL = Object.assign( class extends originalURL {}, {
+			createObjectURL,
+			revokeObjectURL,
+		} );

-		// Get the Blob that was passed to saveAs
-		const [ blob ] = ( saveAs as jest.Mock ).mock.calls[ 0 ];
+		try {
+			const data = 'Product,Price\n商品 🛒 Café,19.99';
+			downloadCSVFile( 'test.csv', data );
+
+			expect( click ).toHaveBeenCalledTimes( 1 );
+			const [ blob ] = createObjectURL.mock.calls[ 0 ];
+			expect( blob.type ).toBe( 'text/csv;charset=utf-8' );
+
+			const bytes = await new Promise< Uint8Array >(
+				( resolve, reject ) => {
+					const reader = new window.FileReader();
+					reader.onload = () =>
+						resolve(
+							new Uint8Array( reader.result as ArrayBuffer )
+						);
+					reader.onerror = () => reject( reader.error );
+					reader.readAsArrayBuffer( blob );
+				}
+			);
+			expect( Array.from( bytes.slice( 0, 3 ) ) ).toEqual( [
+				239, 187, 191,
+			] );
+			expect( new TextDecoder().decode( bytes ) ).toBe( data );
+
+			expect( revokeObjectURL ).not.toHaveBeenCalled();
+			jest.runOnlyPendingTimers();
+			expect( revokeObjectURL ).toHaveBeenCalledWith( 'blob:test' );
+		} finally {
+			window.URL = originalURL;
+			click.mockRestore();
+			jest.useRealTimers();
+		}
+	} );

-		// Verify it's a Blob with the correct content
-		expect( blob ).toBeInstanceOf( Blob );
-		expect( blob.type ).toBe( 'text/csv;charset=utf-8' );
+	it( 'falls back to a default filename when none is given', () => {
+		const originalURL = window.URL;
+		let download: string | undefined;
+		const click = jest
+			.spyOn( window.HTMLAnchorElement.prototype, 'click' )
+			.mockImplementation( function (
+				this: InstanceType< typeof window.HTMLAnchorElement >
+			) {
+				download = this.download;
+			} );
+
+		jest.useFakeTimers();
+		window.URL = Object.assign( class extends originalURL {}, {
+			createObjectURL: () => 'blob:test',
+			revokeObjectURL: jest.fn(),
+		} );

-		// If you need to verify the content:
-		const reader = new FileReader();
-		reader.readAsText( blob );
-		reader.onload = () => {
-			expect( reader.result ).toBe( mockCSVData );
-		};
+		try {
+			downloadCSVFile( '', 'Product,Price' );

-		expect( saveAs ).toHaveBeenCalledWith( expect.any( Blob ), fileName );
+			expect( download ).toBe( 'download' );
+		} finally {
+			window.URL = originalURL;
+			click.mockRestore();
+			jest.useRealTimers();
+		}
 	} );
 } );
diff --git a/packages/js/csv-export/tsconfig.json b/packages/js/csv-export/tsconfig.json
index be24cae4c13..e711ed46c21 100644
--- a/packages/js/csv-export/tsconfig.json
+++ b/packages/js/csv-export/tsconfig.json
@@ -7,13 +7,11 @@
 		"declarationMap": true,
 		"declarationDir": "./build-types",
 		"typeRoots": [
-			"./typings",
 			"./node_modules/@types"
 		],
 		"composite": true
 	},
 	"include": [
-		"typings/**/*",
 		"src/**/*"
 	],
 	"exclude": [
diff --git a/packages/js/csv-export/typings/index.d.ts b/packages/js/csv-export/typings/index.d.ts
deleted file mode 100644
index 241b58c5296..00000000000
--- a/packages/js/csv-export/typings/index.d.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-declare module 'browser-filesaver' {
-	declare function FileSaver(data: Blob, filename: string, disableAutoBOM?: boolean): void;
-
-	export const saveAs: typeof FileSaver;
-}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ed364c0be3f..846a76dd637 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -804,9 +804,6 @@ importers:
       clsx:
         specifier: 2.1.x
         version: 2.1.1
-      core-js:
-        specifier: ^3.34.0
-        version: 3.49.0
       d3-axis:
         specifier: ^1.0.12
         version: 1.0.12
@@ -861,6 +858,9 @@ importers:
       react-window:
         specifier: ^1.8.11
         version: 1.8.11(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+      uuid:
+        specifier: ^11.1.1
+        version: 11.1.1
     devDependencies:
       '@babel/core':
         specifier: catalog:tooling
@@ -904,9 +904,6 @@ importers:
       '@types/testing-library__jest-dom':
         specifier: ^5.14.9
         version: 5.14.9
-      '@types/uuid':
-        specifier: ^8.3.4
-        version: 8.3.4
       '@types/wordpress__viewport':
         specifier: catalog:wp-min
         version: 5.5.3(react@18.3.1)
@@ -976,9 +973,6 @@ importers:
       typescript:
         specifier: catalog:tooling
         version: 5.7.3
-      uuid:
-        specifier: ^11.1.1
-        version: 11.1.1
       webpack:
         specifier: catalog:tooling
         version: 5.112.2(@swc/core@1.15.24)(esbuild@0.27.7)(postcss@8.5.26)(webpack-cli@5.1.4)
@@ -993,9 +987,6 @@ importers:
       '@types/node':
         specifier: ^24.1.0
         version: 24.12.2
-      browser-filesaver:
-        specifier: ^1.1.1
-        version: 1.1.1
     devDependencies:
       '@babel/core':
         specifier: catalog:tooling
@@ -9236,9 +9227,6 @@ packages:
   '@types/uglify-js@3.17.5':
     resolution: {integrity: sha512-TU+fZFBTBcXj/GpDpDaBmgWk/gn96kMZ+uocaFUlV2f8a6WdMzzI44QBCmGcCiYR0Y6ZlNRiyUyKKt5nl/lbzQ==}

-  '@types/uuid@8.3.4':
-    resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
-
   '@types/webpack-sources@3.2.3':
     resolution: {integrity: sha512-4nZOdMwSPHZ4pTEZzSp0AsTM4K7Qmu40UKW4tJDiOVs20UzYF9l+qUe4s0ftfN0pin06n+5cWWDJXH+sbhAiDw==}

@@ -12190,9 +12178,6 @@ packages:
   brcast@2.0.2:
     resolution: {integrity: sha512-Tfn5JSE7hrUlFcOoaLzVvkbgIemIorMIyoMr3TgvszWW7jFt2C9PdeMLtysYD9RU0MmU17b69+XJG1eRY2OBRg==}

-  browser-filesaver@1.1.1:
-    resolution: {integrity: sha512-UI4ps3bE/YXvGKlL7BoITvw8bE/SOt7YnvZeCyME7votTLxsDQ0ES0lvQdEWZMvO9aF5/66h+a3PGWn1KOblBA==}
-
   browserify-zlib@0.1.4:
     resolution: {integrity: sha512-19OEpq7vWgsH6WkvkBJQDFvJS1uPcbFOQ4v9CU839dO+ZZXUZO6XpE6hNCqvlIIj+4fZvRiJ6DsAQ382GwiyTQ==}

@@ -26959,8 +26944,6 @@ snapshots:
       source-map: 0.6.1
     optional: true

-  '@types/uuid@8.3.4': {}
-
   '@types/webpack-sources@3.2.3':
     dependencies:
       '@types/node': 24.12.2
@@ -34595,8 +34578,6 @@ snapshots:

   brcast@2.0.2: {}

-  browser-filesaver@1.1.1: {}
-
   browserify-zlib@0.1.4:
     dependencies:
       pako: 0.2.9