From 520dcb4842cc190a2e05dc6140ccedfee051af6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Smyrek?=
Date: Thu, 21 Nov 2024 13:26:39 +0100
Subject: [PATCH] Pass path to a dynamically imported file as `file://`
protocol URL to make it work in Windows.
---
.../lib/utils/executeinparallel.js | 8 +++++++-
.../tests/utils/executeinparallel.js | 8 ++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/packages/ckeditor5-dev-release-tools/lib/utils/executeinparallel.js b/packages/ckeditor5-dev-release-tools/lib/utils/executeinparallel.js
index 77ccd1b4e..e4fc77542 100644
--- a/packages/ckeditor5-dev-release-tools/lib/utils/executeinparallel.js
+++ b/packages/ckeditor5-dev-release-tools/lib/utils/executeinparallel.js
@@ -70,7 +70,13 @@ export default async function executeInParallel( options ) {
return createWorker( {
signal: signal || defaultAbortController.signal,
onPackageDone,
- workerData: { packages, callbackModule, taskOptions }
+ workerData: {
+ packages,
+ taskOptions,
+ // The callback module is dynamically imported inside worker script.
+ // To make it work in Windows, absolute path to a dynamically imported file must start with the "file:" protocol URL.
+ callbackModule: 'file://' + callbackModule
+ }
} );
} );
diff --git a/packages/ckeditor5-dev-release-tools/tests/utils/executeinparallel.js b/packages/ckeditor5-dev-release-tools/tests/utils/executeinparallel.js
index afcdcc0cc..8818a1188 100644
--- a/packages/ckeditor5-dev-release-tools/tests/utils/executeinparallel.js
+++ b/packages/ckeditor5-dev-release-tools/tests/utils/executeinparallel.js
@@ -105,11 +105,11 @@ describe( 'executeInParallel()', () => {
'utf-8'
);
expect( firstWorker.workerData ).toBeInstanceOf( Object );
- expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', '/home/ckeditor/uuid-4.mjs' );
+ expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'file:///home/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'packages' );
expect( secondWorker.workerData ).toBeInstanceOf( Object );
- expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', '/home/ckeditor/uuid-4.mjs' );
+ expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'file:///home/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'packages' );
// Workers did not emit an error.
@@ -231,11 +231,11 @@ describe( 'executeInParallel()', () => {
const [ firstWorker, secondWorker ] = stubs.WorkerMock.instances;
expect( firstWorker.workerData ).toBeInstanceOf( Object );
- expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'C:/Users/ckeditor/uuid-4.mjs' );
+ expect( firstWorker.workerData ).toHaveProperty( 'callbackModule', 'file://C:/Users/ckeditor/uuid-4.mjs' );
expect( firstWorker.workerData ).toHaveProperty( 'packages' );
expect( secondWorker.workerData ).toBeInstanceOf( Object );
- expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'C:/Users/ckeditor/uuid-4.mjs' );
+ expect( secondWorker.workerData ).toHaveProperty( 'callbackModule', 'file://C:/Users/ckeditor/uuid-4.mjs' );
expect( secondWorker.workerData ).toHaveProperty( 'packages' );
// Workers did not emit an error.