Skip to content

Commit af0e683

Browse files
Copilotttt43ttt
andauthored
Fix ESM import compatibility using globalThis (#112)
* Initial plan * Fix ESM import compatibility by using window.cv instead of root.cv Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com> * Use globalThis instead of this for universal ESM compatibility Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com> * Revert package-lock.json changes and update opencv.js.patch Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ttt43ttt <132509+ttt43ttt@users.noreply.github.com>
1 parent fe77e0b commit af0e683

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

dist/opencv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// Other shells, e.g. d8
2020
root.cv = factory();
2121
}
22-
}(this, function () {
22+
}(globalThis, function () {
2323

2424
var cv = (function() {
2525
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;

dist/opencv.js.patch

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ diff --git a/dist/opencv.js b/dist/opencv.js
22
index af4111b..3ba8a69 100644
33
--- a/dist/opencv.js
44
+++ b/dist/opencv.js
5-
@@ -41,7 +41,7 @@ else if (typeof define === 'function' && define['amd'])
5+
@@ -22,7 +22,7 @@
6+
// Other shells, e.g. d8
7+
root.cv = factory();
8+
}
9+
-}(this, function () {
10+
+}(globalThis, function () {
11+
12+
var cv = (function() {
13+
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
14+
@@ -44,7 +44,7 @@ else if (typeof define === 'function' && define['amd'])
615
define([], () => cv);
716

817
if (typeof Module === 'undefined')

0 commit comments

Comments
 (0)