Adding support to Node 18 (#2065)

* feat: draft

* feat: draft2

* feat: fixed webpack on playground

* fix: playwright env

* fix: e2e testcafe

* fix: cleanup
This commit is contained in:
Guilherme Ribeiro
2023-04-04 09:58:32 +02:00
committed by GitHub
parent ad1943d7fe
commit 63823888b0
22 changed files with 736 additions and 2526 deletions

View File

@@ -10,10 +10,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Use Node.js 16.x - name: Use Node.js 18.x
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 16.x node-version: 18.x
- name: install, coverage - name: install, coverage
run: | run: |

View File

@@ -12,7 +12,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
node-version: [16.x] node-version: [18.x]
# node-version: [16.x, 18.x, 19.x] # node-version: [16.x, 18.x, 19.x]
# Currently 18 and 19 are not supported, still keeping it # Currently 18 and 19 are not supported, still keeping it
# as a reminder for compatibility check # as a reminder for compatibility check

View File

@@ -16,7 +16,7 @@ jobs:
# Setup .npmrc file to publish to npm # Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 18
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
# Copy README to adyen-web package # Copy README to adyen-web package

View File

@@ -9,7 +9,7 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [16.x] node-version: [18.x]
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
v18.15.0

View File

@@ -1,5 +1,4 @@
const webpack = require('webpack'); const webpack = require('webpack');
const { merge } = require('webpack-merge');
const path = require('path'); const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin'); const HTMLWebpackPlugin = require('html-webpack-plugin');
const checkoutDevServer = require('@adyen/adyen-web-server'); const checkoutDevServer = require('@adyen/adyen-web-server');
@@ -30,6 +29,11 @@ const entriesReducer = (acc, { id }) => {
module.exports = { module.exports = {
mode: 'development', mode: 'development',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss']
},
plugins: [ plugins: [
...htmlPages.map(htmlPageGenerator), ...htmlPages.map(htmlPageGenerator),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
@@ -40,20 +44,22 @@ module.exports = {
} }
}) })
], ],
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
entry: { entry: {
...htmlPages.reduce(entriesReducer, {}) ...htmlPages.reduce(entriesReducer, {})
}, },
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss'] watchOptions: {
ignored: ['/node_modules/', '/!(@adyen/adyen-web/dist)/'],
aggregateTimeout: 200,
poll: 500
}, },
stats: { children: false },
module: { module: {
rules: [ rules: [
{ {
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [ oneOf: [
{ {
test: [/\.js?$/], test: [/\.js?$/],
@@ -85,44 +91,18 @@ module.exports = {
} }
] ]
}, },
devServer: { devServer: {
before: app => checkoutDevServer(app),
port, port,
host, host,
https: false, https: false,
inline: true,
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
// for the WebpackDevServer client so it can learn when the files were
// updated. The WebpackDevServer client is included as an entry point
// in the Webpack development configuration. Note that only changes
// to CSS are currently hot reloaded. JS changes will refresh the browser.
hot: true, hot: true,
// Enable gzip compression of generated files.
compress: true, compress: true,
onBeforeSetupMiddleware: devServer => {
// Silence WebpackDevServer's own logs since they're generally not useful. if (!devServer) {
// It will still show compile warnings and errors with this setting. throw new Error('webpack-dev-server is not defined');
clientLogLevel: 'none', }
checkoutDevServer(devServer.app);
// Tells dev-server to suppress messages like the webpack bundle information. }
// Errors and warnings will still be shown.
noInfo: true,
// By default files from `contentBase` will not trigger a page reload.
watchContentBase: false,
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebook/create-react-app/issues/293
// src/node_modules is not ignored to support absolute imports
// https://github.com/facebook/create-react-app/issues/1065
watchOptions: {
ignore: [/node_modules/, /!(@adyen\/adyen-web\/dist)/],
aggregateTimeout: 200,
poll: 500
},
overlay: false
} }
}; };

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers'; import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers'; import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -15,15 +15,15 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^5.2.7", "css-loader": "^5.2.7",
"dotenv": "^16.0.2", "dotenv": "^16.0.2",
"html-webpack-plugin": "^4.5.2", "html-webpack-plugin": "5.5.0",
"prettier": "^1.19.1", "prettier": "^1.19.1",
"sass-loader": "^10.2.0", "sass-loader": "^10.2.0",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",
"ts-loader": "^8.1.0", "ts-loader": "^8.1.0",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"webpack": "^4.46.0", "webpack": "5.76.3",
"webpack-cli": "^3.3.12", "webpack-cli": "5.0.1",
"webpack-dev-server": "^3.11.2" "webpack-dev-server": "4.13.1"
}, },
"dependencies": { "dependencies": {
"@adyen/adyen-web": "5.39.0" "@adyen/adyen-web": "5.39.0"

View File

@@ -1,5 +1,4 @@
const webpack = require('webpack'); const webpack = require('webpack');
const { merge } = require('webpack-merge');
const path = require('path'); const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin'); const HTMLWebpackPlugin = require('html-webpack-plugin');
const checkoutDevServer = require('@adyen/adyen-web-server'); const checkoutDevServer = require('@adyen/adyen-web-server');
@@ -39,6 +38,11 @@ const entriesReducer = (acc, { id }) => {
module.exports = { module.exports = {
mode: 'development', mode: 'development',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss']
},
plugins: [ plugins: [
...htmlPages.map(htmlPageGenerator), ...htmlPages.map(htmlPageGenerator),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
@@ -49,20 +53,22 @@ module.exports = {
} }
}) })
], ],
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
entry: { entry: {
...htmlPages.reduce(entriesReducer, {}) ...htmlPages.reduce(entriesReducer, {})
}, },
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss'] watchOptions: {
ignored: ['/node_modules/', '/!(@adyen/adyen-web/dist)/'],
aggregateTimeout: 200,
poll: 500
}, },
stats: { children: false },
module: { module: {
rules: [ rules: [
{ {
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [ oneOf: [
{ {
test: [/\.js?$/], test: [/\.js?$/],
@@ -94,44 +100,18 @@ module.exports = {
} }
] ]
}, },
devServer: { devServer: {
before: app => checkoutDevServer(app),
port, port,
host, host,
https: false, https: false,
inline: true,
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
// for the WebpackDevServer client so it can learn when the files were
// updated. The WebpackDevServer client is included as an entry point
// in the Webpack development configuration. Note that only changes
// to CSS are currently hot reloaded. JS changes will refresh the browser.
hot: true, hot: true,
// Enable gzip compression of generated files.
compress: true, compress: true,
onBeforeSetupMiddleware: devServer => {
// Silence WebpackDevServer's own logs since they're generally not useful. if (!devServer) {
// It will still show compile warnings and errors with this setting. throw new Error('webpack-dev-server is not defined');
clientLogLevel: 'none', }
checkoutDevServer(devServer.app);
// Tells dev-server to suppress messages like the webpack bundle information. }
// Errors and warnings will still be shown.
noInfo: true,
// By default files from `contentBase` will not trigger a page reload.
watchContentBase: false,
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebook/create-react-app/issues/293
// src/node_modules is not ignored to support absolute imports
// https://github.com/facebook/create-react-app/issues/1065
watchOptions: {
ignore: [/node_modules/, /!(@adyen\/adyen-web\/dist)/],
aggregateTimeout: 200,
poll: 500
},
overlay: false
} }
}; };

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es/index.js'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import '../../style.scss'; import '../../style.scss';

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es/index.js'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers'; import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { handleSubmit, handleAdditionalDetails } from '../../handlers'; import { handleSubmit, handleAdditionalDetails } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { getPaymentMethods } from '../../services'; import { getPaymentMethods } from '../../services';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es/index.js'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers'; import { handleSubmit, handleAdditionalDetails, handleError } from '../../handlers';
import { amount, shopperLocale, countryCode } from '../../services/commonConfig'; import { amount, shopperLocale, countryCode } from '../../services/commonConfig';

View File

@@ -28,16 +28,16 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^5.2.7", "css-loader": "^5.2.7",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"html-webpack-plugin": "^4.5.2", "html-webpack-plugin": "5.5.0",
"sass-loader": "^10.2.0", "sass-loader": "^10.2.0",
"source-map-loader": "^1.1.3", "source-map-loader": "^1.1.3",
"style-loader": "^2.0.0", "style-loader": "^2.0.0",
"testcafe": "^2.2.0", "testcafe": "^2.2.0",
"ts-loader": "^8.1.0", "ts-loader": "^8.1.0",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"webpack": "^4.46.0", "webpack": "5.76.3",
"webpack-cli": "^3.3.12", "webpack-cli": "5.0.1",
"webpack-dev-server": "^3.11.2", "webpack-dev-server": "4.13.1",
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
}, },
"dependencies": { "dependencies": {

View File

@@ -21,6 +21,7 @@
}, },
"./modern": "./dist/es.modern/index.js", "./modern": "./dist/es.modern/index.js",
"./dist/adyen.css": "./dist/adyen.css", "./dist/adyen.css": "./dist/adyen.css",
"./dist/es/adyen.css": "./dist/es/adyen.css",
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"version": "5.39.0", "version": "5.39.0",

View File

@@ -1,17 +0,0 @@
module.exports = {
resolve: {
mainFields: ['module', 'main'],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss']
},
stats: { children: false },
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
};

View File

@@ -1,8 +1,6 @@
const webpack = require('webpack'); const webpack = require('webpack');
const { merge } = require('webpack-merge');
const path = require('path'); const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin'); const HTMLWebpackPlugin = require('html-webpack-plugin');
const webpackConfig = require('./webpack.config');
const checkoutDevServer = require('@adyen/adyen-web-server'); const checkoutDevServer = require('@adyen/adyen-web-server');
const host = process.env.HOST || '0.0.0.0'; const host = process.env.HOST || '0.0.0.0';
const port = process.env.PORT || '3020'; const port = process.env.PORT || '3020';
@@ -39,8 +37,13 @@ const entriesReducer = (acc, { id }) => {
return acc; return acc;
}; };
module.exports = merge(webpackConfig, { module.exports = {
mode: 'development', mode: 'development',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss']
},
plugins: [ plugins: [
...htmlPages.map(htmlPageGenerator), ...htmlPages.map(htmlPageGenerator),
new webpack.HotModuleReplacementPlugin(), new webpack.HotModuleReplacementPlugin(),
@@ -52,10 +55,19 @@ module.exports = merge(webpackConfig, {
} }
}) })
], ],
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
entry: { entry: {
...htmlPages.reduce(entriesReducer, {}) ...htmlPages.reduce(entriesReducer, {})
}, },
watchOptions: {
ignored: ['/node_modules/', '/!(@adyen/adyen-web/dist)/'],
aggregateTimeout: 200,
poll: 500
},
module: { module: {
rules: [ rules: [
{ {
@@ -102,44 +114,18 @@ module.exports = merge(webpackConfig, {
} }
] ]
}, },
devServer: { devServer: {
before: app => checkoutDevServer(app),
port, port,
host, host,
https: false, https: false,
inline: true,
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
// for the WebpackDevServer client so it can learn when the files were
// updated. The WebpackDevServer client is included as an entry point
// in the Webpack development configuration. Note that only changes
// to CSS are currently hot reloaded. JS changes will refresh the browser.
hot: true, hot: true,
// Enable gzip compression of generated files.
compress: true, compress: true,
onBeforeSetupMiddleware: devServer => {
// Silence WebpackDevServer's own logs since they're generally not useful. if (!devServer) {
// It will still show compile warnings and errors with this setting. throw new Error('webpack-dev-server is not defined');
clientLogLevel: 'none', }
checkoutDevServer(devServer.app);
// Tells dev-server to suppress messages like the webpack bundle information. }
// Errors and warnings will still be shown.
noInfo: true,
// By default files from `contentBase` will not trigger a page reload.
watchContentBase: false,
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebook/create-react-app/issues/293
// src/node_modules is not ignored to support absolute imports
// https://github.com/facebook/create-react-app/issues/1065
watchOptions: {
ignore: [/node_modules/, /!(@adyen\/adyen-web\/dist)/],
aggregateTimeout: 200,
poll: 500
},
overlay: false
} }
}); };

