@seamlessdocs/payment-modals 2.0.0-beta.6 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/payment-modals.js +1 -1
- package/package.json +1 -1
- package/src/index.jsx +10 -27
- package/webpack.config.js +16 -7
package/package.json
CHANGED
package/src/index.jsx
CHANGED
|
@@ -17,10 +17,13 @@ import './OpenViewStyles.css';
|
|
|
17
17
|
// Store root instances to manage React 18 roots
|
|
18
18
|
const rootInstances = new Map();
|
|
19
19
|
|
|
20
|
-
// Helper function to get createRoot -
|
|
20
|
+
// Helper function to get createRoot - works in both development and production
|
|
21
|
+
// IMPORTANT: This function ONLY uses the global ReactDOM to avoid conflicts
|
|
22
|
+
// In development, React must be exposed globally (webpack will bundle it)
|
|
23
|
+
// In production, React is external and must be available globally
|
|
21
24
|
const getCreateRoot = () => {
|
|
22
|
-
//
|
|
23
|
-
// This
|
|
25
|
+
// Access ReactDOM from global scope - this is the ONLY way we access React
|
|
26
|
+
// This prevents multiple React instances and internal conflicts
|
|
24
27
|
const ReactDOM = (typeof window !== 'undefined' && window.ReactDOM)
|
|
25
28
|
|| (typeof global !== 'undefined' && global.ReactDOM)
|
|
26
29
|
|| (typeof self !== 'undefined' && self.ReactDOM);
|
|
@@ -29,31 +32,11 @@ const getCreateRoot = () => {
|
|
|
29
32
|
return ReactDOM.createRoot;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
// Strategy 2: Try to require react-dom/client directly (works in development only)
|
|
33
|
-
// Only use this in development when react-dom is bundled
|
|
34
|
-
try {
|
|
35
|
-
const reactDomClient = require('react-dom/client');
|
|
36
|
-
if (reactDomClient && reactDomClient.createRoot && typeof reactDomClient.createRoot === 'function') {
|
|
37
|
-
return reactDomClient.createRoot;
|
|
38
|
-
}
|
|
39
|
-
} catch (e) {
|
|
40
|
-
// Ignore require errors - module might not be available (especially in production)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Strategy 3: Try to require react-dom and access createRoot (works in development only)
|
|
44
|
-
try {
|
|
45
|
-
const ReactDOMModule = require('react-dom');
|
|
46
|
-
if (ReactDOMModule && typeof ReactDOMModule.createRoot === 'function') {
|
|
47
|
-
return ReactDOMModule.createRoot;
|
|
48
|
-
}
|
|
49
|
-
} catch (e) {
|
|
50
|
-
// Ignore require errors
|
|
51
|
-
}
|
|
52
|
-
|
|
53
35
|
throw new Error(
|
|
54
|
-
'createRoot is not available. Make sure React 18 is loaded. ' +
|
|
55
|
-
'
|
|
56
|
-
'In
|
|
36
|
+
'createRoot is not available. Make sure React 18 is loaded and ReactDOM is available globally. ' +
|
|
37
|
+
'ReactDOM should be accessible as window.ReactDOM. ' +
|
|
38
|
+
'In development, ensure React is loaded before this script. ' +
|
|
39
|
+
'In production, React must be external and available as window.ReactDOM.'
|
|
57
40
|
);
|
|
58
41
|
};
|
|
59
42
|
|
package/webpack.config.js
CHANGED
|
@@ -33,12 +33,6 @@ module.exports = (_env, argv) => {
|
|
|
33
33
|
commonjs2: 'react-dom',
|
|
34
34
|
amd: 'react-dom',
|
|
35
35
|
root: 'ReactDOM'
|
|
36
|
-
},
|
|
37
|
-
'react-dom/client': {
|
|
38
|
-
commonjs: 'react-dom',
|
|
39
|
-
commonjs2: 'react-dom',
|
|
40
|
-
amd: 'react-dom',
|
|
41
|
-
root: 'ReactDOM'
|
|
42
36
|
}
|
|
43
37
|
} : {},
|
|
44
38
|
module: {
|
|
@@ -101,8 +95,23 @@ module.exports = (_env, argv) => {
|
|
|
101
95
|
template: path.join(__dirname, 'index.html'),
|
|
102
96
|
inject: 'body',
|
|
103
97
|
scriptLoading: 'blocking'
|
|
98
|
+
}),
|
|
99
|
+
// In development, expose ReactDOM globally at the start of the bundle
|
|
100
|
+
!isProduction && new webpack.BannerPlugin({
|
|
101
|
+
banner: `
|
|
102
|
+
(function() {
|
|
103
|
+
try {
|
|
104
|
+
if (typeof window !== 'undefined' && typeof require !== 'undefined' && !window.ReactDOM) {
|
|
105
|
+
var ReactDOM = require('react-dom');
|
|
106
|
+
if (ReactDOM) window.ReactDOM = ReactDOM;
|
|
107
|
+
}
|
|
108
|
+
} catch(e) {}
|
|
109
|
+
})();
|
|
110
|
+
`.trim(),
|
|
111
|
+
raw: true,
|
|
112
|
+
entryOnly: true
|
|
104
113
|
})
|
|
105
|
-
],
|
|
114
|
+
].filter(Boolean),
|
|
106
115
|
devServer: {
|
|
107
116
|
port: 9000,
|
|
108
117
|
compress: true,
|