@seamlessdocs/payment-modals 2.0.0-beta.7 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamlessdocs/payment-modals",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "Payment modals for SeamlessDocs",
5
5
  "main": "build/payment-modals.js",
6
6
  "repository": {
package/src/index.jsx CHANGED
@@ -1,8 +1,3 @@
1
- // Import createRoot - webpack will handle externals correctly
2
- // In development: will be bundled from react-dom/client
3
- // In production: will be external and resolved to ReactDOM global
4
- import * as ReactDOMClient from 'react-dom/client';
5
-
6
1
  import ChooseModal from './Components/ChooseModal';
7
2
  import ProcessingModal from './Components/ProcessingModal';
8
3
  import ErrorModal from './Components/ErrorModal';
@@ -23,28 +18,12 @@ import './OpenViewStyles.css';
23
18
  const rootInstances = new Map();
24
19
 
25
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
26
24
  const getCreateRoot = () => {
27
- // Strategy 1: Try the imported module first (works in development when bundled)
28
- // Check if createRoot is available directly or as a property
29
- let createRootFn = null;
30
-
31
- if (ReactDOMClient) {
32
- // Try direct access
33
- if (typeof ReactDOMClient.createRoot === 'function') {
34
- createRootFn = ReactDOMClient.createRoot;
35
- }
36
- // Try as default export property
37
- else if (ReactDOMClient.default && typeof ReactDOMClient.default.createRoot === 'function') {
38
- createRootFn = ReactDOMClient.default.createRoot;
39
- }
40
- }
41
-
42
- if (createRootFn) {
43
- return createRootFn;
44
- }
45
-
46
- // Strategy 2: Access ReactDOM from global scope (works in production with externals)
47
- // Also works in development if React is loaded globally
25
+ // Access ReactDOM from global scope - this is the ONLY way we access React
26
+ // This prevents multiple React instances and internal conflicts
48
27
  const ReactDOM = (typeof window !== 'undefined' && window.ReactDOM)
49
28
  || (typeof global !== 'undefined' && global.ReactDOM)
50
29
  || (typeof self !== 'undefined' && self.ReactDOM);
@@ -54,9 +33,10 @@ const getCreateRoot = () => {
54
33
  }
55
34
 
56
35
  throw new Error(
57
- 'createRoot is not available. Make sure React 18 is loaded. ' +
58
- 'In development, react-dom should be bundled. ' +
59
- 'In production, ReactDOM should be available globally as window.ReactDOM.'
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.'
60
40
  );
61
41
  };
62
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,