From 13ade0e9264f7112de37765d2f54051fc82de473 Mon Sep 17 00:00:00 2001 From: Oleg Date: Thu, 24 Jul 2025 15:55:43 +0300 Subject: [PATCH 01/53] refactor: Update package to modern JS - Replaced array-like objects with Set for better performance and clarity. - Removed duplicate code in `forEachAsync` method. - Fixed a bug in the `clear` method. - Improved clarity by refining some function names. --- packages/callback-hook/hook.js | 108 ++++++++++-------------------- packages/callback-hook/package.js | 2 +- 2 files changed, 37 insertions(+), 73 deletions(-) diff --git a/packages/callback-hook/hook.js b/packages/callback-hook/hook.js index ecc9c2ccfb..a5340666cd 100644 --- a/packages/callback-hook/hook.js +++ b/packages/callback-hook/hook.js @@ -36,23 +36,14 @@ // callback will propagate up to the iterator function, and will // terminate calling the remaining callbacks if not caught. -const hasOwn = Object.prototype.hasOwnProperty; - export class Hook { - constructor(options) { - options = options || {}; - this.nextCallbackId = 0; - this.callbacks = Object.create(null); - // Whether to wrap callbacks with Meteor.bindEnvironment - this.bindEnvironment = true; - if (options.bindEnvironment === false) { - this.bindEnvironment = false; - } + constructor(options = {}) { + this.callbacks = new Set(); - this.wrapAsync = true; - if (options.wrapAsync === false) { - this.wrapAsync = false; - } + // Whether to wrap callbacks with Meteor.bindEnvironment + const { bindEnvironment = true, wrapAsync = true } = options; + this.bindEnvironment = !!bindEnvironment; + this.wrapAsync = !!wrapAsync; if (options.exceptionHandler) { this.exceptionHandler = options.exceptionHandler; @@ -64,6 +55,10 @@ export class Hook { } } + clear() { + this.callbacks.clear(); + } + register(callback) { const exceptionHandler = this.exceptionHandler || function (exception) { // Note: this relies on the undocumented fact that if bindEnvironment's @@ -75,29 +70,23 @@ export class Hook { if (this.bindEnvironment) { callback = Meteor.bindEnvironment(callback, exceptionHandler); } else { - callback = dontBindEnvironment(callback, exceptionHandler); + callback = wrapHookWithErrorHandling(callback, exceptionHandler); } if (this.wrapAsync) { callback = Meteor.wrapFn(callback); } - const id = this.nextCallbackId++; - this.callbacks[id] = callback; + this.callbacks.add(callback); return { callback, stop: () => { - delete this.callbacks[id]; + this.callbacks.delete(callback); } }; } - clear() { - this.nextCallbackId = 0; - this.callbacks = []; - } - /** * For each registered callback, call the passed iterator function with the callback. * @@ -110,31 +99,8 @@ export class Hook { * @param iterator */ forEach(iterator) { - - const ids = Object.keys(this.callbacks); - for (let i = 0; i < ids.length; ++i) { - const id = ids[i]; - // check to see if the callback was removed during iteration - if (hasOwn.call(this.callbacks, id)) { - const callback = this.callbacks[id]; - if (! iterator(callback)) { - break; - } - } - } - } - - async forEachAsync(iterator) { - const ids = Object.keys(this.callbacks); - for (let i = 0; i < ids.length; ++i) { - const id = ids[i]; - // check to see if the callback was removed during iteration - if (hasOwn.call(this.callbacks, id)) { - const callback = this.callbacks[id]; - if (!await iterator(callback)) { - break; - } - } + for (const callback of this.callbacks) { + if (!iterator(callback)) break; } } @@ -147,16 +113,8 @@ export class Hook { * @see forEach */ async forEachAsync(iterator) { - const ids = Object.keys(this.callbacks); - for (let i = 0; i < ids.length; ++i) { - const id = ids[i]; - // check to see if the callback was removed during iteration - if (hasOwn.call(this.callbacks, id)) { - const callback = this.callbacks[id]; - if (!await iterator(callback)) { - break; - } - } + for (const callback of this.callbacks) { + if (!await iterator(callback)) break; } } @@ -170,24 +128,30 @@ export class Hook { } // Copied from Meteor.bindEnvironment and removed all the env stuff. -function dontBindEnvironment(func, onException, _this) { - if (!onException || typeof(onException) === 'string') { - const description = onException || "callback of async function"; - onException = function (error) { - Meteor._debug( - "Exception in " + description, - error - ); - }; - } - - return function (...args) { +function wrapHookWithErrorHandling(func, onException, _this) { + const exceptionHandler = normalizeHookExceptionHandler(onException); + return function executeHookWithErrorHandling(...args) { let ret; try { ret = func.apply(_this, args); } catch (e) { - onException(e); + exceptionHandler(e); } return ret; }; } + +function normalizeHookExceptionHandler(exceptionHandler) { + if (typeof exceptionHandler === 'function') { + return exceptionHandler; + } + + // TODO: The message "callback of async function" is not very useful and needs clarification. + const description = typeof exceptionHandler === 'string' + ? exceptionHandler + : "callback of async function"; + + return function defaultHookExceptionHandler(error) { + Meteor._debug(`Exception in ${description}`, error); + } +} \ No newline at end of file diff --git a/packages/callback-hook/package.js b/packages/callback-hook/package.js index 4b4f756266..82df7371bb 100644 --- a/packages/callback-hook/package.js +++ b/packages/callback-hook/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Register callbacks on a hook", - version: '1.6.0', + version: '1.7.0', }); Package.onUse(function (api) { From 065ef8a4610440b4d3f4e3bb3861ef87897de8da Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 25 Jul 2025 18:19:57 +0300 Subject: [PATCH 02/53] feat: Add .size, ._asArray, and ._fromArray methods --- packages/callback-hook/hook.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/callback-hook/hook.js b/packages/callback-hook/hook.js index a5340666cd..88372251d5 100644 --- a/packages/callback-hook/hook.js +++ b/packages/callback-hook/hook.js @@ -59,6 +59,23 @@ export class Hook { this.callbacks.clear(); } + size() { + return this.callbacks.size; + } + + // WARN: This method is for test compatibility only. + _asArray() { + return Array.from(this.callbacks); + } + + // WARN: This method is for test compatibility only. + _fromArray(arr) { + if (!Array.isArray(arr)) { + throw new Error("Method _fromArray expects an array"); + } + this.callbacks = new Set(arr); + } + register(callback) { const exceptionHandler = this.exceptionHandler || function (exception) { // Note: this relies on the undocumented fact that if bindEnvironment's From c22a174716600945b57ba2078c91a69161036e77 Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 25 Jul 2025 18:20:13 +0300 Subject: [PATCH 03/53] chore: bump version to 1.7.1 --- packages/callback-hook/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/callback-hook/package.js b/packages/callback-hook/package.js index 82df7371bb..9d9d33d6c4 100644 --- a/packages/callback-hook/package.js +++ b/packages/callback-hook/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Register callbacks on a hook", - version: '1.7.0', + version: '1.7.1', }); Package.onUse(function (api) { From aaf6eeaf05ee7c712c3101ceba19c93f4f22031d Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 25 Jul 2025 19:25:58 +0300 Subject: [PATCH 04/53] fix: fix account_reconnect_tests.js --- packages/accounts-base/accounts_reconnect_tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/accounts-base/accounts_reconnect_tests.js b/packages/accounts-base/accounts_reconnect_tests.js index 8341cf0a5d..67dcf1199a 100644 --- a/packages/accounts-base/accounts_reconnect_tests.js +++ b/packages/accounts-base/accounts_reconnect_tests.js @@ -112,7 +112,7 @@ if (Meteor.isClient) { loginAsUser1((err) => { test.isUndefined(err, 'Unexpected error logging in as user1'); test.equal( - Object.keys(DDP._reconnectHook.callbacks).length, + DDP._reconnectHook.size(), 1, 'Only one onReconnect callback should be registered' ); @@ -122,7 +122,7 @@ if (Meteor.isClient) { setTimeout(() => { test.isTrue(Meteor.status().connected); test.equal( - Object.keys(DDP._reconnectHook.callbacks).length, + DDP._reconnectHook.size(), 1, 'Only one onReconnect callback should be registered' ); From 9eeb03c95510eeffc43f8a791c24426496c3a5b1 Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 25 Jul 2025 19:26:21 +0300 Subject: [PATCH 05/53] fix: fix spiderable_client_tests.js --- .../spiderable/spiderable_client_tests.js | 76 +++++-------------- 1 file changed, 17 insertions(+), 59 deletions(-) diff --git a/packages/deprecated/spiderable/spiderable_client_tests.js b/packages/deprecated/spiderable/spiderable_client_tests.js index c46c591ae3..f21a886e6f 100644 --- a/packages/deprecated/spiderable/spiderable_client_tests.js +++ b/packages/deprecated/spiderable/spiderable_client_tests.js @@ -1,8 +1,5 @@ Tinytest.add("spiderable - default hooks registered", function (test, expect) { - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 2 - ); + test.equal(Spiderable._onReadyHook.size(), 2); }); Tinytest.add("spiderable - is not ready while initial subscriptions aren't started", function (test, expect) { @@ -39,21 +36,12 @@ Tinytest.add("spiderable - default hooks can ready", function (test, expect) { }); Tinytest.add("spiderable - is not ready with a custom hook", function (test, expect) { - var callbacks = {} - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 2 - ); + test.equal(Spiderable._onReadyHook.size(), 2); //clear all/default callbacks - _.each(Spiderable._onReadyHook.callbacks, function (value,key,list) { - callbacks[key] = value; - delete list[key]; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 0 - ); + var callbacks = Spiderable._onReadyHook._asArray() + Spiderable._onReadyHook.clear(); + test.equal(Spiderable._onReadyHook.size(), 0); // actually test not ready @@ -62,41 +50,21 @@ Tinytest.add("spiderable - is not ready with a custom hook", function (test, exp // clear new callback - _.each(Spiderable._onReadyHook.callbacks, function (value,key,list) { - delete list[key]; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 0 - ); + Spiderable._onReadyHook.clear(); + test.equal(Spiderable._onReadyHook.size(), 0); // restore callbacks - _.each(callbacks, function (value,key,list) { - Spiderable._onReadyHook.callbacks[key] = value; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 2 - ); + Spiderable._onReadyHook._fromArray(callbacks); + test.equal(Spiderable._onReadyHook.size(), 2); }); Tinytest.add("spiderable - is ready with a custom hook", function (test, expect) { - var callbacks = {} - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 2 - ); + test.equal(Spiderable._onReadyHook.size(), 2); //clear all callbacks - _.each(Spiderable._onReadyHook.callbacks, function (value,key,list) { - callbacks[key] = value; - delete list[key]; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 0 - ); - + var callbacks = Spiderable._onReadyHook._asArray(); + Spiderable._onReadyHook.clear(); + test.equal(Spiderable._onReadyHook.size(), 0); // actually test ready Spiderable.addReadyCondition(function () { return true; }); @@ -104,20 +72,10 @@ Tinytest.add("spiderable - is ready with a custom hook", function (test, expect) // clear new callback - _.each(Spiderable._onReadyHook.callbacks, function (value,key,list) { - delete list[key]; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 0 - ); + Spiderable._onReadyHook.clear(); + test.equal(Spiderable._onReadyHook.size(), 0); // restore callbacks - _.each(callbacks, function (value,key,list) { - Spiderable._onReadyHook.callbacks[key] = value; - }); - test.equal( - _.keys(Spiderable._onReadyHook.callbacks).length, - 2 - ); + Spiderable._onReadyHook._fromArray(callbacks); + test.equal(Spiderable._onReadyHook.size(), 2); }); From 83d32d6da24598ffe55d5101bf5e1dd72c7728d1 Mon Sep 17 00:00:00 2001 From: Oleg Date: Sun, 27 Jul 2025 06:16:57 +0300 Subject: [PATCH 06/53] feat: Implement Iterable interface. Adds [Symbol.iterator] method to allow use with for...of loops. --- packages/callback-hook/hook.js | 90 ++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/packages/callback-hook/hook.js b/packages/callback-hook/hook.js index 88372251d5..2b7077fa16 100644 --- a/packages/callback-hook/hook.js +++ b/packages/callback-hook/hook.js @@ -37,28 +37,49 @@ // terminate calling the remaining callbacks if not caught. export class Hook { - constructor(options = {}) { - this.callbacks = new Set(); + /** + * Creates a new Hook instance. + * @param {object} [options={}] - Configuration options for the hook. + * @param {boolean} [options.bindEnvironment=true] - Whether to automatically wrap registered callbacks with `Meteor.bindEnvironment`. + * If `true`, callbacks will run in the Meteor environment of the code that registered them. + * @param {boolean} [options.wrapAsync=true] - Whether to automatically wrap registered callbacks with `Meteor.wrapFn`. + * If `true`, callbacks will be prepared to run asynchronously. + * @param {Function} [options.exceptionHandler] - A custom function to handle exceptions thrown by registered callbacks. + * This function will be called with the exception as its argument. + * If provided, `options.debugPrintExceptions` will be ignored. + * @param {string} [options.debugPrintExceptions] - If an `exceptionHandler` is not provided, and this option is a string, + * exceptions thrown by callbacks will be logged to `Meteor._debug` with this string as a description. + */ + constructor(options = {}) { + this.callbacks = new Set(); - // Whether to wrap callbacks with Meteor.bindEnvironment - const { bindEnvironment = true, wrapAsync = true } = options; - this.bindEnvironment = !!bindEnvironment; - this.wrapAsync = !!wrapAsync; + // Whether to wrap callbacks with Meteor.bindEnvironment + const { bindEnvironment = true, wrapAsync = true } = options; + this.bindEnvironment = !!bindEnvironment; + this.wrapAsync = !!wrapAsync; - if (options.exceptionHandler) { - this.exceptionHandler = options.exceptionHandler; - } else if (options.debugPrintExceptions) { - if (typeof options.debugPrintExceptions !== "string") { - throw new Error("Hook option debugPrintExceptions should be a string"); + if (options.exceptionHandler) { + this.exceptionHandler = options.exceptionHandler; + } else if (options.debugPrintExceptions) { + if (typeof options.debugPrintExceptions !== "string") { + throw new Error("Hook option debugPrintExceptions should be a string"); + } + this.exceptionHandler = options.debugPrintExceptions; } - this.exceptionHandler = options.debugPrintExceptions; } - } + /** + * Clears all registered callbacks from this Hook instance. + * After calling this method, the hook will have no callbacks registered. + */ clear() { this.callbacks.clear(); } + /** + * Returns the number of callbacks currently registered with this Hook instance. + * @returns {number} The number of registered callbacks. + */ size() { return this.callbacks.size; } @@ -76,6 +97,14 @@ export class Hook { this.callbacks = new Set(arr); } + /** + * Registers a new callback with this Hook instance. + * + * @param {Function} callback The function to register. This function will be called when the hook is iterated over. + * @returns {{callback: Function, stop: Function}} An object containing: + * - `callback`: The actual callback function that was added to the hook's internal set (after any wrapping). + * - `stop`: A function that, when called, unregisters this specific callback from the hook. + */ register(callback) { const exceptionHandler = this.exceptionHandler || function (exception) { // Note: this relies on the undocumented fact that if bindEnvironment's @@ -142,9 +171,28 @@ export class Hook { each(iterator) { return this.forEach(iterator); } + + /** + * Makes the Hook instance iterable, allowing it to be used in `for...of` loops. + * It iterates over the registered callbacks. + * @returns {Iterator} An iterator for the registered callbacks. + */ + [Symbol.iterator]() { + return this.callbacks[Symbol.iterator](); + } } -// Copied from Meteor.bindEnvironment and removed all the env stuff. +/** + * Wraps a given function with error handling. If the wrapped function throws an exception, + * it will be caught and passed to the provided exception handler. + * This is similar to `Meteor.bindEnvironment` but without the Meteor environment binding. + * + * @param {Function} func The function to wrap. + * @param {Function|string} onException The exception handler function to call if `func` throws, + * or a string description for default exception logging. + * @param {any} _this The `this` context to bind to `func` when it is called. + * @returns {Function} A new function that executes `func` with error handling. + */ function wrapHookWithErrorHandling(func, onException, _this) { const exceptionHandler = normalizeHookExceptionHandler(onException); return function executeHookWithErrorHandling(...args) { @@ -158,6 +206,16 @@ function wrapHookWithErrorHandling(func, onException, _this) { }; } +/** + * Normalizes an exception handler, ensuring it is a function. + * If a function is provided, it is returned directly. + * If a string is provided, it is used as a description for a default handler that logs exceptions. + * Otherwise, a generic default handler that logs exceptions with a default description is returned. + * + * @param {Function|string} exceptionHandler The exception handler to normalize. Can be a function, + * a string description for logging, or any other value (which defaults to generic logging). + * @returns {Function} A function that handles exceptions. + */ function normalizeHookExceptionHandler(exceptionHandler) { if (typeof exceptionHandler === 'function') { return exceptionHandler; @@ -167,8 +225,8 @@ function normalizeHookExceptionHandler(exceptionHandler) { const description = typeof exceptionHandler === 'string' ? exceptionHandler : "callback of async function"; - + return function defaultHookExceptionHandler(error) { Meteor._debug(`Exception in ${description}`, error); } -} \ No newline at end of file +} From c0b0b29131cf4c44000a6d6c8bd708b62c86bb32 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 28 Jul 2025 11:07:13 +0300 Subject: [PATCH 07/53] refactor: Rename _asArray to asArray, _fromArray to fromArray --- packages/callback-hook/hook.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/callback-hook/hook.js b/packages/callback-hook/hook.js index 2b7077fa16..2638d3426d 100644 --- a/packages/callback-hook/hook.js +++ b/packages/callback-hook/hook.js @@ -84,15 +84,24 @@ export class Hook { return this.callbacks.size; } - // WARN: This method is for test compatibility only. - _asArray() { + /** + * Returns all registered callbacks as a new Array. + * This provides a snapshot of the current callbacks. + * @returns {Array} An array containing all registered callback functions. + */ + asArray() { return Array.from(this.callbacks); } - // WARN: This method is for test compatibility only. - _fromArray(arr) { + /** + * Replaces the current set of registered callbacks with a new set derived from the given array. + * + * @param {Array} arr An array of callback functions to register with this hook. + * @throws {Error} If the provided argument `arr` is not an array. + */ + fromArray(arr) { if (!Array.isArray(arr)) { - throw new Error("Method _fromArray expects an array"); + throw new Error("Method fromArray expects an array"); } this.callbacks = new Set(arr); } From dc2daa160b7ea493ee80f3c330d8dbea9c8a7465 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 28 Jul 2025 11:08:31 +0300 Subject: [PATCH 08/53] fix: Fix Spiderable package tests --- packages/deprecated/spiderable/spiderable_client_tests.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/deprecated/spiderable/spiderable_client_tests.js b/packages/deprecated/spiderable/spiderable_client_tests.js index f21a886e6f..bcd2f2db41 100644 --- a/packages/deprecated/spiderable/spiderable_client_tests.js +++ b/packages/deprecated/spiderable/spiderable_client_tests.js @@ -39,7 +39,7 @@ Tinytest.add("spiderable - is not ready with a custom hook", function (test, exp test.equal(Spiderable._onReadyHook.size(), 2); //clear all/default callbacks - var callbacks = Spiderable._onReadyHook._asArray() + var callbacks = Spiderable._onReadyHook.asArray() Spiderable._onReadyHook.clear(); test.equal(Spiderable._onReadyHook.size(), 0); @@ -54,7 +54,7 @@ Tinytest.add("spiderable - is not ready with a custom hook", function (test, exp test.equal(Spiderable._onReadyHook.size(), 0); // restore callbacks - Spiderable._onReadyHook._fromArray(callbacks); + Spiderable._onReadyHook.fromArray(callbacks); test.equal(Spiderable._onReadyHook.size(), 2); }); @@ -62,7 +62,7 @@ Tinytest.add("spiderable - is ready with a custom hook", function (test, expect) test.equal(Spiderable._onReadyHook.size(), 2); //clear all callbacks - var callbacks = Spiderable._onReadyHook._asArray(); + var callbacks = Spiderable._onReadyHook.asArray(); Spiderable._onReadyHook.clear(); test.equal(Spiderable._onReadyHook.size(), 0); @@ -76,6 +76,6 @@ Tinytest.add("spiderable - is ready with a custom hook", function (test, expect) test.equal(Spiderable._onReadyHook.size(), 0); // restore callbacks - Spiderable._onReadyHook._fromArray(callbacks); + Spiderable._onReadyHook.fromArray(callbacks); test.equal(Spiderable._onReadyHook.size(), 2); }); From a77246874d472d781b71910969c1e84b4d4dd937 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 28 Jul 2025 11:09:19 +0300 Subject: [PATCH 09/53] chore: Set package version to 1.7.0 --- packages/callback-hook/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/callback-hook/package.js b/packages/callback-hook/package.js index 9d9d33d6c4..82df7371bb 100644 --- a/packages/callback-hook/package.js +++ b/packages/callback-hook/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Register callbacks on a hook", - version: '1.7.1', + version: '1.7.0', }); Package.onUse(function (api) { From 5716ea7676110f57f0e17d916a0cac5608082be2 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 30 Jul 2025 18:32:58 +0300 Subject: [PATCH 10/53] chore: Set package version to 1.6.1 --- packages/callback-hook/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/callback-hook/package.js b/packages/callback-hook/package.js index 82df7371bb..6f9e9ac68a 100644 --- a/packages/callback-hook/package.js +++ b/packages/callback-hook/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Register callbacks on a hook", - version: '1.7.0', + version: '1.6.1', }); Package.onUse(function (api) { From 193a0d85d3efaafbebe1e00a1fe24bf509df0d54 Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 12 Aug 2025 16:04:50 +0300 Subject: [PATCH 11/53] chore: Set package version to 1.6.2 --- packages/callback-hook/package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/callback-hook/package.js b/packages/callback-hook/package.js index 6f9e9ac68a..c706df472a 100644 --- a/packages/callback-hook/package.js +++ b/packages/callback-hook/package.js @@ -1,6 +1,6 @@ Package.describe({ summary: "Register callbacks on a hook", - version: '1.6.1', + version: '1.6.2', }); Package.onUse(function (api) { From 5240b244c404237d864d1763c3da83ce816dbd85 Mon Sep 17 00:00:00 2001 From: Oleg Date: Wed, 10 Sep 2025 20:44:42 +0300 Subject: [PATCH 12/53] chore: remove TODO --- packages/callback-hook/hook.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/callback-hook/hook.js b/packages/callback-hook/hook.js index 2638d3426d..8d900c20fc 100644 --- a/packages/callback-hook/hook.js +++ b/packages/callback-hook/hook.js @@ -230,7 +230,6 @@ function normalizeHookExceptionHandler(exceptionHandler) { return exceptionHandler; } - // TODO: The message "callback of async function" is not very useful and needs clarification. const description = typeof exceptionHandler === 'string' ? exceptionHandler : "callback of async function"; From 4ea076305cea67c500a253464a70db157be1250e Mon Sep 17 00:00:00 2001 From: Shresthap21 Date: Thu, 5 Feb 2026 00:39:14 +0530 Subject: [PATCH 13/53] Fix: Track local dependencies in rspack.config.js for cache invalidation Fixes #14031 When rspack.config.js requires local files (like plugin modules), those files weren't tracked in Rspack's buildDependencies. This caused the cache to incorrectly reuse stale data, skipping plugin transform hooks on subsequent meteor runs. Solution: - Parse rspack.config.js to extract require/import statements - Resolve local file paths (with extension fallback) - Add resolved paths to buildDependencies array - Filter out node_modules and external packages Now when local plugin files change, Rspack properly invalidates the cache and calls transform hooks as expected. --- npm-packages/meteor-rspack/rspack.config.js | 94 +++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index 09138424a7..9f7c93094e 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -39,6 +39,94 @@ function safeRequire(moduleName) { } } +/** + * Extract local file dependencies from a config file by parsing require/import statements + * @param {string} configFilePath - Path to the config file to parse + * @returns {string[]} - Array of absolute paths to local dependencies + */ +function extractLocalDependencies(configFilePath) { + if (!configFilePath || !fs.existsSync(configFilePath)) { + return []; + } + + try { + const content = fs.readFileSync(configFilePath, 'utf-8'); + const dependencies = []; + const configDir = path.dirname(configFilePath); + const projectDir = process.cwd(); + + // Regex patterns to match require() and import statements + const requirePattern = /require\s*\(\s*[`'"]([^`'"]+)[`'"]\s*\)/g; + const importPattern = /import\s+.*?\s+from\s+[`'"]([^`'"]+)[`'"]/g; + const dynamicImportPattern = /import\s*\(\s*[`'"]([^`'"]+)[`'"]\s*\)/g; + + // Extract all matches + let match; + const patterns = [requirePattern, importPattern, dynamicImportPattern]; + + for (const pattern of patterns) { + while ((match = pattern.exec(content)) !== null) { + const modulePath = match[1]; + const resolvedPath = resolveLocalModule(modulePath, configDir, projectDir); + if (resolvedPath) { + dependencies.push(resolvedPath); + } + } + } + + // Remove duplicates + return [...new Set(dependencies)]; + } catch (error) { + console.warn('[Rspack Cache] Failed to parse config dependencies:', error.message); + return []; + } +} + +/** + * Resolve a module path to an absolute path if it's a local file + * @param {string} modulePath - Module path from require/import statement + * @param {string} configDir - Directory containing the config file + * @param {string} projectDir - Project root directory + * @returns {string|null} - Resolved absolute path or null + */ +function resolveLocalModule(modulePath, configDir, projectDir) { + // Only process relative paths (starts with . or /) + if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) { + return null; + } + + try { + let resolvedPath = path.resolve(configDir, modulePath); + + // Try common extensions if file doesn't exist as-is + if (!fs.existsSync(resolvedPath)) { + const extensions = ['.js', '.mjs', '.cjs', '.ts', '.json']; + for (const ext of extensions) { + const pathWithExt = resolvedPath + ext; + if (fs.existsSync(pathWithExt)) { + resolvedPath = pathWithExt; + break; + } + } + } + + // Verify file exists and is within project (not node_modules) + if (fs.existsSync(resolvedPath)) { + const normalizedResolved = path.normalize(resolvedPath); + const normalizedProject = path.normalize(projectDir); + + if (normalizedResolved.startsWith(normalizedProject) && + !normalizedResolved.includes('node_modules')) { + return resolvedPath; + } + } + } catch (error) { + // Silently ignore resolution errors + } + + return null; +} + // Persistent filesystem cache strategy function createCacheStrategy(mode, side, { projectConfigPath, configPath } = {}) { // Check for configuration files @@ -59,10 +147,16 @@ function createCacheStrategy(mode, side, { projectConfigPath, configPath } = {}) const yarnLockPath = path.join(process.cwd(), 'yarn.lock'); const hasYarnLock = fs.existsSync(yarnLockPath); + // Extract local dependencies from project config (e.g., plugin files) + const localDependencies = projectConfigPath + ? extractLocalDependencies(projectConfigPath) + : []; + // Build dependencies array const buildDependencies = [ ...(projectConfigPath ? [projectConfigPath] : []), ...(configPath ? [configPath] : []), + ...localDependencies, ...(hasTsconfig ? [tsconfigPath] : []), ...(hasBabelRcConfig ? [babelRcConfig] : []), ...(hasBabelJsConfig ? [babelJsConfig] : []), From c751cd3c453478ff93e75d226a35ea7ad61d049e Mon Sep 17 00:00:00 2001 From: Shresthap21 Date: Fri, 6 Feb 2026 16:58:00 +0530 Subject: [PATCH 14/53] Refactor: Use @swc/core AST parsing for dependency tracking - Replace regex-based parsing with @swc/core AST parsing - Create new helper file lib/localDependenciesHelpers.js - Support all import/export patterns (static, dynamic, re-exports) - Handle directory imports with index file resolution - Fix path resolution with symlink support and proper node_modules filtering - Address all maintainer and Copilot review feedback --- .../lib/localDependenciesHelpers.js | 180 ++++++++++++++++++ npm-packages/meteor-rspack/rspack.config.js | 89 +-------- 2 files changed, 181 insertions(+), 88 deletions(-) create mode 100644 npm-packages/meteor-rspack/lib/localDependenciesHelpers.js diff --git a/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js new file mode 100644 index 0000000000..cea36e9c92 --- /dev/null +++ b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js @@ -0,0 +1,180 @@ +const fs = require('fs'); +const path = require('path'); + +/** + * Extract local file dependencies from a config file by parsing require/import statements using AST + * @param {string} configFilePath - Path to the config file to parse + * @returns {string[]} - Array of absolute paths to local dependencies + */ +function extractLocalDependencies(configFilePath) { + if (!configFilePath || !fs.existsSync(configFilePath)) { + return []; + } + + try { + const swc = require('@swc/core'); + const content = fs.readFileSync(configFilePath, 'utf-8'); + const configDir = path.dirname(configFilePath); + const projectDir = process.cwd(); + const dependencies = []; + + // Parse the file into an AST + const ast = swc.parseSync(content, { + syntax: 'ecmascript', + dynamicImport: true, + target: 'es2020', + }); + + // Visit all nodes to find import/require statements + visitNode(ast, (node) => { + let modulePath = null; + + // Handle require() calls: require('./plugin') + if (node.type === 'CallExpression' && + node.callee.type === 'Identifier' && + node.callee.value === 'require' && + node.arguments.length > 0) { + const arg = node.arguments[0]; + if (arg.expression?.type === 'StringLiteral') { + modulePath = arg.expression.value; + } + } + + // Handle dynamic import() calls: import('./plugin') + if (node.type === 'CallExpression' && + node.callee.type === 'Import' && + node.arguments.length > 0) { + const arg = node.arguments[0]; + if (arg.expression?.type === 'StringLiteral') { + modulePath = arg.expression.value; + } + } + + // Handle static imports: import x from './plugin' + if (node.type === 'ImportDeclaration' && node.source?.type === 'StringLiteral') { + modulePath = node.source.value; + } + + // Handle export re-exports: export * from './plugin' + if (node.type === 'ExportAllDeclaration' && node.source?.type === 'StringLiteral') { + modulePath = node.source.value; + } + + // Handle named export re-exports: export { x } from './plugin' + if (node.type === 'ExportNamedDeclaration' && node.source?.type === 'StringLiteral') { + modulePath = node.source.value; + } + + // If we found a module path, try to resolve it + if (modulePath) { + const resolvedPath = resolveLocalModule(modulePath, configDir, projectDir); + if (resolvedPath) { + dependencies.push(resolvedPath); + } + } + }); + + // Remove duplicates + return [...new Set(dependencies)]; + } catch (error) { + console.warn('[Rspack Cache] Failed to parse config dependencies:', error.message); + return []; + } +} + +/** + * Recursively visit all nodes in an AST + * @param {Object} node - AST node + * @param {Function} callback - Function to call for each node + */ +function visitNode(node, callback) { + if (!node || typeof node !== 'object') { + return; + } + + callback(node); + + // Visit all properties of the node + for (const key in node) { + if (node.hasOwnProperty(key)) { + const value = node[key]; + if (Array.isArray(value)) { + value.forEach(child => visitNode(child, callback)); + } else if (typeof value === 'object') { + visitNode(value, callback); + } + } + } +} + +/** + * Resolve a module path to an absolute path if it's a local file + * @param {string} modulePath - Module path from require/import statement + * @param {string} configDir - Directory containing the config file + * @param {string} projectDir - Project root directory + * @returns {string|null} - Resolved absolute path or null + */ +function resolveLocalModule(modulePath, configDir, projectDir) { + // Only process relative paths (starts with . or ..) + if (!modulePath.startsWith('.')) { + return null; + } + + try { + let resolvedPath = path.resolve(configDir, modulePath); + + // Try common extensions if file doesn't exist as-is + if (!fs.existsSync(resolvedPath)) { + const extensions = ['.js', '.mjs', '.cjs', '.ts', '.json']; + let found = false; + + for (const ext of extensions) { + const pathWithExt = resolvedPath + ext; + if (fs.existsSync(pathWithExt)) { + resolvedPath = pathWithExt; + found = true; + break; + } + } + + // If not found with extension, try index files in directory + if (!found && fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) { + for (const ext of extensions) { + const indexPath = path.join(resolvedPath, `index${ext}`); + if (fs.existsSync(indexPath)) { + resolvedPath = indexPath; + found = true; + break; + } + } + } + + // If still not found, return null + if (!found) { + return null; + } + } + + // Verify file is within project (not node_modules) + const resolvedReal = fs.realpathSync(resolvedPath); + const projectReal = fs.realpathSync(projectDir); + + const isWithinProject = + resolvedReal === projectReal || + resolvedReal.startsWith(projectReal + path.sep); + const hasNodeModulesSegment = resolvedReal.split(path.sep).includes('node_modules'); + + if (isWithinProject && !hasNodeModulesSegment) { + return resolvedPath; + } + } catch (error) { + // Silently ignore resolution errors + } + + return null; +} + +module.exports = { + extractLocalDependencies, + resolveLocalModule, +}; diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index 9f7c93094e..937659f7bb 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -23,6 +23,7 @@ const { disablePlugins, } = require('./lib/meteorRspackHelpers.js'); const { prepareMeteorRspackConfig } = require("./lib/meteorRspackConfigFactory"); +const { extractLocalDependencies } = require('./lib/localDependenciesHelpers.js'); // Safe require that doesn't throw if the module isn't found function safeRequire(moduleName) { @@ -39,94 +40,6 @@ function safeRequire(moduleName) { } } -/** - * Extract local file dependencies from a config file by parsing require/import statements - * @param {string} configFilePath - Path to the config file to parse - * @returns {string[]} - Array of absolute paths to local dependencies - */ -function extractLocalDependencies(configFilePath) { - if (!configFilePath || !fs.existsSync(configFilePath)) { - return []; - } - - try { - const content = fs.readFileSync(configFilePath, 'utf-8'); - const dependencies = []; - const configDir = path.dirname(configFilePath); - const projectDir = process.cwd(); - - // Regex patterns to match require() and import statements - const requirePattern = /require\s*\(\s*[`'"]([^`'"]+)[`'"]\s*\)/g; - const importPattern = /import\s+.*?\s+from\s+[`'"]([^`'"]+)[`'"]/g; - const dynamicImportPattern = /import\s*\(\s*[`'"]([^`'"]+)[`'"]\s*\)/g; - - // Extract all matches - let match; - const patterns = [requirePattern, importPattern, dynamicImportPattern]; - - for (const pattern of patterns) { - while ((match = pattern.exec(content)) !== null) { - const modulePath = match[1]; - const resolvedPath = resolveLocalModule(modulePath, configDir, projectDir); - if (resolvedPath) { - dependencies.push(resolvedPath); - } - } - } - - // Remove duplicates - return [...new Set(dependencies)]; - } catch (error) { - console.warn('[Rspack Cache] Failed to parse config dependencies:', error.message); - return []; - } -} - -/** - * Resolve a module path to an absolute path if it's a local file - * @param {string} modulePath - Module path from require/import statement - * @param {string} configDir - Directory containing the config file - * @param {string} projectDir - Project root directory - * @returns {string|null} - Resolved absolute path or null - */ -function resolveLocalModule(modulePath, configDir, projectDir) { - // Only process relative paths (starts with . or /) - if (!modulePath.startsWith('.') && !modulePath.startsWith('/')) { - return null; - } - - try { - let resolvedPath = path.resolve(configDir, modulePath); - - // Try common extensions if file doesn't exist as-is - if (!fs.existsSync(resolvedPath)) { - const extensions = ['.js', '.mjs', '.cjs', '.ts', '.json']; - for (const ext of extensions) { - const pathWithExt = resolvedPath + ext; - if (fs.existsSync(pathWithExt)) { - resolvedPath = pathWithExt; - break; - } - } - } - - // Verify file exists and is within project (not node_modules) - if (fs.existsSync(resolvedPath)) { - const normalizedResolved = path.normalize(resolvedPath); - const normalizedProject = path.normalize(projectDir); - - if (normalizedResolved.startsWith(normalizedProject) && - !normalizedResolved.includes('node_modules')) { - return resolvedPath; - } - } - } catch (error) { - // Silently ignore resolution errors - } - - return null; -} - // Persistent filesystem cache strategy function createCacheStrategy(mode, side, { projectConfigPath, configPath } = {}) { // Check for configuration files From 35fd9e6bdee41e15b91c4c87260ad7adc5bbd406 Mon Sep 17 00:00:00 2001 From: slegarraga <64795732+slegarraga@users.noreply.github.com> Date: Wed, 25 Feb 2026 01:40:13 -0300 Subject: [PATCH 15/53] fix(accounts): fix operator precedence in passwordValidator for maxLength Due to JavaScript operator precedence, the expression: str.length <= Meteor.settings?.packages?.accounts?.passwordMaxLength || 256 was parsed as: (str.length <= ...passwordMaxLength) || 256 which always evaluates to truthy (256) when passwordMaxLength is undefined, and also when the password exceeds a configured maxLength. Added parentheses so the fallback works correctly: str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256) Fixes #14072 --- packages/accounts-password/password_server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/accounts-password/password_server.js b/packages/accounts-password/password_server.js index cb7cb96112..1d09b38af8 100644 --- a/packages/accounts-password/password_server.js +++ b/packages/accounts-password/password_server.js @@ -290,7 +290,7 @@ Accounts._checkPasswordAsync = checkPasswordAsync; const passwordValidator = Match.OneOf( - Match.Where(str => Match.test(str, String) && str.length <= Meteor.settings?.packages?.accounts?.passwordMaxLength || 256), { + Match.Where(str => Match.test(str, String) && str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256)), { digest: Match.Where(str => Match.test(str, String) && str.length === 64), algorithm: Match.OneOf('sha-256') } From 790d0af0b8b598c97f6fb546b03813f47cf2f485 Mon Sep 17 00:00:00 2001 From: slegarraga <64795732+slegarraga@users.noreply.github.com> Date: Sun, 1 Mar 2026 10:35:51 -0300 Subject: [PATCH 16/53] fix: also fix operator precedence in changePassword and add tests - Fix the same operator precedence bug in the changePassword handler (line 475) where passwordMaxLength || 256 was not properly grouped - Add unit tests to verify password length validation works correctly with the default 256 char limit when no custom maxLength is configured Addresses review feedback from @italojs --- packages/accounts-password/password_server.js | 2 +- packages/accounts-password/password_tests.js | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/packages/accounts-password/password_server.js b/packages/accounts-password/password_server.js index 1d09b38af8..3564b474a5 100644 --- a/packages/accounts-password/password_server.js +++ b/packages/accounts-password/password_server.js @@ -472,7 +472,7 @@ Meteor.methods( Accounts.setPasswordAsync = async (userId, newPlaintextPassword, options) => { check(userId, String); - check(newPlaintextPassword, Match.Where(str => Match.test(str, String) && str.length <= Meteor.settings?.packages?.accounts?.passwordMaxLength || 256)); + check(newPlaintextPassword, Match.Where(str => Match.test(str, String) && str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256))); check(options, Match.Maybe({ logout: Boolean })); options = { logout: true, ...options }; diff --git a/packages/accounts-password/password_tests.js b/packages/accounts-password/password_tests.js index 49f94544a0..4f8ab8e8fb 100644 --- a/packages/accounts-password/password_tests.js +++ b/packages/accounts-password/password_tests.js @@ -1136,6 +1136,56 @@ if (Meteor.isClient) (() => { })(); +if (Meteor.isServer) { + Tinytest.add( + 'passwords - passwordValidator accepts passwords within default maxLength', + test => { + // A password of 256 chars (default max) should be accepted + const validPassword = 'a'.repeat(256); + test.isTrue( + Match.test(validPassword, Match.OneOf( + Match.Where(str => Match.test(str, String) && str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256)), + { digest: Match.Where(str => Match.test(str, String) && str.length === 64), algorithm: Match.OneOf('sha-256') } + )), + 'Password of exactly 256 chars should be accepted' + ); + } + ); + + Tinytest.add( + 'passwords - passwordValidator rejects passwords exceeding default maxLength', + test => { + // A password of 257 chars should be rejected + const longPassword = 'a'.repeat(257); + test.isFalse( + Match.test(longPassword, Match.OneOf( + Match.Where(str => Match.test(str, String) && str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256)), + { digest: Match.Where(str => Match.test(str, String) && str.length === 64), algorithm: Match.OneOf('sha-256') } + )), + 'Password exceeding 256 chars should be rejected' + ); + } + ); + + Tinytest.add( + 'passwords - passwordValidator operator precedence is correct for maxLength fallback', + test => { + // This test verifies the fix: without proper parentheses around the || operator, + // `str.length <= Meteor.settings?.packages?.accounts?.passwordMaxLength || 256` + // would evaluate as `(str.length <= undefined) || 256` which is always truthy (256), + // allowing passwords of any length. + const veryLongPassword = 'a'.repeat(1000); + test.isFalse( + Match.test(veryLongPassword, Match.OneOf( + Match.Where(str => Match.test(str, String) && str.length <= (Meteor.settings?.packages?.accounts?.passwordMaxLength || 256)), + { digest: Match.Where(str => Match.test(str, String) && str.length === 64), algorithm: Match.OneOf('sha-256') } + )), + 'Very long password (1000 chars) should be rejected when no custom maxLength is configured' + ); + } + ); +} + if (Meteor.isServer) (() => { Tinytest.add('passwords - setup more than one onCreateUserHook', test => { From 457838808cbe2ab5ba06646aed47d3a80d69649a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 3 Mar 2026 10:00:12 -0600 Subject: [PATCH 17/53] refactor(accounts-base): remove unnecessary await on Array.find calls --- packages/accounts-base/accounts_server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/accounts-base/accounts_server.js b/packages/accounts-base/accounts_server.js index e8a884c87b..27f5784ff5 100644 --- a/packages/accounts-base/accounts_server.js +++ b/packages/accounts-base/accounts_server.js @@ -1680,13 +1680,13 @@ const defaultResumeLoginHandler = async (accounts, options) => { // {hashedToken, when} for a hashed token or {token, when} for an // unhashed token. let oldUnhashedStyleToken; - let token = await user.services.resume.loginTokens.find(token => + let token = user.services.resume.loginTokens.find(token => token.hashedToken === hashedToken ); if (token) { oldUnhashedStyleToken = false; } else { - token = await user.services.resume.loginTokens.find(token => + token = user.services.resume.loginTokens.find(token => token.token === options.resume ); oldUnhashedStyleToken = true; From 875fe1d51e54028d172d3de1d325f2d6bcd33df5 Mon Sep 17 00:00:00 2001 From: Frederico Maia Date: Wed, 18 Mar 2026 15:17:18 -0300 Subject: [PATCH 18/53] Add TypeScript + Tailwind skeleton support - Introduced a new skeleton type "typescript-tailwind". - Added necessary configuration files and directories for the new skeleton. - Updated documentation to reflect the new skeleton option in the CLI. --- tools/cli/commands.js | 5 +- .../skel-typescript-tailwind/.gitignore | 7 +++ .../.meteor/.gitignore | 1 + .../skel-typescript-tailwind/.meteor/packages | 26 ++++++++++ .../.meteor/platforms | 2 + .../skel-typescript-tailwind/.meteorignore | 2 + .../skel-typescript-tailwind/client/main.css | 6 +++ .../skel-typescript-tailwind/client/main.html | 8 ++++ .../skel-typescript-tailwind/client/main.tsx | 12 +++++ .../imports/api/links.ts | 10 ++++ .../imports/ui/App.tsx | 10 ++++ .../imports/ui/Hello.tsx | 42 +++++++++++++++++ .../imports/ui/Info.tsx | 47 +++++++++++++++++++ .../skel-typescript-tailwind/package.json | 46 ++++++++++++++++++ .../postcss.config.js | 5 ++ .../skel-typescript-tailwind/rspack.config.ts | 31 ++++++++++++ .../skel-typescript-tailwind/server/main.ts | 37 +++++++++++++++ .../skel-typescript-tailwind/tests/main.ts | 21 +++++++++ .../skel-typescript-tailwind/tsconfig.json | 26 ++++++++++ v3-docs/docs/cli/index.md | 2 + 20 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 tools/static-assets/skel-typescript-tailwind/.gitignore create mode 100644 tools/static-assets/skel-typescript-tailwind/.meteor/.gitignore create mode 100644 tools/static-assets/skel-typescript-tailwind/.meteor/packages create mode 100644 tools/static-assets/skel-typescript-tailwind/.meteor/platforms create mode 100644 tools/static-assets/skel-typescript-tailwind/.meteorignore create mode 100644 tools/static-assets/skel-typescript-tailwind/client/main.css create mode 100644 tools/static-assets/skel-typescript-tailwind/client/main.html create mode 100644 tools/static-assets/skel-typescript-tailwind/client/main.tsx create mode 100644 tools/static-assets/skel-typescript-tailwind/imports/api/links.ts create mode 100644 tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx create mode 100644 tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx create mode 100644 tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx create mode 100644 tools/static-assets/skel-typescript-tailwind/package.json create mode 100644 tools/static-assets/skel-typescript-tailwind/postcss.config.js create mode 100644 tools/static-assets/skel-typescript-tailwind/rspack.config.ts create mode 100644 tools/static-assets/skel-typescript-tailwind/server/main.ts create mode 100644 tools/static-assets/skel-typescript-tailwind/tests/main.ts create mode 100644 tools/static-assets/skel-typescript-tailwind/tsconfig.json diff --git a/tools/cli/commands.js b/tools/cli/commands.js index 6c26667dd7..76a6081cb2 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -697,6 +697,7 @@ export const AVAILABLE_SKELETONS = [ "minimal", DEFAULT_SKELETON, "typescript", + "typescript-tailwind", "vue", "svelte", "tailwind", @@ -715,6 +716,7 @@ const SKELETON_INFO = { "minimal": "To create an app with as few Meteor packages as possible", "react": "To create a basic React-based app", "typescript": "To create an app using TypeScript and React", + "typescript-tailwind": "To create an app using TypeScript, React, and Tailwind", "vue": "To create a basic Vue3-based app", "svelte": "To create a basic Svelte app", "tailwind": "To create an app using React and Tailwind", @@ -722,7 +724,7 @@ const SKELETON_INFO = { "solid": "To create a basic Solid app", "coffeescript": "To create a basic CoffeeScript app", "babel": "To create a React app with Babel support", - "angular": "To create a basic Angular app", + "angular": "To create a basic Angular app" }; main.registerCommand({ @@ -741,6 +743,7 @@ main.registerCommand({ react: { type: Boolean }, vue: { type: Boolean }, typescript: { type: Boolean }, + 'typescript-tailwind': { type: Boolean }, apollo: { type: Boolean }, svelte: { type: Boolean }, tailwind: { type: Boolean }, diff --git a/tools/static-assets/skel-typescript-tailwind/.gitignore b/tools/static-assets/skel-typescript-tailwind/.gitignore new file mode 100644 index 0000000000..3e954aa73f --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/.gitignore @@ -0,0 +1,7 @@ +node_modules/ + +# Meteor Modern-Tools build context directories +_build +*/build-assets +*/build-chunks +.rsdoctor diff --git a/tools/static-assets/skel-typescript-tailwind/.meteor/.gitignore b/tools/static-assets/skel-typescript-tailwind/.meteor/.gitignore new file mode 100644 index 0000000000..4083037423 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/tools/static-assets/skel-typescript-tailwind/.meteor/packages b/tools/static-assets/skel-typescript-tailwind/.meteor/packages new file mode 100644 index 0000000000..00d004f864 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/.meteor/packages @@ -0,0 +1,26 @@ +# Meteor packages used by this project, one per line. +# Check this file (and the other files in this directory) into your repository. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +meteor-base # Packages every Meteor app needs to have +mobile-experience # Packages for a great mobile UX +mongo # The database Meteor supports right now +reactive-var # Reactive variable for tracker + +standard-minifier-css # CSS minifier run for production mode +standard-minifier-js # JS minifier run for production mode +es5-shim # ECMAScript 5 compatibility for older browsers +ecmascript # Enable ECMAScript2015+ syntax in app code +typescript # Enable TypeScript syntax in .ts and .tsx modules +shell-server # Server-side component of the `meteor shell` command +hot-module-replacement # Update client in development without reloading the page + +~prototype~ +static-html # Define static page content in .html files +react-meteor-data # React higher-order component for reactively tracking Meteor data + +rspack # Integrate Rspack into Meteor for client and server app bundling + +zodern:types # Pull in type declarations from other Meteor packages \ No newline at end of file diff --git a/tools/static-assets/skel-typescript-tailwind/.meteor/platforms b/tools/static-assets/skel-typescript-tailwind/.meteor/platforms new file mode 100644 index 0000000000..efeba1b50c --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/.meteor/platforms @@ -0,0 +1,2 @@ +server +browser diff --git a/tools/static-assets/skel-typescript-tailwind/.meteorignore b/tools/static-assets/skel-typescript-tailwind/.meteorignore new file mode 100644 index 0000000000..4568c54a7d --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/.meteorignore @@ -0,0 +1,2 @@ +# Ignore Meteor CSS handling; let Rspack resolve Tailwind styles +client/main.css diff --git a/tools/static-assets/skel-typescript-tailwind/client/main.css b/tools/static-assets/skel-typescript-tailwind/client/main.css new file mode 100644 index 0000000000..6ea2603dca --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/client/main.css @@ -0,0 +1,6 @@ +@import "tailwindcss"; + +body { + padding: 10px; + font-family: sans-serif; +} diff --git a/tools/static-assets/skel-typescript-tailwind/client/main.html b/tools/static-assets/skel-typescript-tailwind/client/main.html new file mode 100644 index 0000000000..c710d3dbd3 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/client/main.html @@ -0,0 +1,8 @@ + + ~name~ + + + + +
+ diff --git a/tools/static-assets/skel-typescript-tailwind/client/main.tsx b/tools/static-assets/skel-typescript-tailwind/client/main.tsx new file mode 100644 index 0000000000..a86c160a73 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/client/main.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Meteor } from 'meteor/meteor'; +import { createRoot } from 'react-dom/client'; +import { App } from '/imports/ui/App'; +import './main.css'; + +Meteor.startup(() => { + const target = document.getElementById('react-target'); + if (target) { + createRoot(target).render(); + } +}); diff --git a/tools/static-assets/skel-typescript-tailwind/imports/api/links.ts b/tools/static-assets/skel-typescript-tailwind/imports/api/links.ts new file mode 100644 index 0000000000..ec0bf4631f --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/imports/api/links.ts @@ -0,0 +1,10 @@ +import { Mongo } from 'meteor/mongo'; + +export interface Link { + _id?: string; + title: string; + url: string; + createdAt: Date; +} + +export const LinksCollection = new Mongo.Collection('links'); diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx new file mode 100644 index 0000000000..90a2b06b9e --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { Hello } from './Hello'; +import { Info } from './Info'; + +export const App = () => ( +
+ + +
+); diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx new file mode 100644 index 0000000000..9d0e05237c --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx @@ -0,0 +1,42 @@ +import React, { useState } from 'react'; + +export const Hello = () => { + const [counter, setCounter] = useState(0); + + const increment = () => { + setCounter(counter + 1); + }; + + return ( +
+
+
+
+
+

+ Welcome to Meteor! +

+
+ +
+
+
+

+ You've pressed the button {counter} times. +

+
+
+
+ +
+
+
+
+ ) +}; diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx new file mode 100644 index 0000000000..bc7a35f123 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx @@ -0,0 +1,47 @@ +import React from "react"; +import { useFind, useSubscribe } from "meteor/react-meteor-data/suspense"; +import { LinksCollection } from "../api/links"; + +export const Info = () => { + useSubscribe("links"); + const data = useFind(LinksCollection, []); + + return ( +
+ {data.map((link) => ( +
+
+ + + + + +
+ + +
+ ))} +
+ ); +}; diff --git a/tools/static-assets/skel-typescript-tailwind/package.json b/tools/static-assets/skel-typescript-tailwind/package.json new file mode 100644 index 0000000000..a75fe7e2a0 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/package.json @@ -0,0 +1,46 @@ +{ + "name": "~name~", + "private": true, + "scripts": { + "start": "meteor lint && meteor run", + "test": "meteor test --once --driver-package meteortesting:mocha", + "test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha", + "visualize": "meteor --production --extra-packages bundle-visualizer", + "generate-types": "meteor lint" + }, + "dependencies": { + "@babel/runtime": "^7.23.5", + "@swc/helpers": "^0.5.17", + "autoprefixer": "^10.4.4", + "meteor-node-stubs": "^1.2.12", + "react": "^18.2.0", + "react-dom": "^18.2.0" + }, + "devDependencies": { + "@meteorjs/rspack": "^1.0.1", + "@rsdoctor/rspack-plugin": "^1.2.3", + "@rspack/cli": "^1.7.1", + "@rspack/core": "^1.7.1", + "@rspack/plugin-react-refresh": "^1.4.3", + "@tailwindcss/postcss": "^4.1.12", + "@types/meteor": "^2.9.9", + "@types/mocha": "^8.2.3", + "@types/node": "^22.10.6", + "@types/react": "^18.2.5", + "@types/react-dom": "^18.2.4", + "postcss": "^8.5.6", + "postcss-loader": "^8.1.1", + "react-refresh": "^0.17.0", + "tailwindcss": "^4.1.12", + "ts-checker-rspack-plugin": "^1.1.5", + "typescript": "^5.9.3" + }, + "meteor": { + "mainModule": { + "client": "client/main.tsx", + "server": "server/main.ts" + }, + "testModule": "tests/main.ts", + "modern": true + } +} diff --git a/tools/static-assets/skel-typescript-tailwind/postcss.config.js b/tools/static-assets/skel-typescript-tailwind/postcss.config.js new file mode 100644 index 0000000000..c2ddf74822 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/postcss.config.js @@ -0,0 +1,5 @@ +export default { + plugins: { + "@tailwindcss/postcss": {}, + }, +}; diff --git a/tools/static-assets/skel-typescript-tailwind/rspack.config.ts b/tools/static-assets/skel-typescript-tailwind/rspack.config.ts new file mode 100644 index 0000000000..99ea60b81d --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/rspack.config.ts @@ -0,0 +1,31 @@ +import { defineConfig } from "@meteorjs/rspack"; +import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin"; + +/** + * Rspack configuration for Meteor projects. + * + * Provides typed flags on the `Meteor` object, such as: + * - `Meteor.isClient` / `Meteor.isServer` + * - `Meteor.isDevelopment` / `Meteor.isProduction` + * - …and other flags available + * + * Use these flags to adjust your build settings based on environment. + */ +export default defineConfig(Meteor => { + return { + ...Meteor.isClient && { + plugins: [ + ...(!Meteor.isTest && !Meteor.isAppTest ? [new TsCheckerRspackPlugin()] : []), + ], + module: { + rules: [ + { + test: /\.css$/, + use: ["postcss-loader"], + type: "css", + }, + ], + }, + }, + }; +}); diff --git a/tools/static-assets/skel-typescript-tailwind/server/main.ts b/tools/static-assets/skel-typescript-tailwind/server/main.ts new file mode 100644 index 0000000000..a2619f24e8 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/server/main.ts @@ -0,0 +1,37 @@ +import { Meteor } from 'meteor/meteor'; +import { Link, LinksCollection } from '/imports/api/links'; + +async function insertLink({ title, url }: Pick) { + await LinksCollection.insertAsync({ title, url, createdAt: new Date() }); +} + +Meteor.startup(async () => { + // If the Links collection is empty, add some data. + if (await LinksCollection.find().countAsync() === 0) { + await insertLink({ + title: 'Do the Tutorial', + url: 'https://react-tutorial.meteor.com/simple-todos/01-creating-app.html', + }); + + await insertLink({ + title: 'Follow the Guide', + url: 'http://guide.meteor.com', + }); + + await insertLink({ + title: 'Read the Docs', + url: 'https://docs.meteor.com', + }); + + await insertLink({ + title: 'Discussions', + url: 'https://forums.meteor.com', + }); + } + + // We publish the entire Links collection to all clients. + // In order to be fetched in real-time to the clients + Meteor.publish("links", function () { + return LinksCollection.find(); + }); +}); diff --git a/tools/static-assets/skel-typescript-tailwind/tests/main.ts b/tools/static-assets/skel-typescript-tailwind/tests/main.ts new file mode 100644 index 0000000000..1b098e1aa9 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/tests/main.ts @@ -0,0 +1,21 @@ +import assert from "assert"; +import { Meteor } from "meteor/meteor"; + +describe("~name~", function () { + it("package.json has correct name", async function () { + const { name } = await import("../package.json"); + assert.strictEqual(name, "~name~"); + }); + + if (Meteor.isClient) { + it("client is not server", function () { + assert.strictEqual(Meteor.isServer, false); + }); + } + + if (Meteor.isServer) { + it("server is not client", function () { + assert.strictEqual(Meteor.isClient, false); + }); + } +}); diff --git a/tools/static-assets/skel-typescript-tailwind/tsconfig.json b/tools/static-assets/skel-typescript-tailwind/tsconfig.json new file mode 100644 index 0000000000..21922a37d9 --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "node", + "jsx": "react", + "strict": false, + "noEmit": true, + "esModuleInterop": true, + "allowJs": true, + "resolveJsonModule": true, + "baseUrl": ".", + "paths": { + "/*": ["./*"], + "meteor/react-meteor-data/suspense": [ + ".meteor/local/types/node_modules/package-types/react-meteor-data/package/os/suspense/react-meteor-data.d.ts" + ], + "meteor/*": [ + "node_modules/@types/meteor/*", + ".meteor/local/types/packages.d.ts" + ] + }, + "types": ["meteor", "mocha"] + }, + "exclude": ["node_modules", ".meteor"] +} diff --git a/v3-docs/docs/cli/index.md b/v3-docs/docs/cli/index.md index efb8527bea..20bb00030c 100644 --- a/v3-docs/docs/cli/index.md +++ b/v3-docs/docs/cli/index.md @@ -246,6 +246,7 @@ If you run `meteor create` without arguments, Meteor will launch an interactive Minimal # To create an app with as few Meteor packages as possible React # To create a basic React-based app Typescript # To create an app using TypeScript and React + Typescript-tailwind # To create an app using TypeScript, React, and Tailwind Vue # To create a basic Vue3-based app Svelte # To create a basic Svelte app Tailwind # To create an app using React and Tailwind @@ -278,6 +279,7 @@ If you run `meteor create` without arguments, Meteor will launch an interactive | `--apollo` | React + Apollo (GraphQL) | [Meteor 2 with GraphQL](https://react-tutorial.meteor.com/simple-todos-graphql/) | | `--typescript` | React + TypeScript | [TypeScript Guide](/about/build-tool#typescript) | | `--tailwind` | React + Tailwind CSS | - | +| `--typescript-tailwind` | React + TypeScript + Tailwind CSS | - | | `--chakra-ui` | React + Chakra UI | [Simple Tasks Example](https://github.com/fredmaiaarantes/simpletasks) | | `--coffeescript` | CoffeeScript | - | | `--babel` | React with Babel support | - | From 81e2bd7e5000f097c24c5e06cc372b922c658880 Mon Sep 17 00:00:00 2001 From: dupontbertrand Date: Thu, 19 Mar 2026 23:07:38 +0100 Subject: [PATCH 19/53] ddp-server: clear subscription references after async onStop callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only _callStopCallbacks becomes async — _deactivate uses .then() to clear _session and _documents after callbacks complete, avoiding async propagation up the call stack. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/ddp-server/livedata_server.js | 37 +++++++----- packages/ddp-server/livedata_server_tests.js | 61 +++++++++++++++++++- 2 files changed, 83 insertions(+), 15 deletions(-) diff --git a/packages/ddp-server/livedata_server.js b/packages/ddp-server/livedata_server.js index 3f5efceafb..df167f94c4 100644 --- a/packages/ddp-server/livedata_server.js +++ b/packages/ddp-server/livedata_server.js @@ -1050,23 +1050,33 @@ Object.assign(Subscription.prototype, { // removed messages for the published objects; if that is necessary, call // _removeAllDocuments first. _deactivate: function() { - var self = this; - if (self._deactivated) + if (this._deactivated) return; - self._deactivated = true; - self._callStopCallbacks(); + this._deactivated = true; + this._callStopCallbacks().then(() => { + // Break reference chains to allow GC of the Session and its data. + // Without this, deactivated subscriptions retain live references + // to the (now-closed) session indefinitely. + this._session = null; + this._documents = new Map(); + }); Package['facts-base'] && Package['facts-base'].Facts.incrementServerFact( "livedata", "subscriptions", -1); }, - _callStopCallbacks: function () { - var self = this; - // Tell listeners, so they can clean up - var callbacks = self._stopCallbacks; - self._stopCallbacks = []; - callbacks.forEach(function (callback) { - callback(); - }); + _callStopCallbacks: async function () { + // In Meteor 3, onStop callbacks can be async (e.g. observeHandle.stop() + // returns a Promise). We must await each one so that observer teardown + // completes before the subscription is considered fully deactivated. + const callbacks = this._stopCallbacks; + this._stopCallbacks = []; + for (const callback of callbacks) { + try { + await callback(); + } catch (e) { + Meteor._debug("Exception in onStop callback:", e); + } + } }, // Send remove messages for every document. @@ -1145,8 +1155,7 @@ Object.assign(Subscription.prototype, { // destroyed but the deferred call to _deactivateAllSubscriptions hasn't // happened yet. _isDeactivated: function () { - var self = this; - return self._deactivated || self._session.inQueue === null; + return this._deactivated || !this._session || this._session.inQueue === null; }, /** diff --git a/packages/ddp-server/livedata_server_tests.js b/packages/ddp-server/livedata_server_tests.js index 15b0349e87..6b66c6bc67 100644 --- a/packages/ddp-server/livedata_server_tests.js +++ b/packages/ddp-server/livedata_server_tests.js @@ -593,4 +593,63 @@ function getTestConnections(test) { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); -} \ No newline at end of file +} + +// ============================================================================ +// Async onStop cleanup tests (memory leak fix) +// ============================================================================ + +const asyncCleanupTracker = {}; + +Meteor.publish('test_async_onstop_cleanup', function (trackerId) { + this.onStop(async function () { + await new Promise(resolve => setTimeout(resolve, 50)); + asyncCleanupTracker[trackerId] = true; + }); + this.ready(); +}); + +Tinytest.addAsync( + 'livedata server - async onStop callbacks complete on unsubscribe', + async function (test) { + const trackerId = Random.id(); + asyncCleanupTracker[trackerId] = false; + + const { clientConn } = await getTestConnections(test); + const sub = clientConn.subscribe('test_async_onstop_cleanup', trackerId); + await sleep(100); + + sub.stop(); + await sleep(200); + + test.isTrue( + asyncCleanupTracker[trackerId], + 'Async onStop callback should have completed' + ); + + clientConn.disconnect(); + delete asyncCleanupTracker[trackerId]; + } +); + +Tinytest.addAsync( + 'livedata server - async onStop callbacks complete on disconnect', + async function (test) { + const trackerId = Random.id(); + asyncCleanupTracker[trackerId] = false; + + const { clientConn } = await getTestConnections(test); + clientConn.subscribe('test_async_onstop_cleanup', trackerId); + await sleep(100); + + clientConn.disconnect(); + await sleep(300); + + test.isTrue( + asyncCleanupTracker[trackerId], + 'Async onStop callback should have completed on disconnect' + ); + + delete asyncCleanupTracker[trackerId]; + } +); \ No newline at end of file From 345bcbc2e11bbf47b2807944811d3ab91793a47d Mon Sep 17 00:00:00 2001 From: dupontbertrand Date: Fri, 20 Mar 2026 10:29:29 +0100 Subject: [PATCH 20/53] tests: use waitUntil instead of sleep for async onStop tests --- packages/ddp-server/livedata_server_tests.js | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/ddp-server/livedata_server_tests.js b/packages/ddp-server/livedata_server_tests.js index 6b66c6bc67..dbb49c63ee 100644 --- a/packages/ddp-server/livedata_server_tests.js +++ b/packages/ddp-server/livedata_server_tests.js @@ -617,10 +617,18 @@ Tinytest.addAsync( const { clientConn } = await getTestConnections(test); const sub = clientConn.subscribe('test_async_onstop_cleanup', trackerId); - await sleep(100); + + await waitUntil( + () => sub.ready(), + { description: 'subscription is ready' } + ); sub.stop(); - await sleep(200); + + await waitUntil( + () => asyncCleanupTracker[trackerId] === true, + { description: 'async onStop callback completed after unsubscribe' } + ); test.isTrue( asyncCleanupTracker[trackerId], @@ -640,10 +648,18 @@ Tinytest.addAsync( const { clientConn } = await getTestConnections(test); clientConn.subscribe('test_async_onstop_cleanup', trackerId); - await sleep(100); + + await waitUntil( + () => clientConn.status().connected, + { description: 'client is connected' } + ); clientConn.disconnect(); - await sleep(300); + + await waitUntil( + () => asyncCleanupTracker[trackerId] === true, + { description: 'async onStop callback completed after disconnect' } + ); test.isTrue( asyncCleanupTracker[trackerId], From 3fac9c0404d921f74213015ac74631023ee709f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 24 Mar 2026 15:38:06 +0100 Subject: [PATCH 21/53] update `writeToDisk` logic in Rspack dev server to include `sw.js`, and add documentation on serving root path files during development --- npm-packages/meteor-rspack/rspack.config.js | 3 ++- .../rspack-bundler-integration.md | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index ea1fa3da79..c784879958 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -28,6 +28,7 @@ const { const { loadUserAndOverrideConfig } = require('./lib/meteorRspackConfigHelpers.js'); const { prepareMeteorRspackConfig } = require("./lib/meteorRspackConfigFactory"); + // Safe require that doesn't throw if the module isn't found function safeRequire(moduleName) { try { @@ -643,7 +644,7 @@ module.exports = async function (inMeteor = {}, argv = {}) { port: devServerPort, devMiddleware: { writeToDisk: (filePath) => - /\.(html)$/.test(filePath) && !filePath.includes(".hot-update."), + /\.(html)$/.test(filePath) || filePath.endsWith('sw.js'), }, onListening(devServer) { if (!devServer) return; diff --git a/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md b/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md index 46ee9d8fe2..b376088bb5 100644 --- a/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md +++ b/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md @@ -827,6 +827,8 @@ new GenerateSW({ }) ``` +During development, the HMR dev server writes `sw.js` to disk by default, so build-generated service workers are served by Meteor's web server without extra configuration. If your service worker uses a different filename, see the [Dev Server](#dev-server) section for how to extend `writeToDisk`. + ### Dev Server You can customize the Rspack dev server much like you would when using meteor run. Any [devServer option listed in the official Rspack guide](https://rspack.rs/config/dev-server) can be applied in your app’s [`rspack.config.js`](./rspack-bundler-integration.md#custom-rspackconfigjs). @@ -840,6 +842,23 @@ RSPACK_DEVSERVER_PORT=3232 meteor run The reason is that the Rspack dev server is handled by the Meteor so it can make both dev server works together, and the info of the port needs to be properly shared via the env. +During development, the HMR dev server keeps most build assets in memory and only writes HTML files and `sw.js` to disk by default. This means if your build pipeline generates files that need to be served from the root path, like `service-worker.js`, `manifest.json`, or any other output that Meteor's web server should serve directly, you can extend `writeToDisk` in your `rspack.config.js`: + +```js +const { defineConfig } = require('@meteorjs/rspack'); + +module.exports = defineConfig(Meteor => ({ + devServer: { + devMiddleware: { + writeToDisk: (filePath) => + /\.(html)$/.test(filePath) || filePath.endsWith('service-worker.js'), + }, + }, +})); +``` + +In production, all build outputs are written to disk normally, so this only affects local development. + ### Disable Plugins Meteor allows disabling Rspack plugins that are added by default or through presets. This is useful when troubleshooting build issues or replacing a plugin with a custom implementation. From 07ccbb2895a5828887d19a2d6b0267a88fb3c6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 24 Mar 2026 17:03:00 +0100 Subject: [PATCH 22/53] enable automatic CSS delegation in Meteor-Rspack integration and improve handling of stylesheet extensions --- npm-packages/meteor-rspack/README.md | 1 + .../plugins/MeteorRspackOutputPlugin.js | 37 +++++++++++++++++- npm-packages/meteor-rspack/rspack.config.js | 7 +++- packages/rspack/lib/compilation.js | 9 ++++- packages/rspack/lib/config.js | 39 +++++++++++++++++++ .../rspack-bundler-integration.md | 4 +- 6 files changed, 92 insertions(+), 5 deletions(-) diff --git a/npm-packages/meteor-rspack/README.md b/npm-packages/meteor-rspack/README.md index e5ea9413a4..b2ea3be3a4 100644 --- a/npm-packages/meteor-rspack/README.md +++ b/npm-packages/meteor-rspack/README.md @@ -14,6 +14,7 @@ When Meteor runs with the Rspack bundler enabled, this package is what generates - **Asset externals and HTML generation** through custom Rspack plugins - **A `defineConfig` helper** that accepts a factory function receiving Meteor environment flags and build utilities - **Customizable config** via `rspack.config.js` in your project root, with safe merging that warns if you try to override reserved settings +- **Automatic CSS delegation** — when rspack is configured with CSS, Less, or SCSS loaders, Meteor automatically detects the handled extensions after the first compilation and stops processing those files itself. No `.meteorignore` entries needed. ## Installation diff --git a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js index a4494ae49e..274e938a7e 100644 --- a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js +++ b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js @@ -6,6 +6,40 @@ const { outputMeteorRspack } = require('../lib/meteorRspackHelpers'); +/** + * Extracts file extensions that rspack is configured to handle + * from the resolved module.rules test patterns. + * Only returns extensions relevant for Meteor delegation (CSS-family). + * @param {import('@rspack/core').Compiler} compiler + * @returns {string[]} Array of extensions like ['.css', '.less', '.scss'] + */ +function extractDelegatedExtensions(compiler) { + const delegatableExtensions = ['.css', '.less', '.scss', '.sass', '.styl']; + const found = new Set(); + + function inspectRules(rules) { + for (const rule of rules) { + if (!rule) continue; + if (rule.test) { + const testStr = rule.test instanceof RegExp + ? rule.test.source + : String(rule.test); + for (const ext of delegatableExtensions) { + const escaped = ext.replace('.', '\\.'); + if (testStr.includes(escaped)) { + found.add(ext); + } + } + } + if (rule.oneOf) inspectRules(rule.oneOf); + if (rule.rules) inspectRules(rule.rules); + } + } + + inspectRules(compiler.options.module?.rules || []); + return Array.from(found); +} + class MeteorRspackOutputPlugin { constructor(options = {}) { this.pluginName = 'MeteorRspackOutputPlugin'; @@ -26,6 +60,7 @@ class MeteorRspackOutputPlugin { ...(this.getData(stats, { compilationCount: this.compilationCount, isRebuild: this.compilationCount > 1, + compiler, }) || {}), }; outputMeteorRspack(data); @@ -33,4 +68,4 @@ class MeteorRspackOutputPlugin { } } -module.exports = { MeteorRspackOutputPlugin }; +module.exports = { MeteorRspackOutputPlugin, extractDelegatedExtensions }; diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index ea1fa3da79..192d4bd0fc 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -10,7 +10,7 @@ const { getMeteorAppSwcConfig } = require('./lib/swc.js'); const HtmlRspackPlugin = require('./plugins/HtmlRspackPlugin.js'); const { RequireExternalsPlugin } = require('./plugins/RequireExtenalsPlugin.js'); const { AssetExternalsPlugin } = require('./plugins/AssetExternalsPlugin.js'); -const { MeteorRspackOutputPlugin } = require('./plugins/MeteorRspackOutputPlugin.js'); +const { MeteorRspackOutputPlugin, extractDelegatedExtensions } = require('./plugins/MeteorRspackOutputPlugin.js'); const { generateEagerTestFile } = require("./lib/test.js"); const { getMeteorIgnoreEntries, createIgnoreGlobConfig } = require("./lib/ignore"); const { @@ -843,7 +843,7 @@ module.exports = async function (inMeteor = {}, argv = {}) { // Add MeteorRspackOutputPlugin as the last plugin to output compilation info const meteorRspackOutputPlugin = new MeteorRspackOutputPlugin({ - getData: (stats, { isRebuild, compilationCount }) => ({ + getData: (stats, { isRebuild, compilationCount, compiler }) => ({ name: config.name, mode: config.mode, hasErrors: stats.hasErrors(), @@ -852,6 +852,9 @@ module.exports = async function (inMeteor = {}, argv = {}) { statsOverrided, compilationCount, isRebuild, + ...(!isRebuild && compiler && { + delegatedExtensions: extractDelegatedExtensions(compiler), + }), }), }); config.plugins = [meteorRspackOutputPlugin, ...(config.plugins || [])]; diff --git a/packages/rspack/lib/compilation.js b/packages/rspack/lib/compilation.js index 1a3de1511e..f0850fb642 100644 --- a/packages/rspack/lib/compilation.js +++ b/packages/rspack/lib/compilation.js @@ -16,6 +16,8 @@ const { setGlobalState } = require('meteor/tools-core/lib/global-state'); +const { applyDelegatedExtensions } = require('./config'); + // Helper function to format milliseconds with comma separators function formatMilliseconds(ms) { return ms.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); @@ -124,10 +126,15 @@ export function setupCompilationTracking() { }; // Define separate onCompile callbacks for client and server - const onCompileClient = (data) => { + const onCompileClient = (data, config) => { // Resolve the promise if it's the first compilation const clientState = getGlobalState(GLOBAL_STATE_KEYS.CLIENT_FIRST_COMPILE, clientFirstCompile); if (!clientState?.resolved) { + // Apply delegated extensions before resolving (so they're set before Meteor scans) + if (config?.delegatedExtensions?.length > 0) { + applyDelegatedExtensions(config.delegatedExtensions); + } + clientState.resolved = true; clientState.resolve(); setGlobalState(GLOBAL_STATE_KEYS.CLIENT_FIRST_COMPILE, clientState); diff --git a/packages/rspack/lib/config.js b/packages/rspack/lib/config.js index 5771d25fb2..17b3aa61f8 100644 --- a/packages/rspack/lib/config.js +++ b/packages/rspack/lib/config.js @@ -386,3 +386,42 @@ export function configureMeteorForRspack() { } } } + +/** + * Applies delegated extension ignore patterns for entry folder files. + * Called after rspack's first compilation reports which extensions it handles. + * Since Meteor awaits rspack compilation before scanning files, these patterns + * are in place before Meteor processes any application files. + * + * Uses gitignore semantics: a later positive pattern (client/*.css) overrides + * an earlier negation (!client/*.css) that was set in configureMeteorForRspack. + * + * @param {string[]} extensions - Array of extensions like ['.css', '.less'] + */ +export function applyDelegatedExtensions(extensions) { + if (!extensions || extensions.length === 0) return; + + const initialEntrypoints = getInitialEntrypoints(); + const entrypointContexts = [ + initialEntrypoints.mainClient, + initialEntrypoints.mainServer, + ] + .filter(Boolean) + .map(entrypoint => path.dirname(entrypoint)); + + const ignorePatterns = []; + for (const dir of entrypointContexts) { + for (const ext of extensions) { + // ext comes as '.css', glob needs '*.css' + ignorePatterns.push(`${dir}/*${ext}`); + } + } + + if (ignorePatterns.length > 0) { + setMeteorAppIgnore(ignorePatterns.join(' ')); + + if (isMeteorAppDebug() || isMeteorAppConfigModernVerbose()) { + logInfo(`[i] Rspack delegated extensions: ${extensions.join(', ')} (ignored in entry folders)`); + } + } +} diff --git a/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md b/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md index 46ee9d8fe2..f718a4c5f0 100644 --- a/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md +++ b/v3-docs/docs/about/modern-build-stack/rspack-bundler-integration.md @@ -229,7 +229,7 @@ Ensure your app defines these entry files with the correct paths where each modu Defining entry points improves performance even with the Meteor bundler, as Meteor stops scanning and eagerly loading unnecessary files. For Meteor-Rspack integration, this is required, since it does not support automatic code discovery for efficiency. -In Meteor-Rspack integration, all app code is ignored by Meteor and handled by Rspack. By default, Meteor still processes eagerly CSS and HTML files in the entry folder (e.g. `client/*.[html|css]` in most apps). +In Meteor-Rspack integration, all app code is ignored by Meteor and handled by Rspack. By default, Meteor still processes eagerly HTML files in the entry folder (e.g. `client/*.html` in most apps). CSS files in the entry folder are automatically delegated to Rspack when a CSS loader is configured, see [CSS](#css) for details. If no CSS loader is present, Meteor handles them as before. If you need Meteor to handle CSS or HTML files outside the main entry folder, add them to the `modules` field. This field accepts an array of strings, each pointing to a file or folder. @@ -422,6 +422,8 @@ With the Meteor–Rspack integration, `zodern:melte` no longer works. Use the of Meteor-Rspack comes with built-in CSS support. You can import any CSS file into your code, and it will be processed and included in your HTML skeleton automatically. In addition, any CSS file placed in the same folder as your Meteor entry point will be processed and added as global styles without the need for explicit imports. +When Rspack is configured with a CSS rule, whether through `postcss-loader`, `type: "css"`, or any other CSS-handling loader, Meteor automatically detects the handled file extensions after Rspack's first compilation and stops processing those files itself. This means you do not need to manually add CSS files to `.meteorignore` or otherwise tell Meteor to skip them. The same automatic delegation applies to Less and SCSS when their respective loaders are configured. If no CSS rule is present in the rspack configuration, Meteor continues to handle stylesheets as it normally would. + ### CSS Modules [CSS Modules](https://rspack.rs/guide/tech/css#css-modules) are supported out of the box — any file named `*.module.css` is automatically scoped locally. From c39ab099d061681ce6dbae00043178560d142515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Tue, 24 Mar 2026 17:12:13 +0100 Subject: [PATCH 23/53] clarify context for automatic CSS delegation in README --- npm-packages/meteor-rspack/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm-packages/meteor-rspack/README.md b/npm-packages/meteor-rspack/README.md index b2ea3be3a4..e7787cfaa1 100644 --- a/npm-packages/meteor-rspack/README.md +++ b/npm-packages/meteor-rspack/README.md @@ -14,7 +14,7 @@ When Meteor runs with the Rspack bundler enabled, this package is what generates - **Asset externals and HTML generation** through custom Rspack plugins - **A `defineConfig` helper** that accepts a factory function receiving Meteor environment flags and build utilities - **Customizable config** via `rspack.config.js` in your project root, with safe merging that warns if you try to override reserved settings -- **Automatic CSS delegation** — when rspack is configured with CSS, Less, or SCSS loaders, Meteor automatically detects the handled extensions after the first compilation and stops processing those files itself. No `.meteorignore` entries needed. +- **Automatic CSS delegation** when rspack is configured with CSS, Less, or SCSS loaders, Meteor automatically detects the handled extensions after the first compilation and stops processing those files itself in the entry folder context. No `.meteorignore` entries needed. ## Installation From 307b6b7fa1d2707b0da57407e25c6d9aa2d31fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Wed, 25 Mar 2026 15:25:50 +0100 Subject: [PATCH 24/53] print all ignores --- packages/rspack/lib/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rspack/lib/config.js b/packages/rspack/lib/config.js index 17b3aa61f8..70278d75ea 100644 --- a/packages/rspack/lib/config.js +++ b/packages/rspack/lib/config.js @@ -421,7 +421,7 @@ export function applyDelegatedExtensions(extensions) { setMeteorAppIgnore(ignorePatterns.join(' ')); if (isMeteorAppDebug() || isMeteorAppConfigModernVerbose()) { - logInfo(`[i] Rspack delegated extensions: ${extensions.join(', ')} (ignored in entry folders)`); + logInfo(`[i] Rspack delegated extensions: ${extensions.join(', ')} (ignored in entry folders)\n ${process.env.METEOR_IGNORE}`); } } } From 4b36e4af03287c730c4aff145781da1505bb507c Mon Sep 17 00:00:00 2001 From: 9Morello Date: Thu, 26 Mar 2026 08:51:52 -0300 Subject: [PATCH 25/53] Check if Preact is installed before installing React deps --- packages/rspack/lib/dependencies.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rspack/lib/dependencies.js b/packages/rspack/lib/dependencies.js index 20ebca4271..c6270637a0 100644 --- a/packages/rspack/lib/dependencies.js +++ b/packages/rspack/lib/dependencies.js @@ -213,7 +213,7 @@ export function checkReactInstalled() { const appDir = getMeteorAppDir(); // Check if React is a dependency in the project - const isReactInstalled = checkNpmDependencyExists('react', { cwd: appDir }); + const isReactInstalled = checkNpmDependencyExists('react', { cwd: appDir }) && !checkNpmDependencyExists('preact', { cwd: appDir }); if (isReactInstalled) { // Set environment variable to indicate React is enabled From d7638494e717667b1e5fa97cbf29b792b5cda8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 26 Mar 2026 16:56:15 +0100 Subject: [PATCH 26/53] add .coderabbit.yml configuration for review automation --- .coderabbit.yalm | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .coderabbit.yalm diff --git a/.coderabbit.yalm b/.coderabbit.yalm new file mode 100644 index 0000000000..b4edd06cab --- /dev/null +++ b/.coderabbit.yalm @@ -0,0 +1,95 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json + +language: "en-US" + +reviews: + profile: "chill" # community repo — keep it welcoming + request_changes_workflow: false + high_level_summary: true + poem: false # serious OSS platform + in_progress_fortune: false # noise + review_status: true + review_details: false + commit_status: true + collapse_walkthrough: true + changed_files_summary: true + sequence_diagrams: false # overkill for package-level PRs + estimate_code_review_effort: true + assess_linked_issues: true + related_issues: true + related_prs: true + suggested_labels: true + auto_apply_labels: false + suggested_reviewers: true + auto_assign_reviewers: false + + # Exclude generated, build, and Meteor-internal files + path_filters: + - "!**/node_modules/**" + - "!**/.meteor/**" + - "!**/bundle/**" + - "!**/programs/**" + - "!**/*.min.js" + - "!**/cordova-build/**" + - "!**/package-lock.json" + + path_instructions: + - path: "packages/**" + instructions: > + This is a core Meteor Atmosphere package. Focus on API backwards + compatibility, DDP/reactivity correctness, and client/server split. + Avoid nitpicking style — the codebase has legacy patterns. + - path: "tools/**" + instructions: > + This is the Meteor build tool (Isobuild). Be thorough about + correctness, edge cases, and performance in the CLI/build pipeline. + - path: "npm-packages/**" + instructions: > + These are npm packages published from the Meteor monorepo. + Check for correct exports, peer dependency handling, and Node.js compatibility. + - path: "v3-docs/**" + instructions: > + Documentation for Meteor v3. Check for accuracy, clarity, and + correct code examples. Grammar and spelling matter here. + - path: "scripts/**" + instructions: > + Build and CI scripts. Focus on correctness, portability, and + error handling. + + auto_review: + enabled: true + drafts: false + auto_incremental_review: true + auto_pause_after_reviewed_commits: 3 + ignore_title_keywords: + - "WIP" + - "DO NOT MERGE" + base_branches: [] + + finishing_touches: + docstrings: + enabled: false # legacy JS — too much noise across 100s of packages + unit_tests: + enabled: true + simplify: + enabled: false + + tools: + shellcheck: + enabled: true # ✅ they have .sh scripts in /scripts + markdownlint: + enabled: true # ✅ heavy docs contribution + languagetool: + enabled: true # ✅ useful for international doc contributors + level: "default" + disabled_categories: + - "TYPOGRAPHY" # too nitpicky for code comments + ruff: + enabled: false # ❌ not a Python project + biome: + enabled: false # ❌ they use ESLint already (.eslintignore exists) + ast-grep: + essential_rules: true + +chat: + auto_reply: true From 69f36ab27a64fc45704ab2c28ed62e3330abadfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 26 Mar 2026 17:03:22 +0100 Subject: [PATCH 27/53] update .coderabbit.yaml configuration --- .coderabbit.yalm => .coderabbit.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .coderabbit.yalm => .coderabbit.yaml (100%) diff --git a/.coderabbit.yalm b/.coderabbit.yaml similarity index 100% rename from .coderabbit.yalm rename to .coderabbit.yaml From a99f6e193789370a5738782e8e3ea08eb02cffd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 26 Mar 2026 17:07:22 +0100 Subject: [PATCH 28/53] re-run checks From d5b8f6c904bc102197b63c44eca77175dc2bfed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Thu, 26 Mar 2026 17:41:57 +0100 Subject: [PATCH 29/53] update .coderabbit.yaml to disable review_status --- .coderabbit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index b4edd06cab..ba6de87c22 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -8,7 +8,7 @@ reviews: high_level_summary: true poem: false # serious OSS platform in_progress_fortune: false # noise - review_status: true + review_status: false review_details: false commit_status: true collapse_walkthrough: true From f3b296efc834ed29b6971255209199f380b63e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 15:31:03 +0100 Subject: [PATCH 30/53] Add custom summary reporter to Jest configuration in e2e tests --- tools/e2e-tests/jest.config.js | 4 ++ tools/e2e-tests/summary-reporter.js | 95 +++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tools/e2e-tests/summary-reporter.js diff --git a/tools/e2e-tests/jest.config.js b/tools/e2e-tests/jest.config.js index f625e86ac5..3f62f89d54 100644 --- a/tools/e2e-tests/jest.config.js +++ b/tools/e2e-tests/jest.config.js @@ -30,4 +30,8 @@ module.exports = { } }, maxWorkers: 1, + reporters: [ + 'default', + '/summary-reporter.js', + ], }; diff --git a/tools/e2e-tests/summary-reporter.js b/tools/e2e-tests/summary-reporter.js new file mode 100644 index 0000000000..f10612d142 --- /dev/null +++ b/tools/e2e-tests/summary-reporter.js @@ -0,0 +1,95 @@ +/** + * Custom Jest reporter that prints a structured summary of all test results, + * including detailed error logs for failures. + */ +class SummaryReporter { + constructor(globalConfig) { + this._globalConfig = globalConfig; + } + + onRunComplete(_contexts, results) { + const passed = []; + const failed = []; + const skipped = []; + + for (const suite of results.testResults) { + for (const test of suite.testResults) { + const entry = { + name: test.fullName || test.title, + suite: suite.testFilePath.replace(this._globalConfig.rootDir + '/', ''), + duration: test.duration, + status: test.status, + }; + + if (test.status === 'passed') { + passed.push(entry); + } else if (test.status === 'failed') { + entry.errors = test.failureMessages || []; + failed.push(entry); + } else { + skipped.push(entry); + } + } + } + + this._printConsole(passed, failed, skipped); + } + + _printConsole(passed, failed, skipped) { + const divider = '═'.repeat(70); + const thinDivider = '─'.repeat(70); + + console.log('\n' + divider); + console.log(' E2E TEST SUMMARY'); + console.log(divider); + + if (passed.length > 0) { + console.log(`\n PASSED (${passed.length}):`); + console.log(thinDivider); + for (const t of passed) { + const duration = t.duration ? ` (${(t.duration / 1000).toFixed(1)}s)` : ''; + console.log(` [PASS] ${t.name}${duration}`); + } + } + + if (skipped.length > 0) { + console.log(`\n SKIPPED (${skipped.length}):`); + console.log(thinDivider); + for (const t of skipped) { + console.log(` [SKIP] ${t.name}`); + } + } + + if (failed.length > 0) { + console.log(`\n FAILED (${failed.length}):`); + console.log(thinDivider); + for (const t of failed) { + const duration = t.duration ? ` (${(t.duration / 1000).toFixed(1)}s)` : ''; + console.log(`\n [FAIL] ${t.name}${duration}`); + console.log(` Suite: ${t.suite}`); + for (const err of t.errors) { + const indented = err + .split('\n') + .map(line => ` ${line}`) + .join('\n'); + console.log(indented); + } + } + } + + const totalTime = [...passed, ...failed, ...skipped] + .reduce((sum, t) => sum + (t.duration || 0), 0); + + console.log('\n' + divider); + console.log( + ` TOTAL: ${passed.length + failed.length + skipped.length} | ` + + `PASSED: ${passed.length} | ` + + `FAILED: ${failed.length} | ` + + `SKIPPED: ${skipped.length} | ` + + `TIME: ${(totalTime / 1000).toFixed(1)}s` + ); + console.log(divider + '\n'); + } +} + +module.exports = SummaryReporter; From 94308d07d0ff47b2d90bee6316008796b753fcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 15:31:13 +0100 Subject: [PATCH 31/53] remove Jest retry logic for CI environment in e2e test setup --- tools/e2e-tests/jest.setup.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/e2e-tests/jest.setup.js b/tools/e2e-tests/jest.setup.js index 8b3f830a1f..3269f839a9 100644 --- a/tools/e2e-tests/jest.setup.js +++ b/tools/e2e-tests/jest.setup.js @@ -1,12 +1,6 @@ // jest.setup.js import chalk from 'chalk'; -const isCI = process.env.GITHUB_ACTIONS === "true"; -if (isCI) { - jest.retryTimes(2); - console.log('Set 2 retries on Jest level'); -} - // Clear NODE_ENV so meteor commands don't inherit any value from the test runner environment process.env.NODE_ENV = ''; From 873bbbcdf08c60caef2decc8d1a35c9c18b774b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 15:46:42 +0100 Subject: [PATCH 32/53] enhance E2E test summary reporter with color-coded output using `chalk` for better readability. --- tools/e2e-tests/summary-reporter.js | 41 ++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/tools/e2e-tests/summary-reporter.js b/tools/e2e-tests/summary-reporter.js index f10612d142..ec2593574f 100644 --- a/tools/e2e-tests/summary-reporter.js +++ b/tools/e2e-tests/summary-reporter.js @@ -1,3 +1,5 @@ +const chalk = require('chalk'); + /** * Custom Jest reporter that prints a structured summary of all test results, * including detailed error logs for failures. @@ -36,41 +38,44 @@ class SummaryReporter { } _printConsole(passed, failed, skipped) { - const divider = '═'.repeat(70); - const thinDivider = '─'.repeat(70); + const hasFails = failed.length > 0; + const divider = chalk.dim('═'.repeat(70)); + const thinDivider = chalk.dim('─'.repeat(70)); console.log('\n' + divider); - console.log(' E2E TEST SUMMARY'); + console.log(hasFails + ? chalk.bold.red(' E2E TEST SUMMARY') + : chalk.bold.green(' E2E TEST SUMMARY')); console.log(divider); if (passed.length > 0) { - console.log(`\n PASSED (${passed.length}):`); + console.log(chalk.green(`\n PASSED (${passed.length}):`)); console.log(thinDivider); for (const t of passed) { - const duration = t.duration ? ` (${(t.duration / 1000).toFixed(1)}s)` : ''; - console.log(` [PASS] ${t.name}${duration}`); + const duration = t.duration ? chalk.dim(` (${(t.duration / 1000).toFixed(1)}s)`) : ''; + console.log(` ${chalk.green('✓')} ${t.name}${duration}`); } } if (skipped.length > 0) { - console.log(`\n SKIPPED (${skipped.length}):`); + console.log(chalk.yellow(`\n SKIPPED (${skipped.length}):`)); console.log(thinDivider); for (const t of skipped) { - console.log(` [SKIP] ${t.name}`); + console.log(` ${chalk.yellow('○')} ${chalk.dim(t.name)}`); } } if (failed.length > 0) { - console.log(`\n FAILED (${failed.length}):`); + console.log(chalk.red(`\n FAILED (${failed.length}):`)); console.log(thinDivider); for (const t of failed) { - const duration = t.duration ? ` (${(t.duration / 1000).toFixed(1)}s)` : ''; - console.log(`\n [FAIL] ${t.name}${duration}`); - console.log(` Suite: ${t.suite}`); + const duration = t.duration ? chalk.dim(` (${(t.duration / 1000).toFixed(1)}s)`) : ''; + console.log(`\n ${chalk.red('✕')} ${chalk.bold(t.name)}${duration}`); + console.log(` ${chalk.dim('Suite:')} ${chalk.dim(t.suite)}`); for (const err of t.errors) { const indented = err .split('\n') - .map(line => ` ${line}`) + .map(line => ` ${chalk.red(line)}`) .join('\n'); console.log(indented); } @@ -82,11 +87,11 @@ class SummaryReporter { console.log('\n' + divider); console.log( - ` TOTAL: ${passed.length + failed.length + skipped.length} | ` + - `PASSED: ${passed.length} | ` + - `FAILED: ${failed.length} | ` + - `SKIPPED: ${skipped.length} | ` + - `TIME: ${(totalTime / 1000).toFixed(1)}s` + ` ${chalk.bold('TOTAL:')} ${passed.length + failed.length + skipped.length} ${chalk.dim('|')} ` + + `${chalk.green('PASSED:')} ${chalk.green(passed.length)} ${chalk.dim('|')} ` + + `${chalk.red('FAILED:')} ${chalk.red(failed.length)} ${chalk.dim('|')} ` + + `${chalk.yellow('SKIPPED:')} ${chalk.yellow(skipped.length)} ${chalk.dim('|')} ` + + `${chalk.dim('TIME:')} ${chalk.dim((totalTime / 1000).toFixed(1) + 's')}` ); console.log(divider + '\n'); } From 3ccea457686573d7038460df86c4a86c9a924caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 16:02:51 +0100 Subject: [PATCH 33/53] conditionally display skipped tests in E2E summary based on `E2E_SHOW_SKIPPED` environment variable --- tools/e2e-tests/summary-reporter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/e2e-tests/summary-reporter.js b/tools/e2e-tests/summary-reporter.js index ec2593574f..d0269d0298 100644 --- a/tools/e2e-tests/summary-reporter.js +++ b/tools/e2e-tests/summary-reporter.js @@ -57,7 +57,7 @@ class SummaryReporter { } } - if (skipped.length > 0) { + if (skipped.length > 0 && process.env.E2E_SHOW_SKIPPED) { console.log(chalk.yellow(`\n SKIPPED (${skipped.length}):`)); console.log(thinDivider); for (const t of skipped) { From 681d0df94eee02f3fd75b5ea6681698a2b5d8f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 16:04:15 +0100 Subject: [PATCH 34/53] refactor E2E workflow to replace retry action with custom retry steps for better control over test retries --- .github/workflows/e2e-tests.yml | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index ce29d07dfb..268af2df5c 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -86,10 +86,25 @@ jobs: run: ./meteor --get-ready - name: Run tests for ${{ matrix.category }} - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 15 - retry_wait_seconds: 90 - command: npm run test:e2e -- -t="${{ matrix.category }}" + id: test-run + continue-on-error: true + timeout-minutes: 15 + run: npm run test:e2e -- -t="${{ matrix.category }}" + + - name: Retry failed tests for ${{ matrix.category }} (attempt 2) + id: test-retry-1 + if: steps.test-run.outcome == 'failure' + continue-on-error: true + timeout-minutes: 15 + run: | + echo "::warning::First attempt failed, retrying..." + sleep 90 + npm run test:e2e -- -t="${{ matrix.category }}" + + - name: Retry failed tests for ${{ matrix.category }} (attempt 3) + if: steps.test-retry-1.outcome == 'failure' + timeout-minutes: 15 + run: | + echo "::warning::Second attempt failed, retrying..." + sleep 90 + npm run test:e2e -- -t="${{ matrix.category }}" From 65a0a0841be3468a622beee68a748e5414c31052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 16:59:54 +0100 Subject: [PATCH 35/53] update Rspack config to re-append unignore patterns for meteor.modules and add `modules` field to Vue E2E test app --- packages/rspack/lib/config.js | 12 +++++++++++- tools/e2e-tests/apps/vue/package.json | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/rspack/lib/config.js b/packages/rspack/lib/config.js index 70278d75ea..d2675e46e5 100644 --- a/packages/rspack/lib/config.js +++ b/packages/rspack/lib/config.js @@ -418,7 +418,17 @@ export function applyDelegatedExtensions(extensions) { } if (ignorePatterns.length > 0) { - setMeteorAppIgnore(ignorePatterns.join(' ')); + // Re-append meteor.modules unignore patterns after the delegation ignores + // so they take precedence (gitignore semantics: last match wins) + const meteorAppConfig = getMeteorAppConfig(); + const unignoredFilesAndFolders = buildUnignorePatterns( + meteorAppConfig?.modules || [], + { skipLevel: 1 }, + ); + + setMeteorAppIgnore( + [...ignorePatterns, ...unignoredFilesAndFolders].join(' ') + ); if (isMeteorAppDebug() || isMeteorAppConfigModernVerbose()) { logInfo(`[i] Rspack delegated extensions: ${extensions.join(', ')} (ignored in entry folders)\n ${process.env.METEOR_IGNORE}`); diff --git a/tools/e2e-tests/apps/vue/package.json b/tools/e2e-tests/apps/vue/package.json index 31c39838ad..a533902f34 100644 --- a/tools/e2e-tests/apps/vue/package.json +++ b/tools/e2e-tests/apps/vue/package.json @@ -34,6 +34,7 @@ "client": "client/main.js", "server": "server/main.js" }, + "modules": ["client/meteor.css"], "testModule": "tests/main.js" } } From 3642e3faca3ece88ec934d1d753e1e7aef78f962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 17:44:07 +0100 Subject: [PATCH 36/53] refactor `MeteorRspackOutputPlugin` to improve extension extraction logic; differentiate configured and delegated extensions --- .../plugins/MeteorRspackOutputPlugin.js | 35 +++++++++++++++++-- npm-packages/meteor-rspack/rspack.config.js | 2 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js index 274e938a7e..45986acb01 100644 --- a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js +++ b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js @@ -9,11 +9,10 @@ const { outputMeteorRspack } = require('../lib/meteorRspackHelpers'); /** * Extracts file extensions that rspack is configured to handle * from the resolved module.rules test patterns. - * Only returns extensions relevant for Meteor delegation (CSS-family). * @param {import('@rspack/core').Compiler} compiler - * @returns {string[]} Array of extensions like ['.css', '.less', '.scss'] + * @returns {Set} Set of extensions like .css, .less, .scss */ -function extractDelegatedExtensions(compiler) { +function extractConfiguredExtensions(compiler) { const delegatableExtensions = ['.css', '.less', '.scss', '.sass', '.styl']; const found = new Set(); @@ -37,6 +36,36 @@ function extractDelegatedExtensions(compiler) { } inspectRules(compiler.options.module?.rules || []); + return found; +} + +/** + * Extracts file extensions that rspack both has rules for AND actually compiled. + * An extension is only delegated if it appears in the config rules and at least + * one file with that extension was part of the compilation dependency graph. + * This prevents Meteor from ignoring files that Rspack is configured for but + * never actually processes. + * @param {import('@rspack/core').Stats} stats + * @param {import('@rspack/core').Compiler} compiler + * @returns {string[]} Array of extensions like ['.css', '.less', '.scss'] + */ +function extractDelegatedExtensions(stats, compiler) { + const configured = extractConfiguredExtensions(compiler); + if (configured.size === 0) return []; + + const found = new Set(); + const path = require('path'); + + for (const module of stats.compilation.modules) { + const resource = module.resource || module.userRequest; + if (!resource) continue; + const ext = path.extname(resource); + if (configured.has(ext)) { + found.add(ext); + if (found.size === configured.size) break; + } + } + return Array.from(found); } diff --git a/npm-packages/meteor-rspack/rspack.config.js b/npm-packages/meteor-rspack/rspack.config.js index c83a9cfd57..e700538991 100644 --- a/npm-packages/meteor-rspack/rspack.config.js +++ b/npm-packages/meteor-rspack/rspack.config.js @@ -854,7 +854,7 @@ module.exports = async function (inMeteor = {}, argv = {}) { compilationCount, isRebuild, ...(!isRebuild && compiler && { - delegatedExtensions: extractDelegatedExtensions(compiler), + delegatedExtensions: extractDelegatedExtensions(stats, compiler), }), }), }); From 80a7c7790dfaeda6a0831c8c9f5e104dda2f8c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 17:55:16 +0100 Subject: [PATCH 37/53] update `MeteorRspackOutputPlugin` to refine extension extraction; prioritize entry folder files for delegation --- .../plugins/MeteorRspackOutputPlugin.js | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js index 45986acb01..548e4183ab 100644 --- a/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js +++ b/npm-packages/meteor-rspack/plugins/MeteorRspackOutputPlugin.js @@ -40,11 +40,11 @@ function extractConfiguredExtensions(compiler) { } /** - * Extracts file extensions that rspack both has rules for AND actually compiled. - * An extension is only delegated if it appears in the config rules and at least - * one file with that extension was part of the compilation dependency graph. - * This prevents Meteor from ignoring files that Rspack is configured for but - * never actually processes. + * Extracts file extensions that rspack both has rules for AND actually compiled + * from files within entry folder paths (e.g. client/, server/). + * An extension is only delegated if Rspack compiled a file with that extension + * from an entry folder. Files in non-entry folders (e.g. imports/) don't count, + * since delegation only ignores entry folder files for Meteor. * @param {import('@rspack/core').Stats} stats * @param {import('@rspack/core').Compiler} compiler * @returns {string[]} Array of extensions like ['.css', '.less', '.scss'] @@ -53,12 +53,39 @@ function extractDelegatedExtensions(stats, compiler) { const configured = extractConfiguredExtensions(compiler); if (configured.size === 0) return []; - const found = new Set(); const path = require('path'); + const fs = require('fs'); + const appRoot = compiler.options.context || process.cwd(); + + // Read entry folders from package.json meteor.mainModule + const entryFolders = new Set(); + try { + const pkgPath = path.join(appRoot, 'package.json'); + const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); + const mainModule = pkg?.meteor?.mainModule || {}; + for (const entry of Object.values(mainModule)) { + if (typeof entry === 'string') { + const folder = entry.split('/')[0]; + if (folder) entryFolders.add(folder); + } + } + } catch (e) { + // If we can't read package.json, fall back to config-only + return Array.from(configured); + } + + if (entryFolders.size === 0) return Array.from(configured); + + const found = new Set(); for (const module of stats.compilation.modules) { const resource = module.resource || module.userRequest; if (!resource) continue; + + const relativePath = path.relative(appRoot, resource); + const topFolder = relativePath.split(path.sep)[0]; + if (!entryFolders.has(topFolder)) continue; + const ext = path.extname(resource); if (configured.has(ext)) { found.add(ext); From facf6fa7c533cddf6d8ecc1f7c417a0112e6b661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Fri, 27 Mar 2026 18:08:57 +0100 Subject: [PATCH 38/53] document CSS auto-delegation and `meteor.modules` config updates in Rspack E2E coverage --- dev/modern-tools/rspack/E2E_COVERAGE.md | 11 ++++++++--- tools/e2e-tests/apps/vue/.meteorignore | 2 -- tools/static-assets/skel-tailwind/.meteorignore | 2 -- 3 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 tools/e2e-tests/apps/vue/.meteorignore delete mode 100644 tools/static-assets/skel-tailwind/.meteorignore diff --git a/dev/modern-tools/rspack/E2E_COVERAGE.md b/dev/modern-tools/rspack/E2E_COVERAGE.md index 1199c73a50..d656fcd7b2 100644 --- a/dev/modern-tools/rspack/E2E_COVERAGE.md +++ b/dev/modern-tools/rspack/E2E_COVERAGE.md @@ -54,7 +54,7 @@ Full-featured React Router app with custom packages, Less, and advanced rspack c | Compiler output cached in dev (babel.config.js) | Run | | 404 page routing (renders "Page Not Found") | Run, Prod | | Less stylesheet support (`white-space: break-spaces`) | Run, Prod | -| Meteor modules config styles (`align-content: center`) | Run, Prod | +| `meteor.modules` config styles (`align-content: center`) | Run, Prod | | Custom HTML meta tags (`theme-color`) | Run, Prod | | Default + custom package loading | Run | | `resolve.extensions` loading (`.jsx`) | Run | @@ -132,12 +132,15 @@ CoffeeScript language support. ### vue -Vue.js framework with Tailwind CSS. +Vue.js framework with Tailwind CSS, CSS auto-delegation, and `meteor.modules` config. | What is covered | Phase | |----------------|-------| | Vue single-file components | All | | Tailwind CSS styles (`.p-8` padding) | Run, Prod | +| CSS auto-delegation (`client/main.css` processed by Rspack, not Meteor) | All | +| `meteor.modules` config preserves `client/meteor.css` for Meteor processing | All | +| Rspack CSS + Meteor CSS coexistence in same entry folder | All | | HMR works in dev, disabled in prod | Run, Prod | ### solid @@ -262,7 +265,7 @@ Where each feature is tested across apps and skeletons. | Static asset bundling | react-router, monorepo | | | Less styles | react-router | | | SCSS styles | typescript | | -| Tailwind CSS | vue | tailwind | +| Tailwind CSS | vue (PostCSS) | tailwind | | Image asset loading | react | | | 404 routing | react-router | | | Meta tags | react-router | | @@ -278,6 +281,8 @@ Where each feature is tested across apps and skeletons. | Custom NODE_ENV compilation | babel | | | Portable build (no isDev/isProd defines) | typescript | | | `Meteor.extendSwcConfig` (path aliases) | typescript | | +| CSS auto-delegation (entry folder filtering) | vue | | +| `meteor.modules` config (preserve files for Meteor) | react-router, vue | | | `meteor reset` cleanup | all apps | all skeletons | | Skeleton creation | | all 14 skeletons | | Body style assertions | | react, tailwind (custom); most others (default) | diff --git a/tools/e2e-tests/apps/vue/.meteorignore b/tools/e2e-tests/apps/vue/.meteorignore deleted file mode 100644 index 21d63e9485..0000000000 --- a/tools/e2e-tests/apps/vue/.meteorignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore client/main.css file so that is processed by Rspack import -client/main.css diff --git a/tools/static-assets/skel-tailwind/.meteorignore b/tools/static-assets/skel-tailwind/.meteorignore deleted file mode 100644 index 4568c54a7d..0000000000 --- a/tools/static-assets/skel-tailwind/.meteorignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore Meteor CSS handling; let Rspack resolve Tailwind styles -client/main.css From 9c9d400260ff54c500db3735cfe31e4a0444e8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 09:45:30 +0200 Subject: [PATCH 39/53] add `checkout-pr` script and update documentation for testing fork branches locally --- CONTRIBUTING.md | 8 ++ DEVELOPMENT.md | 26 ++++ scripts/checkout-pr.js | 261 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 295 insertions(+) create mode 100755 scripts/checkout-pr.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c646fad457..40ac2548f1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,14 @@ Current Reviewers: - [@zodern](https://github.com/zodern) - [@radekmie](https://github.com/radekmie) +##### Testing a contributor's branch locally + +To quickly check out a PR branch from a fork for local testing, see the [Testing a fork branch](DEVELOPMENT.md#testing-a-fork-branch) section in `DEVELOPMENT.md`, or run: + +```sh +node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ +``` + #### Core Committer The contributors with commit access to meteor/meteor are employees of Meteor Software LP or community members who have distinguished themselves in other contribution areas or members of partner companies. If you want to become a core committer, please start writing PRs. diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 58eda23621..e8c49ab999 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -56,6 +56,32 @@ can run Meteor directly from a Git checkout using these steps: > > Then you can use the chrome debugger inside `chrome://inspect`. +### Testing a fork branch + +When reviewing a pull request or testing changes from a contributor's fork, use the `checkout-pr.js` script to set up a local branch automatically: + +```sh +# From a PR URL (requires gh CLI or falls back to GitHub API via curl) +$ node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ + +# From a user:branch shorthand +$ node scripts/checkout-pr.js : + +# From a full fork repo URL and branch name +$ node scripts/checkout-pr.js +``` + +The script will: + +1. Add the fork as a git remote (named after the fork owner) if not already present +2. Fetch the target branch +3. Create (or update) a local branch named `fork//` +4. Print instructions for switching back to your previous branch + +For upstream PRs (branches on `meteor/meteor` itself), the script detects the existing `origin` remote and checks out the branch directly without the `fork/` prefix. + +If you run the script again for the same fork branch, it will fetch the latest changes and update the local branch. + ### Notes when running from a checkout The following are some distinct differences you must pay attention to when running Meteor from a checkout: diff --git a/scripts/checkout-pr.js b/scripts/checkout-pr.js new file mode 100755 index 0000000000..f904f2a5ac --- /dev/null +++ b/scripts/checkout-pr.js @@ -0,0 +1,261 @@ +#!/usr/bin/env node +// +// checkout-pr.js — prepare a local branch from a fork contribution +// +// Usage: +// node scripts/checkout-pr.js +// node scripts/checkout-pr.js : +// node scripts/checkout-pr.js +// +// Examples: +// node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ +// node scripts/checkout-pr.js : +// node scripts/checkout-pr.js + +'use strict'; + +const { execSync } = require('child_process'); +const https = require('https'); + +// Colors (disabled if stdout is not a TTY) +const isTTY = process.stdout.isTTY; +const c = { + red: isTTY ? '\x1b[0;31m' : '', + green: isTTY ? '\x1b[0;32m' : '', + yellow: isTTY ? '\x1b[0;33m' : '', + cyan: isTTY ? '\x1b[0;36m' : '', + bold: isTTY ? '\x1b[1m' : '', + reset: isTTY ? '\x1b[0m' : '', +}; + +function info(msg) { console.log(`${c.cyan}\u2192${c.reset} ${msg}`); } +function ok(msg) { console.log(`${c.green}\u2713${c.reset} ${msg}`); } +function warn(msg) { console.log(`${c.yellow}\u26A0${c.reset} ${msg}`); } +function err(msg) { console.error(`${c.red}\u2717${c.reset} ${msg}`); } + +function die(msg) { + err(msg); + process.exit(1); +} + +function usage() { + console.log(`Usage: + checkout-pr.js + checkout-pr.js : + checkout-pr.js + +Prepares a local branch from a fork contribution for testing and review. + +Examples: + node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ + node scripts/checkout-pr.js : + node scripts/checkout-pr.js `); + process.exit(1); +} + +function git(cmd, { silent = false } = {}) { + try { + return execSync(`git ${cmd}`, { + encoding: 'utf8', + stdio: silent ? ['pipe', 'pipe', 'pipe'] : ['pipe', 'pipe', 'inherit'], + }).trim(); + } catch (e) { + if (silent) return null; + throw e; + } +} + +function ghCli(args) { + try { + return execSync(`gh ${args}`, { encoding: 'utf8', stdio: 'pipe' }).trim(); + } catch { + return null; + } +} + +function hasCommand(name) { + try { + execSync(process.platform === 'win32' ? `where ${name}` : `command -v ${name}`, { stdio: 'pipe' }); + return true; + } catch { + return false; + } +} + +function httpsGet(url) { + return new Promise((resolve, reject) => { + https.get(url, { headers: { 'User-Agent': 'meteor-checkout-pr' } }, (res) => { + if (res.statusCode < 200 || res.statusCode >= 300) { + return reject(new Error(`HTTP ${res.statusCode}`)); + } + let data = ''; + res.on('data', (chunk) => { data += chunk; }); + res.on('end', () => resolve(data)); + }).on('error', reject); + }); +} + +async function extractFromPrUrl(prUrl) { + const match = prUrl.match(/^https?:\/\/github\.com\/([^/]+\/[^/]+)\/pull\/(\d+)/); + if (!match) die(`could not parse PR URL: ${prUrl}`); + const [, repoPath, prNumber] = match; + + // Try gh CLI first + if (hasCommand('gh')) { + const result = ghCli(`pr view "${prUrl}" --json headRepositoryOwner,headRefName`); + if (result) { + try { + const data = JSON.parse(result); + const owner = data.headRepositoryOwner?.login; + const branch = data.headRefName; + if (owner && branch) return { owner, branch }; + } catch { /* fall through */ } + } + } + + // Fall back to GitHub REST API + const apiUrl = `https://api.github.com/repos/${repoPath}/pulls/${prNumber}`; + let body; + try { + body = await httpsGet(apiUrl); + } catch (e) { + die(`could not fetch PR data from ${apiUrl} (${e.message})`); + } + + try { + const data = JSON.parse(body); + const owner = data.head?.user?.login; + const branch = data.head?.ref; + if (owner && branch) return { owner, branch }; + } catch { /* fall through */ } + + die(`could not extract fork owner/branch from PR #${prNumber}`); +} + +function extractOwnerFromUrl(url) { + const match = url.match(/github\.com[:/]([^/]+)\//); + return match ? match[1] : null; +} + +function normalizeUrl(url) { + return url + .replace(/\.git$/, '') + .replace(/\/$/, '') + .replace(/^https?:\/\//, '') + .replace(/^git@github\.com:/, 'github.com/'); +} + +async function main() { + const args = process.argv.slice(2); + + // Ensure we're inside a git repo + if (!git('rev-parse --is-inside-work-tree', { silent: true })) { + die('not inside a git repository'); + } + + let forkOwner, forkBranch, forkRepoUrl; + + if (args.length === 0) { + usage(); + } else if (args.length === 1) { + const arg = args[0]; + const prMatch = arg.match(/^https?:\/\/github\.com\/.*\/pull\/\d+/); + const shortMatch = arg.match(/^([^:]+):(.+)$/); + + if (prMatch) { + const result = await extractFromPrUrl(arg); + forkOwner = result.owner; + forkBranch = result.branch; + forkRepoUrl = `https://github.com/${forkOwner}/meteor.git`; + } else if (shortMatch) { + forkOwner = shortMatch[1]; + forkBranch = shortMatch[2]; + forkRepoUrl = `https://github.com/${forkOwner}/meteor.git`; + } else { + err(`unrecognized format: ${arg}`); + console.error(''); + usage(); + } + } else if (args.length === 2) { + forkRepoUrl = args[0]; + forkBranch = args[1]; + forkOwner = extractOwnerFromUrl(forkRepoUrl); + if (!forkOwner) die(`could not extract owner from URL: ${forkRepoUrl}`); + } else { + usage(); + } + + const previousBranch = git('symbolic-ref --short HEAD', { silent: true }) + || git('rev-parse --short HEAD', { silent: true }) + || 'HEAD'; + + // Detect if the PR is from the upstream repo (not a fork) + let remoteName = ''; + let isUpstream = false; + const originUrl = git('remote get-url origin', { silent: true }); + if (originUrl) { + const normFork = normalizeUrl(forkRepoUrl); + const normOrigin = normalizeUrl(originUrl); + if (normFork === normOrigin) { + remoteName = 'origin'; + isUpstream = true; + } + } + + let localBranch; + if (isUpstream) { + localBranch = forkBranch; + } else { + remoteName = forkOwner; + localBranch = `fork/${forkOwner}/${forkBranch}`; + } + + console.log(`${c.bold}--- checkout-pr ---${c.reset}`); + info(`owner: ${c.bold}${forkOwner}${c.reset}`); + info(`branch: ${c.bold}${forkBranch}${c.reset}`); + info(`repo: ${c.bold}${forkRepoUrl}${c.reset}`); + if (isUpstream) { + info(`upstream: yes (using remote '${c.bold}${remoteName}${c.reset}')`); + } + info(`local branch: ${c.bold}${localBranch}${c.reset}`); + console.log(''); + + // Add remote if needed (skip for upstream PRs) + if (!isUpstream) { + const existingUrl = git(`remote get-url "${remoteName}"`, { silent: true }); + if (existingUrl) { + warn(`remote '${remoteName}' already exists, reusing it`); + } else { + info(`adding remote '${remoteName}' \u2192 ${forkRepoUrl}`); + git(`remote add "${remoteName}" "${forkRepoUrl}"`); + ok(`remote '${remoteName}' added`); + } + } + + // Fetch the branch + info(`fetching '${forkBranch}' from '${remoteName}'...`); + const fetchResult = git(`fetch "${remoteName}" "${forkBranch}"`, { silent: true }); + if (fetchResult === null) { + die(`failed to fetch branch '${forkBranch}' from '${remoteName}' \u2014 check that the fork and branch exist`); + } + ok(`fetched latest from '${remoteName}'`); + + // Create or switch to local branch + const branchExists = git(`show-ref --verify "refs/heads/${localBranch}"`, { silent: true }); + if (branchExists) { + warn(`branch '${localBranch}' already exists, switching and updating...`); + git(`checkout "${localBranch}"`); + git(`reset --hard "refs/remotes/${remoteName}/${forkBranch}"`); + } else { + info(`creating branch '${localBranch}'...`); + git(`checkout -b "${localBranch}" "refs/remotes/${remoteName}/${forkBranch}"`); + } + + console.log(''); + ok(`ready on branch: ${c.bold}${localBranch}${c.reset}`); + info(`to switch back: ${c.bold}git checkout ${previousBranch}${c.reset}`); +} + +main().catch((e) => { + die(e.message); +}); From 37816052f0285ba84bc24e4bb92d73ebe658ae0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 12:23:27 +0200 Subject: [PATCH 40/53] Add @swc/core as a peer dependency --- npm-packages/meteor-rspack/package-lock.json | 265 ++++++++++++++++++- npm-packages/meteor-rspack/package.json | 3 +- 2 files changed, 266 insertions(+), 2 deletions(-) diff --git a/npm-packages/meteor-rspack/package-lock.json b/npm-packages/meteor-rspack/package-lock.json index 7792758d69..739b4cd71d 100644 --- a/npm-packages/meteor-rspack/package-lock.json +++ b/npm-packages/meteor-rspack/package-lock.json @@ -16,7 +16,8 @@ }, "peerDependencies": { "@rspack/cli": ">=1.3.0", - "@rspack/core": ">=1.3.0" + "@rspack/core": ">=1.3.0", + "@swc/core": ">=1.3.0" } }, "node_modules/@discoveryjs/json-ext": { @@ -491,6 +492,268 @@ "node": ">=16.0.0" } }, + "node_modules/@swc/core": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.21.tgz", + "integrity": "sha512-fkk7NJcBscrR3/F8jiqlMptRHP650NxqDnspBMrRe5d8xOoCy9MLL5kOBLFXjFLfMo3KQQHhk+/jUULOMlR1uQ==", + "hasInstallScript": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.25" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.15.21", + "@swc/core-darwin-x64": "1.15.21", + "@swc/core-linux-arm-gnueabihf": "1.15.21", + "@swc/core-linux-arm64-gnu": "1.15.21", + "@swc/core-linux-arm64-musl": "1.15.21", + "@swc/core-linux-ppc64-gnu": "1.15.21", + "@swc/core-linux-s390x-gnu": "1.15.21", + "@swc/core-linux-x64-gnu": "1.15.21", + "@swc/core-linux-x64-musl": "1.15.21", + "@swc/core-win32-arm64-msvc": "1.15.21", + "@swc/core-win32-ia32-msvc": "1.15.21", + "@swc/core-win32-x64-msvc": "1.15.21" + }, + "peerDependencies": { + "@swc/helpers": ">=0.5.17" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.21.tgz", + "integrity": "sha512-SA8SFg9dp0qKRH8goWsax6bptFE2EdmPf2YRAQW9WoHGf3XKM1bX0nd5UdwxmC5hXsBUZAYf7xSciCler6/oyA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.21.tgz", + "integrity": "sha512-//fOVntgowz9+V90lVsNCtyyrtbHp3jWH6Rch7MXHXbcvbLmbCTmssl5DeedUWLLGiAAW1wksBdqdGYOTjaNLw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.21.tgz", + "integrity": "sha512-meNI4Sh6h9h8DvIfEc0l5URabYMSuNvyisLmG6vnoYAS43s8ON3NJR8sDHvdP7NJTrLe0q/x2XCn6yL/BeHcZg==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.21.tgz", + "integrity": "sha512-QrXlNQnHeXqU2EzLlnsPoWEh8/GtNJLvfMiPsDhk+ht6Xv8+vhvZ5YZ/BokNWSIZiWPKLAqR0M7T92YF5tmD3g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.21.tgz", + "integrity": "sha512-8/yGCMO333ultDaMQivE5CjO6oXDPeeg1IV4sphojPkb0Pv0i6zvcRIkgp60xDB+UxLr6VgHgt+BBgqS959E9g==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-ppc64-gnu": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.21.tgz", + "integrity": "sha512-ucW0HzPx0s1dgRvcvuLSPSA/2Kk/VYTv9st8qe1Kc22Gu0Q0rH9+6TcBTmMuNIp0Xs4BPr1uBttmbO1wEGI49Q==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-s390x-gnu": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.21.tgz", + "integrity": "sha512-ulTnOGc5I7YRObE/9NreAhQg94QkiR5qNhhcUZ1iFAYjzg/JGAi1ch+s/Ixe61pMIr8bfVrF0NOaB0f8wjaAfA==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.21.tgz", + "integrity": "sha512-D0RokxtM+cPvSqJIKR6uja4hbD+scI9ezo95mBhfSyLUs9wnPPl26sLp1ZPR/EXRdYm3F3S6RUtVi+8QXhT24Q==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.21.tgz", + "integrity": "sha512-nER8u7VeRfmU6fMDzl1NQAbbB/G7O2avmvCOwIul1uGkZ2/acbPH+DCL9h5+0yd/coNcxMBTL6NGepIew+7C2w==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.21.tgz", + "integrity": "sha512-+/AgNBnjYugUA8C0Do4YzymgvnGbztv7j8HKSQLvR/DQgZPoXQ2B3PqB2mTtGh/X5DhlJWiqnunN35JUgWcAeQ==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.21.tgz", + "integrity": "sha512-IkSZj8PX/N4HcaFhMQtzmkV8YSnuNoJ0E6OvMwFiOfejPhiKXvl7CdDsn1f4/emYEIDO3fpgZW9DTaCRMDxaDA==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.15.21", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.21.tgz", + "integrity": "sha512-zUyWso7OOENB6e1N1hNuNn8vbvLsTdKQ5WKLgt/JcBNfJhKy/6jmBmqI3GXk/MyvQKd5SLvP7A0F36p7TeDqvw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "license": "Apache-2.0", + "peer": true + }, + "node_modules/@swc/types": { + "version": "0.1.26", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.26.tgz", + "integrity": "sha512-lyMwd7WGgG79RS7EERZV3T8wMdmPq3xwyg+1nmAM64kIhx5yl+juO2PYIHb7vTiPgPCj8LYjsNV2T5wiQHUEaw==", + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, "node_modules/@tybys/wasm-util": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.0.tgz", diff --git a/npm-packages/meteor-rspack/package.json b/npm-packages/meteor-rspack/package.json index 2bcbb679c2..a880bf3f19 100644 --- a/npm-packages/meteor-rspack/package.json +++ b/npm-packages/meteor-rspack/package.json @@ -14,6 +14,7 @@ }, "peerDependencies": { "@rspack/cli": ">=1.3.0", - "@rspack/core": ">=1.3.0" + "@rspack/core": ">=1.3.0", + "@swc/core": ">=1.3.0" } } From 5741635e307a7027e3080c640ea8544f7f3c5a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 12:24:29 +0200 Subject: [PATCH 41/53] replace `hasOwnProperty` usage with `Object.prototype.hasOwnProperty.call` for better reliability. --- npm-packages/meteor-rspack/lib/localDependenciesHelpers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js index cea36e9c92..e1ad321fbb 100644 --- a/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js +++ b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js @@ -96,7 +96,7 @@ function visitNode(node, callback) { // Visit all properties of the node for (const key in node) { - if (node.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(node, key)) { const value = node[key]; if (Array.isArray(value)) { value.forEach(child => visitNode(child, callback)); From 17bfd1950dc3da7092fb91903c50388798de5941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 12:26:31 +0200 Subject: [PATCH 42/53] simplify logic for resolving module paths with better extension and directory handling --- .../lib/localDependenciesHelpers.js | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js index e1ad321fbb..b43199d87e 100644 --- a/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js +++ b/npm-packages/meteor-rspack/lib/localDependenciesHelpers.js @@ -122,10 +122,26 @@ function resolveLocalModule(modulePath, configDir, projectDir) { try { let resolvedPath = path.resolve(configDir, modulePath); + const extensions = ['.js', '.mjs', '.cjs', '.ts', '.json']; - // Try common extensions if file doesn't exist as-is - if (!fs.existsSync(resolvedPath)) { - const extensions = ['.js', '.mjs', '.cjs', '.ts', '.json']; + // If the path exists as-is, check if it's a directory needing index resolution + if (fs.existsSync(resolvedPath)) { + if (fs.statSync(resolvedPath).isDirectory()) { + let found = false; + for (const ext of extensions) { + const indexPath = path.join(resolvedPath, `index${ext}`); + if (fs.existsSync(indexPath)) { + resolvedPath = indexPath; + found = true; + break; + } + } + if (!found) { + return null; + } + } + } else { + // Try common extensions if file doesn't exist as-is let found = false; for (const ext of extensions) { @@ -137,18 +153,6 @@ function resolveLocalModule(modulePath, configDir, projectDir) { } } - // If not found with extension, try index files in directory - if (!found && fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) { - for (const ext of extensions) { - const indexPath = path.join(resolvedPath, `index${ext}`); - if (fs.existsSync(indexPath)) { - resolvedPath = indexPath; - found = true; - break; - } - } - } - // If still not found, return null if (!found) { return null; From 8f8ed8ccb4c59fd23f6919c2b69ad803a0452106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 14:15:28 +0200 Subject: [PATCH 43/53] support SSH-based fork URLs and add clear error handling for unrecognized repo formats in checkout-pr script --- scripts/checkout-pr.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/checkout-pr.js b/scripts/checkout-pr.js index f904f2a5ac..1b174899b0 100755 --- a/scripts/checkout-pr.js +++ b/scripts/checkout-pr.js @@ -145,6 +145,15 @@ function normalizeUrl(url) { .replace(/^git@github\.com:/, 'github.com/'); } +function buildForkUrl(owner) { + // Match origin's protocol (SSH vs HTTPS) + const originUrl = git('remote get-url origin', { silent: true }) || ''; + if (originUrl.startsWith('git@')) { + return `git@github.com:${owner}/meteor.git`; + } + return `https://github.com/${owner}/meteor.git`; +} + async function main() { const args = process.argv.slice(2); @@ -160,17 +169,22 @@ async function main() { } else if (args.length === 1) { const arg = args[0]; const prMatch = arg.match(/^https?:\/\/github\.com\/.*\/pull\/\d+/); - const shortMatch = arg.match(/^([^:]+):(.+)$/); + const sshMatch = arg.match(/^git@[^:]+:/); + const httpsRepoMatch = arg.match(/^https?:\/\/.*\.git$/); + // user:branch — must not start with git@ (SSH) or contain / before : (URLs) + const shortMatch = !sshMatch && arg.match(/^([^/:]+):(.+)$/); if (prMatch) { const result = await extractFromPrUrl(arg); forkOwner = result.owner; forkBranch = result.branch; - forkRepoUrl = `https://github.com/${forkOwner}/meteor.git`; + forkRepoUrl = buildForkUrl(forkOwner); + } else if (sshMatch || httpsRepoMatch) { + die(`repo URL requires a branch argument: node scripts/checkout-pr.js ${arg} `); } else if (shortMatch) { forkOwner = shortMatch[1]; forkBranch = shortMatch[2]; - forkRepoUrl = `https://github.com/${forkOwner}/meteor.git`; + forkRepoUrl = buildForkUrl(forkOwner); } else { err(`unrecognized format: ${arg}`); console.error(''); From 7ec1dd5948dddcfbb767a5f7ca2026e946fc084a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 14:17:57 +0200 Subject: [PATCH 44/53] add `checkout:pr` npm script and update documentation usage --- CONTRIBUTING.md | 2 +- DEVELOPMENT.md | 8 ++++---- package.json | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 40ac2548f1..04902faabf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ Current Reviewers: To quickly check out a PR branch from a fork for local testing, see the [Testing a fork branch](DEVELOPMENT.md#testing-a-fork-branch) section in `DEVELOPMENT.md`, or run: ```sh -node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ +npm run checkout:pr -- https://github.com/meteor/meteor/pull/ ``` #### Core Committer diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 9c5c216561..80f6cbf585 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -70,13 +70,13 @@ When reviewing a pull request or testing changes from a contributor's fork, use ```sh # From a PR URL (requires gh CLI or falls back to GitHub API via curl) -$ node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ +$ npm run checkout:pr -- https://github.com/meteor/meteor/pull/ # From a user:branch shorthand -$ node scripts/checkout-pr.js : +$ npm run checkout:pr -- : -# From a full fork repo URL and branch name -$ node scripts/checkout-pr.js +# From a full fork repo URL and branch name (HTTPS or SSH) +$ npm run checkout:pr -- ``` The script will: diff --git a/package.json b/package.json index 9c096fcd0a..6c4f6cc640 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "test:unit": "cd tools/unit-tests && npm test", "test:idle-bot": "node --test .github/scripts/__tests__/inactive-issues.test.js", "install:e2e": "cd tools/modern-tests && npm install && npx playwright install --with-deps chromium chromium-headless-shell", - "test:e2e": "cd tools/modern-tests && npm test -- " + "test:e2e": "cd tools/modern-tests && npm test -- ", + "checkout:pr": "node scripts/checkout-pr.js" }, "jshintConfig": { "esversion": 11 From f1a0d2677805aae9ddab034adcb14f22febb58d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 14:21:04 +0200 Subject: [PATCH 45/53] sdd SSH fork URL support to `checkout:pr` script and usage documentation --- DEVELOPMENT.md | 5 ++++- scripts/checkout-pr.js | 16 ++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 80f6cbf585..bf5c84193f 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -75,8 +75,11 @@ $ npm run checkout:pr -- https://github.com/meteor/meteor/pull/ # From a user:branch shorthand $ npm run checkout:pr -- : -# From a full fork repo URL and branch name (HTTPS or SSH) +# From a full fork repo URL and branch name (HTTPS) $ npm run checkout:pr -- + +# From a full fork repo URL and branch name (SSH) +$ npm run checkout:pr -- git@github.com:/.git ``` The script will: diff --git a/scripts/checkout-pr.js b/scripts/checkout-pr.js index 1b174899b0..d0c1e32ebd 100755 --- a/scripts/checkout-pr.js +++ b/scripts/checkout-pr.js @@ -6,11 +6,13 @@ // node scripts/checkout-pr.js // node scripts/checkout-pr.js : // node scripts/checkout-pr.js +// node scripts/checkout-pr.js git@github.com:/.git // // Examples: // node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ // node scripts/checkout-pr.js : // node scripts/checkout-pr.js +// node scripts/checkout-pr.js git@github.com:/.git 'use strict'; @@ -40,16 +42,18 @@ function die(msg) { function usage() { console.log(`Usage: - checkout-pr.js - checkout-pr.js : - checkout-pr.js + npm run checkout:pr -- + npm run checkout:pr -- : + npm run checkout:pr -- + npm run checkout:pr -- git@github.com:/.git Prepares a local branch from a fork contribution for testing and review. Examples: - node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ - node scripts/checkout-pr.js : - node scripts/checkout-pr.js `); + npm run checkout:pr -- https://github.com/meteor/meteor/pull/ + npm run checkout:pr -- : + npm run checkout:pr -- + npm run checkout:pr -- git@github.com:/.git `); process.exit(1); } From 8cc1efa34bce5ec7477d6158ba28669828a83397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 16:28:46 +0200 Subject: [PATCH 46/53] add demo unplugin to Rspack config and E2E tests for cache tracking --- dev/modern-tools/rspack/E2E_COVERAGE.md | 10 +++++ tools/e2e-tests/apps/react/package.json | 1 + .../apps/react/plugins/demo-unplugin.js | 30 +++++++++++++ tools/e2e-tests/apps/react/rspack.config.cjs | 3 +- tools/e2e-tests/react.test.js | 42 ++++++++++++++++--- 5 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 tools/e2e-tests/apps/react/plugins/demo-unplugin.js diff --git a/dev/modern-tools/rspack/E2E_COVERAGE.md b/dev/modern-tools/rspack/E2E_COVERAGE.md index 1199c73a50..f01e58e4c3 100644 --- a/dev/modern-tools/rspack/E2E_COVERAGE.md +++ b/dev/modern-tools/rspack/E2E_COVERAGE.md @@ -40,6 +40,9 @@ Core React integration with custom Meteor local directory. | React + JSX environment detection | Run, Prod, Test, Build | | Image assets load (generated + public + background) | Run, Prod | | `Meteor.disablePlugins` suppresses rspack plugins | Run, Prod, Test, Build | +| Unplugin transform hook fires on first run (fresh cache) | Init | +| Unplugin factory created on cached run — #14031 regression | Run | +| Unplugin transform + buildDependencies tracking in production | Prod | | Custom rspack config (`rspack.config.cjs`) | All | | HMR works in dev, disabled in prod | Run, Prod | @@ -227,6 +230,12 @@ Several apps import specific npm packages to verify that Meteor + Rspack handles | `node:buffer` | `imports/api/links.js` | Node.js built-in via `node:` protocol in shared client/server code — must be ignored on client without errors | | `@react-email/components` | `imports/emails/TestEmail.jsx` | JSX-heavy ESM package with many subpath exports | +### react (`apps/react/plugins/demo-unplugin.js`) + +| Package | Reason | +|---------|--------| +| `unplugin` | Unplugin transform hook integration — validates rspack cache tracks plugin dependency files (#14031) | + ### babel (`apps/babel/server/apollo.js`) | Package | Reason | @@ -269,6 +278,7 @@ Where each feature is tested across apps and skeletons. | Babel compiler plugin | react-router | | | TypeScript type checking | typescript | | | Meteor.disablePlugins | react | | +| Unplugin transform with cache (#14031) | react | | | Custom package dirs | react-router | | | CoffeeScript compilation | coffeescript | coffeescript | | Server-only (no client) | server-only | | diff --git a/tools/e2e-tests/apps/react/package.json b/tools/e2e-tests/apps/react/package.json index c57d7575f1..748641428a 100644 --- a/tools/e2e-tests/apps/react/package.json +++ b/tools/e2e-tests/apps/react/package.json @@ -11,6 +11,7 @@ "@babel/runtime": "^7.23.5", "@swc/helpers": "^0.5.17", "meteor-node-stubs": "^1.2.12", + "unplugin": "^2.3.2", "react": "^18.2.0", "react-dom": "^18.2.0" }, diff --git a/tools/e2e-tests/apps/react/plugins/demo-unplugin.js b/tools/e2e-tests/apps/react/plugins/demo-unplugin.js new file mode 100644 index 0000000000..e570040b16 --- /dev/null +++ b/tools/e2e-tests/apps/react/plugins/demo-unplugin.js @@ -0,0 +1,30 @@ +const { createUnplugin } = require('unplugin'); + +const demoUnplugin = createUnplugin(() => { + console.log('[demo-unplugin][factory-created]'); + return { + name: 'demo-unplugin', + transformInclude(id) { + // Only process app source files, skip node_modules and .meteor + if (id.includes('node_modules') || id.includes('.meteor')) { + return false; + } + const ok = + id.endsWith('.tsx') || + id.endsWith('.ts') || + id.endsWith('.jsx') || + id.endsWith('.js'); + + if (ok) { + console.log('[demo-unplugin][transformInclude]', id, '=> true'); + } + return ok; + }, + transform(code, id) { + console.log('[demo-unplugin][transform-enter]', id); + return { code, map: null }; + }, + }; +}); + +module.exports = { demoRspackPlugin: demoUnplugin.rspack }; diff --git a/tools/e2e-tests/apps/react/rspack.config.cjs b/tools/e2e-tests/apps/react/rspack.config.cjs index a28fcc5ac3..91a774dcdb 100644 --- a/tools/e2e-tests/apps/react/rspack.config.cjs +++ b/tools/e2e-tests/apps/react/rspack.config.cjs @@ -1,6 +1,7 @@ const { defineConfig } = require('@meteorjs/rspack'); const path = require('path'); const CustomConsoleLogPlugin = require("./plugins/CustomConsoleLogPlugin"); +const { demoRspackPlugin } = require("./plugins/demo-unplugin"); /** * Rspack configuration for Meteor projects. @@ -39,6 +40,6 @@ module.exports = defineConfig(Meteor => { }, ], }, - plugins: [new CustomConsoleLogPlugin()], + plugins: [new CustomConsoleLogPlugin(), demoRspackPlugin()], }; }); diff --git a/tools/e2e-tests/react.test.js b/tools/e2e-tests/react.test.js index f10ececa9c..2f13cdfa46 100644 --- a/tools/e2e-tests/react.test.js +++ b/tools/e2e-tests/react.test.js @@ -78,6 +78,13 @@ describe('React App Bundling /', () => { buildDir: "_build-local-custom", env: { METEOR_LOCAL_DIR: ".meteor/local-custom" }, customAssertions: { + afterInit: async ({ result }) => { + // Verify unplugin transform hook is called on first run (fresh cache) + await waitForMeteorOutput( + result.outputLines, + /.*\[demo-unplugin\]\[transform-enter\].*/ + ); + }, afterRun: async ({ result, tempDir }) => { const appDir = tempDir; // testMeteorRspackBundler uses tempDir as appDir if not monorepo @@ -95,11 +102,20 @@ describe('React App Bundling /', () => { await assertImagesExistAndLoad(); // Check custom plugin is disabled with Meteor.disablePlugins + // Use specific log prefix to avoid matching the filename in buildDependencies await waitForMeteorOutput( result.outputLines, - /.*CustomConsoleLogPlugin.*/, + /.*\[CustomConsoleLogPlugin\].*/, { negate: true } ); + + // Verify unplugin factory is still created on second run (with cache) + // This confirms the plugin is loaded and active even when rspack uses + // cached transform results (#14031 regression test) + await waitForMeteorOutput( + result.outputLines, + /.*\[demo-unplugin\]\[factory-created\].*/ + ); }, afterRunRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR output as enabled by default @@ -115,11 +131,24 @@ describe('React App Bundling /', () => { await assertImagesExistAndLoad(); // Check custom plugin is disabled with Meteor.disablePlugins + // Use specific log prefix to avoid matching the filename in buildDependencies await waitForMeteorOutput( result.outputLines, - /.*CustomConsoleLogPlugin.*/, + /.*\[CustomConsoleLogPlugin\].*/, { negate: true } ); + + // Verify demo-unplugin.js is tracked in rspack buildDependencies (#14031) + await waitForMeteorOutput( + result.outputLines, + /.*plugins\/demo-unplugin\.js.*/ + ); + + // Verify unplugin transform hook fires in production (separate cache version) + await waitForMeteorOutput( + result.outputLines, + /.*\[demo-unplugin\]\[transform-enter\].*/ + ); }, afterRunProductionRebuildClient: async ({ allConsoleLogs }) => { // Check for HMR to not be enabled in production-like mode @@ -133,9 +162,10 @@ describe('React App Bundling /', () => { await waitForReactEnvs(result.outputLines); // Check custom plugin is disabled with Meteor.disablePlugins + // Use specific log prefix to avoid matching the filename in buildDependencies await waitForMeteorOutput( result.outputLines, - /.*CustomConsoleLogPlugin.*/, + /.*\[CustomConsoleLogPlugin\].*/, { negate: true } ); }, @@ -143,9 +173,10 @@ describe('React App Bundling /', () => { await waitForReactEnvs(result.outputLines); // Check custom plugin is disabled with Meteor.disablePlugins + // Use specific log prefix to avoid matching the filename in buildDependencies await waitForMeteorOutput( result.outputLines, - /.*CustomConsoleLogPlugin.*/, + /.*\[CustomConsoleLogPlugin\].*/, { negate: true } ); }, @@ -153,9 +184,10 @@ describe('React App Bundling /', () => { await waitForReactEnvs(result.outputLines, { isJsxEnabled: true }); // Check custom plugin is disabled with Meteor.disablePlugins + // Use specific log prefix to avoid matching the filename in buildDependencies await waitForMeteorOutput( result.outputLines, - /.*CustomConsoleLogPlugin.*/, + /.*\[CustomConsoleLogPlugin\].*/, { negate: true } ); }, From 88dc95bbd48aee6fc67e937f376742115dacecf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 16:47:54 +0200 Subject: [PATCH 47/53] replace React imports with automatic JSX runtime and add `swc.config.ts` templates for TypeScript and Tailwind skeletons --- .../skel-typescript-tailwind/client/main.tsx | 1 - .../skel-typescript-tailwind/imports/ui/App.tsx | 1 - .../skel-typescript-tailwind/imports/ui/Hello.tsx | 2 +- .../skel-typescript-tailwind/imports/ui/Info.tsx | 1 - .../skel-typescript-tailwind/package.json | 1 + .../skel-typescript-tailwind/swc.config.ts | 13 +++++++++++++ tools/static-assets/skel-typescript/.swcrc | 9 --------- tools/static-assets/skel-typescript/package.json | 1 + tools/static-assets/skel-typescript/swc.config.ts | 13 +++++++++++++ 9 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 tools/static-assets/skel-typescript-tailwind/swc.config.ts delete mode 100644 tools/static-assets/skel-typescript/.swcrc create mode 100644 tools/static-assets/skel-typescript/swc.config.ts diff --git a/tools/static-assets/skel-typescript-tailwind/client/main.tsx b/tools/static-assets/skel-typescript-tailwind/client/main.tsx index a86c160a73..99ef2083ac 100644 --- a/tools/static-assets/skel-typescript-tailwind/client/main.tsx +++ b/tools/static-assets/skel-typescript-tailwind/client/main.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Meteor } from 'meteor/meteor'; import { createRoot } from 'react-dom/client'; import { App } from '/imports/ui/App'; diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx index 90a2b06b9e..a21faaeeec 100644 --- a/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/App.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { Hello } from './Hello'; import { Info } from './Info'; diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx index 9d0e05237c..370eeca07c 100644 --- a/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/Hello.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import { useState } from 'react'; export const Hello = () => { const [counter, setCounter] = useState(0); diff --git a/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx b/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx index bc7a35f123..30e8d3355f 100644 --- a/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx +++ b/tools/static-assets/skel-typescript-tailwind/imports/ui/Info.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { useFind, useSubscribe } from "meteor/react-meteor-data/suspense"; import { LinksCollection } from "../api/links"; diff --git a/tools/static-assets/skel-typescript-tailwind/package.json b/tools/static-assets/skel-typescript-tailwind/package.json index a75fe7e2a0..b18a3a0601 100644 --- a/tools/static-assets/skel-typescript-tailwind/package.json +++ b/tools/static-assets/skel-typescript-tailwind/package.json @@ -21,6 +21,7 @@ "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", + "@swc/core": "^1.15.18", "@rspack/plugin-react-refresh": "^1.4.3", "@tailwindcss/postcss": "^4.1.12", "@types/meteor": "^2.9.9", diff --git a/tools/static-assets/skel-typescript-tailwind/swc.config.ts b/tools/static-assets/skel-typescript-tailwind/swc.config.ts new file mode 100644 index 0000000000..699a33a40d --- /dev/null +++ b/tools/static-assets/skel-typescript-tailwind/swc.config.ts @@ -0,0 +1,13 @@ +import type { Config } from "@swc/core"; + +const config: Config = { + jsc: { + transform: { + react: { + runtime: "automatic", + }, + }, + }, +}; + +export default config; diff --git a/tools/static-assets/skel-typescript/.swcrc b/tools/static-assets/skel-typescript/.swcrc deleted file mode 100644 index bbc8887edb..0000000000 --- a/tools/static-assets/skel-typescript/.swcrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "jsc": { - "transform": { - "react": { - "runtime": "automatic" - } - } - } -} \ No newline at end of file diff --git a/tools/static-assets/skel-typescript/package.json b/tools/static-assets/skel-typescript/package.json index 59017498e0..58b1a58a59 100644 --- a/tools/static-assets/skel-typescript/package.json +++ b/tools/static-assets/skel-typescript/package.json @@ -19,6 +19,7 @@ "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", + "@swc/core": "^1.15.18", "@rspack/plugin-react-refresh": "^1.4.3", "@types/meteor": "^2.9.9", "@types/mocha": "^8.2.3", diff --git a/tools/static-assets/skel-typescript/swc.config.ts b/tools/static-assets/skel-typescript/swc.config.ts new file mode 100644 index 0000000000..699a33a40d --- /dev/null +++ b/tools/static-assets/skel-typescript/swc.config.ts @@ -0,0 +1,13 @@ +import type { Config } from "@swc/core"; + +const config: Config = { + jsc: { + transform: { + react: { + runtime: "automatic", + }, + }, + }, +}; + +export default config; From 33124cf9f191152cc50ff4678d44ac86cae44ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 16:48:51 +0200 Subject: [PATCH 48/53] add E2E test for TypeScript Tailwind skeleton and disable TsCheckerRspackPlugin in CI --- tools/e2e-tests/skeleton.test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/e2e-tests/skeleton.test.js b/tools/e2e-tests/skeleton.test.js index 1556a00c51..63aa19e3c2 100644 --- a/tools/e2e-tests/skeleton.test.js +++ b/tools/e2e-tests/skeleton.test.js @@ -216,6 +216,33 @@ describe('Meteor Skeletons /', () => { }), ); + describe( + "Typescript Tailwind Skeleton /", + testMeteorSkeleton({ + skeletonName: "typescript", + port: 3221, + filePaths: { + client: "client/main.tsx", + server: "server/main.ts", + test: "tests/main.ts", + }, + customAssertions: { + afterCreate({ tempDir }) { + if (isCI) { + const rspackConfigPath = path.join(tempDir, "rspack.config.ts"); + // Remove the TsCheckerRspackPlugin plugin as is resource-intense, CI gets exhausted and fails + let configContent = fs.readFileSync(rspackConfigPath, "utf8"); + configContent = configContent.replace( + /\s*new\s+TsCheckerRspackPlugin\(\)/, + "" + ); + fs.writeFileSync(rspackConfigPath, configContent); + } + }, + }, + }) + ); + describe( 'Vue Skeleton /', testMeteorSkeleton({ From f2c0f8136aacb09a6ad24067e6a1a7d5947194aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 17:36:17 +0200 Subject: [PATCH 49/53] add PR number support to `checkout:pr` script and enhance usage documentation --- scripts/checkout-pr.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/checkout-pr.js b/scripts/checkout-pr.js index d0c1e32ebd..7914243b07 100755 --- a/scripts/checkout-pr.js +++ b/scripts/checkout-pr.js @@ -3,12 +3,14 @@ // checkout-pr.js — prepare a local branch from a fork contribution // // Usage: +// node scripts/checkout-pr.js // node scripts/checkout-pr.js // node scripts/checkout-pr.js : // node scripts/checkout-pr.js // node scripts/checkout-pr.js git@github.com:/.git // // Examples: +// node scripts/checkout-pr.js 123 // node scripts/checkout-pr.js https://github.com/meteor/meteor/pull/ // node scripts/checkout-pr.js : // node scripts/checkout-pr.js @@ -42,6 +44,7 @@ function die(msg) { function usage() { console.log(`Usage: + npm run checkout:pr -- npm run checkout:pr -- npm run checkout:pr -- : npm run checkout:pr -- @@ -50,6 +53,7 @@ function usage() { Prepares a local branch from a fork contribution for testing and review. Examples: + npm run checkout:pr -- 123 npm run checkout:pr -- https://github.com/meteor/meteor/pull/ npm run checkout:pr -- : npm run checkout:pr -- @@ -136,6 +140,18 @@ async function extractFromPrUrl(prUrl) { die(`could not extract fork owner/branch from PR #${prNumber}`); } +function getRepoPathFromOrigin() { + const originUrl = git('remote get-url origin', { silent: true }); + if (!originUrl) return null; + // Match HTTPS: https://github.com/owner/repo(.git) + const httpsMatch = originUrl.match(/github\.com\/([^/]+\/[^/]+?)(?:\.git)?$/); + if (httpsMatch) return httpsMatch[1]; + // Match SSH: git@github.com:owner/repo(.git) + const sshMatch = originUrl.match(/github\.com:([^/]+\/[^/]+?)(?:\.git)?$/); + if (sshMatch) return sshMatch[1]; + return null; +} + function extractOwnerFromUrl(url) { const match = url.match(/github\.com[:/]([^/]+)\//); return match ? match[1] : null; @@ -172,13 +188,23 @@ async function main() { usage(); } else if (args.length === 1) { const arg = args[0]; + const prNumberMatch = arg.match(/^\d+$/); const prMatch = arg.match(/^https?:\/\/github\.com\/.*\/pull\/\d+/); const sshMatch = arg.match(/^git@[^:]+:/); const httpsRepoMatch = arg.match(/^https?:\/\/.*\.git$/); // user:branch — must not start with git@ (SSH) or contain / before : (URLs) const shortMatch = !sshMatch && arg.match(/^([^/:]+):(.+)$/); - if (prMatch) { + if (prNumberMatch) { + const repoPath = getRepoPathFromOrigin(); + if (!repoPath) die('could not determine repository from origin remote'); + const prUrl = `https://github.com/${repoPath}/pull/${arg}`; + info(`resolved PR #${arg} → ${c.bold}${prUrl}${c.reset}`); + const result = await extractFromPrUrl(prUrl); + forkOwner = result.owner; + forkBranch = result.branch; + forkRepoUrl = buildForkUrl(forkOwner); + } else if (prMatch) { const result = await extractFromPrUrl(arg); forkOwner = result.owner; forkBranch = result.branch; From 7c72c706f77e5b847d44b1b12fa959ce3071c47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 17:38:33 +0200 Subject: [PATCH 50/53] refactor `checkout:pr` script to simplify argument validation and improve error handling --- scripts/checkout-pr.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/checkout-pr.js b/scripts/checkout-pr.js index 7914243b07..1bfdc7cdf2 100755 --- a/scripts/checkout-pr.js +++ b/scripts/checkout-pr.js @@ -184,9 +184,7 @@ async function main() { let forkOwner, forkBranch, forkRepoUrl; - if (args.length === 0) { - usage(); - } else if (args.length === 1) { + if (args.length === 1) { const arg = args[0]; const prNumberMatch = arg.match(/^\d+$/); const prMatch = arg.match(/^https?:\/\/github\.com\/.*\/pull\/\d+/); @@ -218,7 +216,7 @@ async function main() { } else { err(`unrecognized format: ${arg}`); console.error(''); - usage(); + return usage(); } } else if (args.length === 2) { forkRepoUrl = args[0]; @@ -226,7 +224,7 @@ async function main() { forkOwner = extractOwnerFromUrl(forkRepoUrl); if (!forkOwner) die(`could not extract owner from URL: ${forkRepoUrl}`); } else { - usage(); + return usage(); } const previousBranch = git('symbolic-ref --short HEAD', { silent: true }) From 7c35bb0ebe3b6d5f25cc9d605ac2e92ae58c6820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 17:42:09 +0200 Subject: [PATCH 51/53] update test to use "typescript-tailwind" skeleton name in E2E suite --- tools/e2e-tests/skeleton.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/e2e-tests/skeleton.test.js b/tools/e2e-tests/skeleton.test.js index 63aa19e3c2..a747446238 100644 --- a/tools/e2e-tests/skeleton.test.js +++ b/tools/e2e-tests/skeleton.test.js @@ -219,7 +219,7 @@ describe('Meteor Skeletons /', () => { describe( "Typescript Tailwind Skeleton /", testMeteorSkeleton({ - skeletonName: "typescript", + skeletonName: "typescript-tailwind", port: 3221, filePaths: { client: "client/main.tsx", From 186b38f3e7f46e0489b17d9de65dd8a84573801f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 18:36:25 +0200 Subject: [PATCH 52/53] switch JSX setting from "react" to "react-jsx" --- tools/static-assets/skel-typescript-tailwind/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/static-assets/skel-typescript-tailwind/tsconfig.json b/tools/static-assets/skel-typescript-tailwind/tsconfig.json index 21922a37d9..420b46c51a 100644 --- a/tools/static-assets/skel-typescript-tailwind/tsconfig.json +++ b/tools/static-assets/skel-typescript-tailwind/tsconfig.json @@ -3,7 +3,7 @@ "target": "ES2020", "module": "ESNext", "moduleResolution": "node", - "jsx": "react", + "jsx": "react-jsx", "strict": false, "noEmit": true, "esModuleInterop": true, From cd04e0e0c4c777b90231c0031ee42550e320c2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nacho=20Codo=C3=B1er?= Date: Mon, 30 Mar 2026 22:22:14 +0200 Subject: [PATCH 53/53] bump @meteorjs/rspack to 1.1.0-beta.33 across all skeletons and constants, add scripts and devDependencies for version management --- npm-packages/meteor-rspack/package-lock.json | 20 +++++++++++++++++-- npm-packages/meteor-rspack/package.json | 9 ++++++++- packages/rspack/lib/constants.js | 2 +- tools/e2e-tests/apps/solid/package.json | 2 +- tools/e2e-tests/apps/svelte/package.json | 2 +- tools/e2e-tests/apps/vue/package.json | 2 +- tools/static-assets/skel-angular/package.json | 2 +- tools/static-assets/skel-apollo/package.json | 2 +- tools/static-assets/skel-babel/package.json | 2 +- tools/static-assets/skel-blaze/package.json | 2 +- .../static-assets/skel-chakra-ui/package.json | 2 +- .../skel-coffeescript/package.json | 2 +- tools/static-assets/skel-full/package.json | 2 +- tools/static-assets/skel-react/package.json | 2 +- tools/static-assets/skel-solid/package.json | 2 +- tools/static-assets/skel-svelte/package.json | 2 +- .../static-assets/skel-tailwind/package.json | 2 +- .../skel-typescript/package.json | 2 +- tools/static-assets/skel-vue/package.json | 2 +- 19 files changed, 43 insertions(+), 20 deletions(-) diff --git a/npm-packages/meteor-rspack/package-lock.json b/npm-packages/meteor-rspack/package-lock.json index 739b4cd71d..4143577f54 100644 --- a/npm-packages/meteor-rspack/package-lock.json +++ b/npm-packages/meteor-rspack/package-lock.json @@ -1,12 +1,12 @@ { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.31", + "version": "1.1.0-beta.33", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.31", + "version": "1.1.0-beta.33", "license": "ISC", "dependencies": { "fast-deep-equal": "^3.1.3", @@ -14,6 +14,9 @@ "node-polyfill-webpack-plugin": "^4.1.0", "webpack-merge": "^6.0.1" }, + "devDependencies": { + "semver": "^7.7.4" + }, "peerDependencies": { "@rspack/cli": ">=1.3.0", "@rspack/core": ">=1.3.0", @@ -4470,6 +4473,19 @@ "node": ">=10" } }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/send": { "version": "0.19.0", "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", diff --git a/npm-packages/meteor-rspack/package.json b/npm-packages/meteor-rspack/package.json index a880bf3f19..8107608514 100644 --- a/npm-packages/meteor-rspack/package.json +++ b/npm-packages/meteor-rspack/package.json @@ -1,17 +1,24 @@ { "name": "@meteorjs/rspack", - "version": "1.1.0-beta.31", + "version": "1.1.0-beta.33", "description": "Configuration logic for using Rspack in Meteor projects", "main": "index.js", "type": "commonjs", "author": "", "license": "ISC", + "scripts": { + "bump": "node ./scripts/bump-version.js", + "publish:beta": "bash ./scripts/publish-beta.sh" + }, "dependencies": { "fast-deep-equal": "^3.1.3", "ignore-loader": "^0.1.2", "node-polyfill-webpack-plugin": "^4.1.0", "webpack-merge": "^6.0.1" }, + "devDependencies": { + "semver": "^7.7.4" + }, "peerDependencies": { "@rspack/cli": ">=1.3.0", "@rspack/core": ">=1.3.0", diff --git a/packages/rspack/lib/constants.js b/packages/rspack/lib/constants.js index 1341f54ce7..89830dd491 100644 --- a/packages/rspack/lib/constants.js +++ b/packages/rspack/lib/constants.js @@ -7,7 +7,7 @@ import path from 'path'; export const DEFAULT_RSPACK_VERSION = '1.7.1'; -export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.31'; +export const DEFAULT_METEOR_RSPACK_VERSION = '1.1.0-beta.33'; export const DEFAULT_METEOR_RSPACK_REACT_HMR_VERSION = '1.4.3'; diff --git a/tools/e2e-tests/apps/solid/package.json b/tools/e2e-tests/apps/solid/package.json index 5ce93de638..0f055dbf09 100644 --- a/tools/e2e-tests/apps/solid/package.json +++ b/tools/e2e-tests/apps/solid/package.json @@ -22,7 +22,7 @@ "modern": true }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rspack/cli": "^1.4.8", "@rspack/core": "^1.4.8", "babel-loader": "10.0.0", diff --git a/tools/e2e-tests/apps/svelte/package.json b/tools/e2e-tests/apps/svelte/package.json index cba0d4e7a0..82496ec1a0 100644 --- a/tools/e2e-tests/apps/svelte/package.json +++ b/tools/e2e-tests/apps/svelte/package.json @@ -13,7 +13,7 @@ "meteor-node-stubs": "^1.2.12" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rspack/cli": "^1.4.8", "@rspack/core": "^1.4.8", "playwright": "1.58.0", diff --git a/tools/e2e-tests/apps/vue/package.json b/tools/e2e-tests/apps/vue/package.json index a533902f34..36b2b717dd 100644 --- a/tools/e2e-tests/apps/vue/package.json +++ b/tools/e2e-tests/apps/vue/package.json @@ -17,7 +17,7 @@ "vue-router": "^4.2.5" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rspack/cli": "^1.4.8", "@rspack/core": "^1.4.8", "@tailwindcss/postcss": "^4.1.12", diff --git a/tools/static-assets/skel-angular/package.json b/tools/static-assets/skel-angular/package.json index fa3105b024..c56f044706 100644 --- a/tools/static-assets/skel-angular/package.json +++ b/tools/static-assets/skel-angular/package.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@angular/compiler-cli": "^20.0.0", - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@nx/angular-rspack": "^21.1.0", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", diff --git a/tools/static-assets/skel-apollo/package.json b/tools/static-assets/skel-apollo/package.json index 5fd18f2131..5ccccde773 100644 --- a/tools/static-assets/skel-apollo/package.json +++ b/tools/static-assets/skel-apollo/package.json @@ -20,7 +20,7 @@ "devDependencies": { "@graphql-tools/webpack-loader": "^7.0.0", "@rsdoctor/rspack-plugin": "^1.2.3", - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", "@rspack/plugin-react-refresh": "^1.4.3", diff --git a/tools/static-assets/skel-babel/package.json b/tools/static-assets/skel-babel/package.json index 8c9c45753f..1a86abf697 100644 --- a/tools/static-assets/skel-babel/package.json +++ b/tools/static-assets/skel-babel/package.json @@ -17,7 +17,7 @@ "devDependencies": { "@babel/preset-env": "^7.28.3", "@babel/preset-react": "^7.23.3", - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-blaze/package.json b/tools/static-assets/skel-blaze/package.json index 6dd838aaf6..47e5d33755 100644 --- a/tools/static-assets/skel-blaze/package.json +++ b/tools/static-assets/skel-blaze/package.json @@ -14,7 +14,7 @@ "meteor-node-stubs": "^1.2.12" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-chakra-ui/package.json b/tools/static-assets/skel-chakra-ui/package.json index a30ef9f180..d9ca4809d4 100644 --- a/tools/static-assets/skel-chakra-ui/package.json +++ b/tools/static-assets/skel-chakra-ui/package.json @@ -21,7 +21,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-coffeescript/package.json b/tools/static-assets/skel-coffeescript/package.json index 6f2ebbce93..bde5d75679 100644 --- a/tools/static-assets/skel-coffeescript/package.json +++ b/tools/static-assets/skel-coffeescript/package.json @@ -15,7 +15,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-full/package.json b/tools/static-assets/skel-full/package.json index e7f8bb952e..88393fc5f1 100644 --- a/tools/static-assets/skel-full/package.json +++ b/tools/static-assets/skel-full/package.json @@ -12,7 +12,7 @@ "meteor-node-stubs": "^1.2.12" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-react/package.json b/tools/static-assets/skel-react/package.json index 1091b1727a..a5d14793d7 100644 --- a/tools/static-assets/skel-react/package.json +++ b/tools/static-assets/skel-react/package.json @@ -15,7 +15,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-solid/package.json b/tools/static-assets/skel-solid/package.json index d14262c517..7a21b3b001 100644 --- a/tools/static-assets/skel-solid/package.json +++ b/tools/static-assets/skel-solid/package.json @@ -14,7 +14,7 @@ "picocolors": "^1.1.1" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-svelte/package.json b/tools/static-assets/skel-svelte/package.json index d864cf7c23..2f0bfebafe 100644 --- a/tools/static-assets/skel-svelte/package.json +++ b/tools/static-assets/skel-svelte/package.json @@ -13,7 +13,7 @@ "meteor-node-stubs": "^1.2.12" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-tailwind/package.json b/tools/static-assets/skel-tailwind/package.json index 79935caba4..69f05385c7 100644 --- a/tools/static-assets/skel-tailwind/package.json +++ b/tools/static-assets/skel-tailwind/package.json @@ -16,7 +16,7 @@ "react-dom": "^17.0.2" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-typescript/package.json b/tools/static-assets/skel-typescript/package.json index 58b1a58a59..3877a069a2 100644 --- a/tools/static-assets/skel-typescript/package.json +++ b/tools/static-assets/skel-typescript/package.json @@ -15,7 +15,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1", diff --git a/tools/static-assets/skel-vue/package.json b/tools/static-assets/skel-vue/package.json index a156645d98..1dda2123b5 100644 --- a/tools/static-assets/skel-vue/package.json +++ b/tools/static-assets/skel-vue/package.json @@ -17,7 +17,7 @@ "vue-router": "^4.2.5" }, "devDependencies": { - "@meteorjs/rspack": "^1.1.0-beta.31", + "@meteorjs/rspack": "^1.1.0-beta.33", "@rsdoctor/rspack-plugin": "^1.2.3", "@rspack/cli": "^1.7.1", "@rspack/core": "^1.7.1",