hedgedoc/.yarn/patches/yjs-npm-13.5.52-a5c64d9068.patch
Tilman Vatteroth 54ee492411 fix: suppress yjs double import warning
This warning should indicate that you mix cjs and mjs imports.
While this is a nice feature it has a weird side effect:
Jest triggers this check and floods the console every time a test imports yjs.
This happens between all test suites and every time you call jest.resetModules().
Nothing breaks here. Jest does what it should.
Therefore this commit suppresses this warning in test mode.

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2023-04-13 10:38:20 +02:00

33 lines
1.4 KiB
Diff

# This warning should indicate that you mix cjs and mjs imports.
# While this is a nice feature it has a weird side effect:
# Jest triggers this check and floods the console every time a test imports yjs.
# This happens between all test suites and every time you call jest.resetModules().
# Nothing breaks here. Jest does what it should.
# Therefore this commit suppresses this warning in test mode.
diff --git a/dist/yjs.cjs b/dist/yjs.cjs
index a296aa30408893dc8cc59a083f4dc716aded29d0..068e2b9dee30f9c59e6edb8285788be66b202978 100644
--- a/dist/yjs.cjs
+++ b/dist/yjs.cjs
@@ -9893,7 +9893,7 @@ const glo = /** @type {any} */ (typeof globalThis !== 'undefined'
const importIdentifier = '__ $YJS$ __';
-if (glo[importIdentifier] === true) {
+if (glo[importIdentifier] === true && process.env.NODE_ENV !== 'test') {
/**
* Dear reader of this message. Please take this seriously.
*
diff --git a/dist/yjs.mjs b/dist/yjs.mjs
index 005cc66e8dcd8aef9b2adf7a0eadc5a61b86667e..cbf100dc0b91ff9f61b544cc5c7cbf1be1388a28 100644
--- a/dist/yjs.mjs
+++ b/dist/yjs.mjs
@@ -9858,7 +9858,7 @@ const glo = /** @type {any} */ (typeof globalThis !== 'undefined'
const importIdentifier = '__ $YJS$ __';
-if (glo[importIdentifier] === true) {
+if (glo[importIdentifier] === true && process.env.NODE_ENV !== 'test') {
/**
* Dear reader of this message. Please take this seriously.
*