View File

@@ -27,7 +27,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^5.2.7", "css-loader": "^5.2.7",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"html-webpack-plugin": "^4.5.2", "html-webpack-plugin": "5.5.0",
"postcss": "^8.4.7", "postcss": "^8.4.7",
"postcss-loader": "^4.3.0", "postcss-loader": "^4.3.0",
"sass-loader": "^10.2.0", "sass-loader": "^10.2.0",
@@ -35,10 +35,9 @@
"style-loader": "^2.0.0", "style-loader": "^2.0.0",
"ts-loader": "^8.1.0", "ts-loader": "^8.1.0",
"typescript": "^4.4.4", "typescript": "^4.4.4",
"webpack": "^4.46.0", "webpack": "5.76.3",
"webpack-cli": "^3.3.12", "webpack-cli": "5.0.1",
"webpack-dev-server": "^3.11.2", "webpack-dev-server": "4.13.1",
"webpack-merge": "^5.8.0",
"whatwg-fetch": "^3.6.2" "whatwg-fetch": "^3.6.2"
}, },
"dependencies": { "dependencies": {

View File

@@ -1,4 +1,4 @@
import AdyenCheckout from '@adyen/adyen-web/dist/es'; import AdyenCheckout from '@adyen/adyen-web';
import '@adyen/adyen-web/dist/es/adyen.css'; import '@adyen/adyen-web/dist/es/adyen.css';
import { getSearchParameters } from '../../utils'; import { getSearchParameters } from '../../utils';
import '../../../config/polyfills'; import '../../../config/polyfills';

3012
yarn.lock

File diff suppressed because it is too large Load Diff