@seamlessdocs/payment-modals 1.0.64 → 2.0.0-beta.1

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.
@@ -11,7 +11,7 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
11
11
  const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
12
12
  const TerserPlugin = require('terser-webpack-plugin');
13
13
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
14
- const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
14
+ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
15
15
  const safePostCssParser = require('postcss-safe-parser');
16
16
  const ManifestPlugin = require('webpack-manifest-plugin');
17
17
  const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
@@ -242,19 +242,9 @@ module.exports = function(webpackEnv) {
242
242
  sourceMap: shouldUseSourceMap,
243
243
  }),
244
244
  // This is only used in production mode
245
- new OptimizeCSSAssetsPlugin({
246
- cssProcessorOptions: {
247
- parser: safePostCssParser,
248
- map: shouldUseSourceMap
249
- ? {
250
- // `inline: false` forces the sourcemap to be output into a
251
- // separate file
252
- inline: false,
253
- // `annotation: true` appends the sourceMappingURL to the end of
254
- // the css file, helping the browser find the sourcemap
255
- annotation: true,
256
- }
257
- : false,
245
+ new CssMinimizerPlugin({
246
+ minimizerOptions: {
247
+ preset: ['default'],
258
248
  },
259
249
  }),
260
250
  ],
@@ -305,6 +295,18 @@ module.exports = function(webpackEnv) {
305
295
  // Make sure your source files are compiled, as they will not be processed in any way.
306
296
  new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
307
297
  ],
298
+ // Some libraries import Node modules but don't use them in the browser.
299
+ // Tell Webpack to provide empty mocks for them so importing them works.
300
+ fallback: {
301
+ module: false,
302
+ dgram: false,
303
+ dns: false,
304
+ fs: false,
305
+ http2: false,
306
+ net: false,
307
+ tls: false,
308
+ child_process: false,
309
+ },
308
310
  },
309
311
  resolveLoader: {
310
312
  plugins: [
@@ -637,18 +639,6 @@ module.exports = function(webpackEnv) {
637
639
  formatter: isEnvProduction ? typescriptFormatter : undefined,
638
640
  }),
639
641
  ].filter(Boolean),
640
- // Some libraries import Node modules but don't use them in the browser.
641
- // Tell Webpack to provide empty mocks for them so importing them works.
642
- node: {
643
- module: 'empty',
644
- dgram: 'empty',
645
- dns: 'mock',
646
- fs: 'empty',
647
- http2: 'empty',
648
- net: 'empty',
649
- tls: 'empty',
650
- child_process: 'empty',
651
- },
652
642
  // Turn off performance processing because we utilize
653
643
  // our own hints via the FileSizeReporter
654
644
  performance: false,
@@ -28,16 +28,25 @@ module.exports = function(proxy, allowedHost) {
28
28
  // So we will disable the host check normally, but enable it if you have
29
29
  // specified the `proxy` setting. Finally, we let you override it if you
30
30
  // really know what you're doing with a special environment variable.
31
- disableHostCheck:
32
- !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
31
+ // WebpackDevServer 2.4.3 introduced a security fix that prevents remote
32
+ // websites from potentially accessing local content through DNS rebinding.
33
+ // For Webpack 5, we use allowedHosts instead of disableHostCheck
34
+ allowedHosts: proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true'
35
+ ? 'all'
36
+ : 'auto',
33
37
  // Enable gzip compression of generated files.
34
38
  compress: true,
35
39
  // Silence WebpackDevServer's own logs since they're generally not useful.
36
40
  // It will still show compile warnings and errors with this setting.
37
- clientLogLevel: 'none',
41
+ client: {
42
+ logging: 'none',
43
+ webSocketURL: allowedHost ? {
44
+ hostname: allowedHost,
45
+ } : undefined,
46
+ },
38
47
  // By default WebpackDevServer serves physical files from current directory
39
48
  // in addition to all the virtual build products that it serves from memory.
40
- // This is confusing because those files wont automatically be available in
49
+ // This is confusing because those files won't automatically be available in
41
50
  // production build folder unless we copy them. However, copying the whole
42
51
  // project directory is dangerous because we may expose sensitive files.
43
52
  // Instead, we establish a convention that only files in `public` directory
@@ -49,21 +58,23 @@ module.exports = function(proxy, allowedHost) {
49
58
  // for files like `favicon.ico`, `manifest.json`, and libraries that are
50
59
  // for some reason broken when imported through Webpack. If you just want to
51
60
  // use an image, put it in `src` and `import` it from JavaScript instead.
52
- contentBase: paths.appPublic,
53
- // By default files from `contentBase` will not trigger a page reload.
54
- watchContentBase: true,
61
+ static: {
62
+ directory: paths.appPublic,
63
+ watch: true,
64
+ },
55
65
  // Enable hot reloading server. It will provide /sockjs-node/ endpoint
56
66
  // for the WebpackDevServer client so it can learn when the files were
57
67
  // updated. The WebpackDevServer client is included as an entry point
58
68
  // in the Webpack development configuration. Note that only changes
59
69
  // to CSS are currently hot reloaded. JS changes will refresh the browser.
60
70
  hot: true,
71
+ liveReload: false,
61
72
  // It is important to tell WebpackDevServer to use the same "root" path
62
73
  // as we specified in the config. In development, we always serve from /.
63
74
  publicPath: '/',
64
75
  // WebpackDevServer is noisy by default so we emit custom message instead
65
76
  // by listening to the compiler events with `compiler.hooks[...].tap` calls above.
66
- quiet: true,
77
+ // Note: 'quiet' option is deprecated in Webpack 5, use client.logging instead
67
78
  // Reportedly, this avoids CPU overload on some systems.
68
79
  // https://github.com/facebook/create-react-app/issues/293
69
80
  // src/node_modules is not ignored to support absolute imports
@@ -80,16 +91,19 @@ module.exports = function(proxy, allowedHost) {
80
91
  // See https://github.com/facebook/create-react-app/issues/387.
81
92
  disableDotRule: true,
82
93
  },
83
- public: allowedHost,
84
94
  proxy,
85
- before(app, server) {
95
+ setupMiddlewares: (middlewares, devServer) => {
96
+ if (!devServer) {
97
+ throw new Error('webpack-dev-server is not defined');
98
+ }
99
+ const app = devServer.app;
86
100
  if (fs.existsSync(paths.proxySetup)) {
87
101
  // This registers user provided middleware for proxy reasons
88
102
  require(paths.proxySetup)(app);
89
103
  }
90
104
 
91
105
  // This lets us fetch source contents from webpack for the error overlay
92
- app.use(evalSourceMapMiddleware(server));
106
+ app.use(evalSourceMapMiddleware(devServer));
93
107
  // This lets us open files from the runtime error overlay.
94
108
  app.use(errorOverlayMiddleware());
95
109
 
@@ -99,6 +113,7 @@ module.exports = function(proxy, allowedHost) {
99
113
  // it used the same host and port.
100
114
  // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
101
115
  app.use(noopServiceWorkerMiddleware());
116
+ return middlewares;
102
117
  },
103
118
  };
104
119
  };
package/index.html CHANGED
@@ -3,7 +3,6 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <link rel="stylesheet" href="index.css" />
7
6
  <title>Payment Modals</title>
8
7
  </head>
9
8
  <body>
@@ -22,7 +21,6 @@
22
21
  </div>
23
22
  <div id="payment-modal"></div>
24
23
  <script src="https://core.spreedly.com/iframe/express-2.min.js"></script>
25
- <script src="./build/payment-modals.js"></script>
26
24
  <script>
27
25
  var triggers = document.querySelectorAll('.links a');
28
26
  var callbacks = {
@@ -169,6 +167,20 @@
169
167
  transactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transaction.json',
170
168
  getTransactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transactions',
171
169
  updateTransactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transactions',
170
+ lineItems: [
171
+ {
172
+ title: "Document Fee",
173
+ description: "",
174
+ quantity: 1,
175
+ unitPrice: 100,
176
+ },
177
+ {
178
+ title: "Fee Test ACH",
179
+ description: "",
180
+ quantity: 1,
181
+ unitPrice: 200,
182
+ },
183
+ ],
172
184
  callbacks: {
173
185
  onPay: function () {
174
186
  setTimeout(function () {
@@ -219,6 +231,20 @@
219
231
  transactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transaction.json',
220
232
  getTransactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transactions/',
221
233
  updateTransactionUrl: 'https://backend.dev.nonprod.seamlessdocs.com/payments/transactions/govOsPay/transactions/',
234
+ lineItems: [
235
+ {
236
+ title: "Document Fee",
237
+ description: "",
238
+ quantity: 1,
239
+ unitPrice: 100,
240
+ },
241
+ {
242
+ title: "Fee Test Credit Card",
243
+ description: "",
244
+ quantity: 1,
245
+ unitPrice: 2.0408163265306145,
246
+ },
247
+ ],
222
248
  callbacks: {
223
249
  onPay: function () {
224
250
  setTimeout(function () {
package/package.json CHANGED
@@ -1,60 +1,68 @@
1
1
  {
2
2
  "name": "@seamlessdocs/payment-modals",
3
- "version": "1.0.64",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Payment modals for SeamlessDocs",
5
5
  "main": "build/payment-modals.js",
6
6
  "repository": {
7
7
  "url": "https://github.com/SeamlessDocsDev/PaymentModals"
8
8
  },
9
+ "engines": {
10
+ "node": ">=22.0.0"
11
+ },
9
12
  "scripts": {
10
13
  "start": "webpack-dev-server --mode development",
11
- "dev": "webpack --mode development ./src/index.jsx --output ./build/payment-modals.js",
12
- "build": "webpack --mode production ./src/index.jsx --output ./build/payment-modals.js"
14
+ "dev": "webpack --mode development",
15
+ "build": "webpack --mode production"
13
16
  },
14
17
  "devDependencies": {
15
- "@babel/core": "^7.6.2",
16
- "@babel/plugin-syntax-class-properties": "^7.2.0",
17
- "@babel/plugin-transform-runtime": "^7.4.4",
18
- "@babel/preset-env": "^7.6.2",
19
- "@babel/preset-react": "^7.0.0",
20
- "@babel/runtime": "^7.4.5",
21
- "babel-eslint": "^10.0.1",
22
- "babel-loader": "^8.0.6",
23
- "babel-plugin-transform-class-properties": "^6.24.1",
24
- "css-loader": "^2.1.1",
25
- "eslint": "^5.16.0",
26
- "eslint-config-airbnb": "^17.1.0",
27
- "eslint-config-prettier": "^4.2.0",
28
- "eslint-plugin-import": "^2.14.0",
29
- "eslint-plugin-jsx-a11y": "^6.1.1",
30
- "eslint-plugin-prettier": "^3.0.1",
31
- "eslint-plugin-react": "^7.13.0",
32
- "extract-text-webpack-plugin": "^3.0.2",
18
+ "@babel/core": "^7.23.7",
19
+ "@babel/eslint-parser": "^7.23.3",
20
+ "@babel/plugin-syntax-class-properties": "^7.12.13",
21
+ "@babel/plugin-transform-runtime": "^7.23.7",
22
+ "@babel/preset-env": "^7.23.7",
23
+ "@babel/preset-react": "^7.23.3",
24
+ "@babel/runtime": "^7.23.7",
25
+ "babel-loader": "^9.1.3",
26
+ "css-loader": "^6.8.1",
27
+ "css-minimizer-webpack-plugin": "^5.0.1",
28
+ "eslint": "^8.56.0",
29
+ "eslint-config-airbnb": "^19.0.4",
30
+ "eslint-config-prettier": "^9.1.0",
31
+ "eslint-plugin-import": "^2.29.1",
32
+ "eslint-plugin-jsx-a11y": "^6.8.0",
33
+ "eslint-plugin-prettier": "^5.1.3",
34
+ "eslint-plugin-react": "^7.33.2",
33
35
  "file-loader": "^3.0.1",
36
+ "html-loader": "^4.2.0",
37
+ "html-webpack-plugin": "^5.6.0",
34
38
  "image-webpack-loader": "^6.0.0",
35
- "mini-css-extract-plugin": "^0.5.0",
36
- "node-sass": "^4.11.0",
39
+ "mini-css-extract-plugin": "^2.7.6",
40
+ "sass": "^1.69.0",
37
41
  "prettier": "^1.17.0",
38
- "sass-loader": "^7.1.0",
39
- "style-loader": "^0.23.1",
42
+ "react": "^18.2.0",
43
+ "react-dom": "^18.2.0",
44
+ "sass-loader": "^13.3.0",
45
+ "style-loader": "^3.3.3",
40
46
  "svg-inline-loader": "^0.8.0",
41
47
  "url-loader": "^1.1.2",
42
- "webpack": "^4.41.0",
43
- "webpack-cli": "^3.3.9",
44
- "webpack-dev-server": "^3.2.1"
48
+ "webpack": "^5.89.0",
49
+ "webpack-cli": "^5.1.4",
50
+ "webpack-dev-server": "^5.0.0"
51
+ },
52
+ "peerDependencies": {
53
+ "react": ">=18.0.0",
54
+ "react-dom": ">=18.0.0"
45
55
  },
46
56
  "dependencies": {
47
- "@kofile/platform-react-payrix": "1.6.15",
57
+ "@kofile/platform-react-payrix": "1.7.47",
48
58
  "babel-plugin-import": "^1.11.0",
49
59
  "base64-image-loader": "^1.2.1",
50
60
  "classnames": "^2.2.6",
51
61
  "download": "^7.1.0",
52
62
  "formik": "^2.1.5",
53
- "postcss-loader": "^3.0.0",
63
+ "postcss-loader": "^7.3.4",
54
64
  "postcss-nested": "^4.1.2",
55
65
  "prop-types": "^15.7.2",
56
- "react": "^16.10.1",
57
- "react-dom": "^16.10.1",
58
66
  "react-inlinesvg": "^1.1.7",
59
67
  "react-select": "^3.1.0",
60
68
  "react-tippy": "^1.4.0"
@@ -18,6 +18,7 @@ const GovOSPayACHPaymentModal = ({
18
18
  transactionUrl,
19
19
  getTransactionUrl,
20
20
  updateTransactionUrl,
21
+ lineItems,
21
22
  }) => {
22
23
  useEffect(() => {
23
24
  // TODO: Remove use of shims when mootools is removed
@@ -38,7 +39,7 @@ const GovOSPayACHPaymentModal = ({
38
39
  </div>
39
40
  <div className={styles.modal}>
40
41
  <ACHPayment
41
- lineItems={[]}
42
+ lineItems={lineItems}
42
43
  providerConfig={paymentConfig}
43
44
  applicationName={'GovOS Studio'}
44
45
  transactionUrl={transactionUrl}
@@ -62,6 +63,7 @@ GovOSPayACHPaymentModal.propTypes = {
62
63
  transactionUrl: PropTypes.string.isRequired,
63
64
  getTransactionUrl: PropTypes.string,
64
65
  updateTransactionUrl: PropTypes.string,
66
+ lineItems: PropTypes.array,
65
67
  };
66
68
 
67
69
  export default GovOSPayACHPaymentModal;
@@ -19,6 +19,7 @@ const GovOSPayCardPaymentModal = ({
19
19
  transactionUrl,
20
20
  getTransactionUrl,
21
21
  updateTransactionUrl,
22
+ lineItems,
22
23
  }) => {
23
24
  useEffect(() => {
24
25
  // TODO: Remove use of shims when mootools is removed
@@ -39,7 +40,7 @@ const GovOSPayCardPaymentModal = ({
39
40
  </div>
40
41
  <div className={styles.modal}>
41
42
  <CardPayment
42
- lineItems={[]}
43
+ lineItems={lineItems}
43
44
  providerConfig={paymentConfig}
44
45
  applicationName={'GovOS Studio'}
45
46
  transactionUrl={transactionUrl}
@@ -65,6 +66,7 @@ GovOSPayCardPaymentModal.propTypes = {
65
66
  transactionUrl: PropTypes.string.isRequired,
66
67
  getTransactionUrl: PropTypes.string,
67
68
  updateTransactionUrl: PropTypes.string,
69
+ lineItems: PropTypes.array,
68
70
  };
69
71
 
70
72
  GovOSPayCardPaymentModal.defaultProps = {
package/src/index.jsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
2
+ import { createRoot } from 'react-dom/client';
3
3
 
4
4
  import ChooseModal from './Components/ChooseModal';
5
5
  import ProcessingModal from './Components/ProcessingModal';
@@ -14,12 +14,27 @@ import GovOSPayInvoiceSummaryModal from './Components/GovOSPayInvoiceSummaryModa
14
14
 
15
15
  import { restoreNativeEventConstructor, loadJQuery } from './shims';
16
16
 
17
+ import '../index.css';
17
18
  import './OpenViewStyles.css';
18
19
 
20
+ // Helper function to render with React 18 createRoot
21
+ let rootInstance = null;
22
+ const renderModal = (element, containerId) => {
23
+ const containerElement = document.getElementById(containerId);
24
+ if (!containerElement) {
25
+ console.warn(`Container element with id "${containerId}" not found`);
26
+ return;
27
+ }
28
+ if (!rootInstance) {
29
+ rootInstance = createRoot(containerElement);
30
+ }
31
+ rootInstance.render(element);
32
+ };
33
+
19
34
  const handlePaymentModal = {};
20
35
 
21
36
  handlePaymentModal.chooseModal = settings => {
22
- ReactDOM.render(
37
+ renderModal(
23
38
  <ChooseModal
24
39
  title={settings.title}
25
40
  description={settings.description}
@@ -28,16 +43,16 @@ handlePaymentModal.chooseModal = settings => {
28
43
  onWithPay={settings.callbacks.withPay}
29
44
  onClose={settings.callbacks.close}
30
45
  />,
31
- document.getElementById('payment-modal')
46
+ 'payment-modal'
32
47
  );
33
48
  };
34
49
 
35
50
  handlePaymentModal.processingModal = () => {
36
- ReactDOM.render(<ProcessingModal />, document.getElementById('payment-modal'));
51
+ renderModal(<ProcessingModal />, 'payment-modal');
37
52
  };
38
53
 
39
54
  handlePaymentModal.errorModal = settings => {
40
- ReactDOM.render(
55
+ renderModal(
41
56
  <ErrorModal
42
57
  isOptional={settings.isOptional}
43
58
  errorText={settings.errorText}
@@ -45,19 +60,19 @@ handlePaymentModal.errorModal = settings => {
45
60
  onRetry={settings.callbacks.retry}
46
61
  onClose={settings.callbacks.close}
47
62
  />,
48
- document.getElementById('payment-modal')
63
+ 'payment-modal'
49
64
  );
50
65
  };
51
66
 
52
67
  handlePaymentModal.successModal = settings => {
53
- ReactDOM.render(
68
+ renderModal(
54
69
  <SuccessModal description={settings.description} />,
55
- document.getElementById('payment-modal')
70
+ 'payment-modal'
56
71
  );
57
72
  };
58
73
 
59
74
  handlePaymentModal.selectPaymentModal = settings => {
60
- ReactDOM.render(
75
+ renderModal(
61
76
  <SelectPaymentModal
62
77
  isPaymentRequired={settings.isPaymentRequired}
63
78
  onPayByBank={settings.callbacks.onPayByBank}
@@ -71,12 +86,12 @@ handlePaymentModal.selectPaymentModal = settings => {
71
86
  isCreditCardFeeEnable={settings.isCreditCardFeeEnable}
72
87
  isBankAccountFeeEnable={settings.isBankAccountFeeEnable}
73
88
  />,
74
- document.getElementById('payment-modal')
89
+ 'payment-modal'
75
90
  );
76
91
  };
77
92
 
78
93
  handlePaymentModal.achPaymentModal = settings => {
79
- ReactDOM.render(
94
+ renderModal(
80
95
  <ACHPaymentModal
81
96
  onPay={settings.callbacks.onPay}
82
97
  onClose={settings.callbacks.onClose}
@@ -86,14 +101,14 @@ handlePaymentModal.achPaymentModal = settings => {
86
101
  description={settings.description}
87
102
  feeName={settings.feeName}
88
103
  />,
89
- document.getElementById('payment-modal')
104
+ 'payment-modal'
90
105
  );
91
106
  };
92
107
 
93
108
  // TODO: Remove use of shims when mootools is removed
94
109
  handlePaymentModal.govOSPayACHPaymentModal = settings => {
95
110
  restoreNativeEventConstructor();
96
- ReactDOM.render(
111
+ renderModal(
97
112
  <GovOSPayACHPaymentModal
98
113
  onPay={settings.callbacks.onPay}
99
114
  onClose={settings.callbacks.onClose}
@@ -103,8 +118,9 @@ handlePaymentModal.govOSPayACHPaymentModal = settings => {
103
118
  transactionUrl={settings.transactionUrl}
104
119
  getTransactionUrl={settings.getTransactionUrl}
105
120
  updateTransactionUrl={settings.updateTransactionUrl}
121
+ lineItems={settings.lineItems}
106
122
  />,
107
- document.getElementById('payment-modal')
123
+ 'payment-modal'
108
124
  );
109
125
  }
110
126
 
@@ -112,7 +128,7 @@ handlePaymentModal.govOSPayACHPaymentModal = settings => {
112
128
  handlePaymentModal.govOSPayCardPaymentModal = settings => {
113
129
  restoreNativeEventConstructor();
114
130
  loadJQuery(() => {
115
- ReactDOM.render(
131
+ renderModal(
116
132
  <GovOSPayCardPaymentModal
117
133
  onPay={settings.callbacks.onPay}
118
134
  onClose={settings.callbacks.onClose}
@@ -123,8 +139,9 @@ handlePaymentModal.govOSPayCardPaymentModal = settings => {
123
139
  transactionUrl={settings.transactionUrl}
124
140
  getTransactionUrl={settings.getTransactionUrl}
125
141
  updateTransactionUrl={settings.updateTransactionUrl}
142
+ lineItems={settings.lineItems}
126
143
  />,
127
- document.getElementById('payment-modal')
144
+ 'payment-modal'
128
145
  );
129
146
  });
130
147
  }
@@ -132,18 +149,18 @@ handlePaymentModal.govOSPayCardPaymentModal = settings => {
132
149
  // TODO: Remove use of shims when mootools is removed
133
150
  handlePaymentModal.govOSPayInvoiceSummaryModal = settings => {
134
151
  restoreNativeEventConstructor();
135
- ReactDOM.render(
152
+ renderModal(
136
153
  <GovOSPayInvoiceSummaryModal
137
154
  onSubmit={settings.callbacks.onSubmit}
138
155
  onClose={settings.callbacks.onClose}
139
156
  transactionData={settings.transactionData}
140
157
  />,
141
- document.getElementById('payment-modal')
158
+ 'payment-modal'
142
159
  );
143
160
  }
144
161
 
145
162
  handlePaymentModal.none = () => {
146
- ReactDOM.render(<EmptyModal />, document.getElementById('payment-modal'));
163
+ renderModal(<EmptyModal />, 'payment-modal');
147
164
  };
148
165
 
149
166
  window.handlePaymentModal = handlePaymentModal;
package/webpack.config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
2
3
 
3
4
  module.exports = (_env, argv) => {
4
5
  const isProduction = argv.mode === 'production';
@@ -8,11 +9,37 @@ module.exports = (_env, argv) => {
8
9
  },
9
10
  output: {
10
11
  filename: 'payment-modals.js',
11
- path: '/build',
12
- library: 'payment-modals',
13
- libraryTarget: 'umd',
14
- umdNamedDefine: true
12
+ path: path.resolve(__dirname, 'build'),
13
+ library: {
14
+ name: 'payment-modals',
15
+ type: 'umd'
16
+ },
17
+ umdNamedDefine: true,
18
+ clean: true,
19
+ globalObject: 'this'
15
20
  },
21
+ // Solo aplicar externals en producción
22
+ // En desarrollo, React debe estar incluido en el bundle
23
+ externals: isProduction ? {
24
+ 'react': {
25
+ commonjs: 'react',
26
+ commonjs2: 'react',
27
+ amd: 'react',
28
+ root: 'React'
29
+ },
30
+ 'react-dom': {
31
+ commonjs: 'react-dom',
32
+ commonjs2: 'react-dom',
33
+ amd: 'react-dom',
34
+ root: 'ReactDOM'
35
+ },
36
+ 'react-dom/client': {
37
+ commonjs: 'react-dom/client',
38
+ commonjs2: 'react-dom/client',
39
+ amd: 'react-dom/client',
40
+ root: 'ReactDOM'
41
+ }
42
+ } : {},
16
43
  module: {
17
44
  rules: [
18
45
  {
@@ -23,18 +50,20 @@ module.exports = (_env, argv) => {
23
50
  }
24
51
  },
25
52
  {
26
- test: /\.css$/,
53
+ test: /\.module\.css$/,
27
54
  use: [
28
55
  'style-loader',
29
56
  {
30
57
  loader: 'css-loader',
31
58
  options: {
32
59
  importLoaders: 1,
33
- modules: true
60
+ modules: {
61
+ localIdentName: '[local]__[hash:base64:5]',
62
+ exportLocalsConvention: 'camelCase'
63
+ }
34
64
  }
35
65
  }
36
- ],
37
- include: /\.module\.css$/
66
+ ]
38
67
  },
39
68
  {
40
69
  test: /\.css$/,
@@ -55,24 +84,41 @@ module.exports = (_env, argv) => {
55
84
  use: {
56
85
  loader: 'html-loader',
57
86
  options: {
58
- attrs: ['img:src', 'link:href']
87
+ sources: {
88
+ list: [
89
+ { tag: 'img', attribute: 'src', type: 'src' },
90
+ { tag: 'link', attribute: 'href', type: 'src' }
91
+ ]
92
+ }
59
93
  }
60
94
  }
61
95
  }
62
96
  ]
63
97
  },
98
+ plugins: [
99
+ new HtmlWebpackPlugin({
100
+ template: path.join(__dirname, 'index.html'),
101
+ inject: 'body',
102
+ scriptLoading: 'blocking'
103
+ })
104
+ ],
64
105
  devServer: {
65
106
  port: 9000,
66
107
  compress: true,
67
108
  open: true,
68
- publicPath: '/build/',
69
- contentBase: path.join(__dirname, 'build'),
109
+ static: [
110
+ {
111
+ directory: path.join(__dirname),
112
+ publicPath: '/',
113
+ watch: true
114
+ }
115
+ ],
70
116
  historyApiFallback: true
71
117
  },
72
118
  devtool: isProduction ? false : 'inline-source-map',
73
119
  resolve: {
74
- modules: [path.join(__dirname, 'src'), 'node_modules'],
75
- extensions: ['.js', '.jsx', '.scss'],
120
+ modules: [path.join(__dirname, 'src'), path.join(__dirname), 'node_modules'],
121
+ extensions: ['.js', '.jsx', '.scss', '.css'],
76
122
  alias: {
77
123
  'react-virtualized/List': 'react-virtualized/dist/es/List'
78
124
  }