Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use babel to transpile typescript, remove global polyfill and add modern bundle #1343

Merged
merged 32 commits into from
Dec 13, 2021

Conversation

m1aw
Copy link
Contributor

@m1aw m1aw commented Oct 27, 2021

Summary

This ticket has 3 main objectives:

  • Remove the pollution happening with globally scoped polyfills
  • Atomically handle new polyfills
  • Provide an unpolyfilled / "modern" version of the lib to reduce the transferred size

To achieve this we start using core-js-pure via babel-runtime, this explains why babel was introduced.
For fast babel transpilation we started using babel-typescript-preset instead of doing 2 stages (tsc then babel).
For the "modern" build we use babel and babel-preset env with target:"module" and bugfixes:true.
Also the umd build now only runs when building the production bundle and not in dev to speed up compilation.

Tested scenarios

  • Unit test passed successfully
  • There was no increase in failed e2e tests
  • The resulting bundles where tests on chrome for global scoped pollution (checked if Function.toString() was being polyfilled for example)
  • Tested normal dropin flow on IE11

Fixed issue:

Might help #337

@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2021

Size Change: +204 kB (+39%) 🚨

Total Size: 724 kB

Filename Size Change
packages/lib/dist/adyen.js 193 kB +26.6 kB (+16%) ⚠️
packages/lib/dist/cjs/index.js 164 kB +446 B (0%)
packages/lib/dist/es/ar.js 4.42 kB +56 B (+1%)
packages/lib/dist/es/cs-CZ.js 3.96 kB +55 B (+1%)
packages/lib/dist/es/da-DK.js 3.6 kB +50 B (+1%)
packages/lib/dist/es/de-DE.js 3.88 kB +39 B (+1%)
packages/lib/dist/es/el-GR.js 4.89 kB +48 B (+1%)
packages/lib/dist/es/es-ES.js 3.63 kB +48 B (+1%)
packages/lib/dist/es/fi-FI.js 3.68 kB +38 B (+1%)
packages/lib/dist/es/fr-FR.js 3.83 kB +60 B (+2%)
packages/lib/dist/es/hr-HR.js 3.74 kB +61 B (+2%)
packages/lib/dist/es/hu-HU.js 3.92 kB +42 B (+1%)
packages/lib/dist/es/index.js 95.7 kB -1.71 kB (-2%)
packages/lib/dist/es/it-IT.js 3.63 kB +60 B (+2%)
packages/lib/dist/es/ja-JP.js 4.37 kB +40 B (+1%)
packages/lib/dist/es/ko-KR.js 3.99 kB +43 B (+1%)
packages/lib/dist/es/nl-NL.js 3.66 kB +37 B (+1%)
packages/lib/dist/es/no-NO.js 3.59 kB +47 B (+1%)
packages/lib/dist/es/pl-PL.js 4.01 kB +78 B (+2%)
packages/lib/dist/es/pt-BR.js 3.67 kB +66 B (+2%)
packages/lib/dist/es/ro-RO.js 3.87 kB +60 B (+2%)
packages/lib/dist/es/ru-RU.js 4.62 kB +65 B (+1%)
packages/lib/dist/es/sk-SK.js 4 kB +42 B (+1%)
packages/lib/dist/es/sl-SI.js 3.65 kB +53 B (+1%)
packages/lib/dist/es/sv-SE.js 3.62 kB +47 B (+1%)
packages/lib/dist/es/zh-CN.js 3.89 kB +46 B (+1%)
packages/lib/dist/es/zh-TW.js 4.06 kB +44 B (+1%)
packages/lib/dist/es.modern/ar.js 4.42 kB +4.42 kB (new file) 🆕
packages/lib/dist/es.modern/cs-CZ.js 3.96 kB +3.96 kB (new file) 🆕
packages/lib/dist/es.modern/da-DK.js 3.6 kB +3.6 kB (new file) 🆕
packages/lib/dist/es.modern/de-DE.js 3.88 kB +3.88 kB (new file) 🆕
packages/lib/dist/es.modern/el-GR.js 4.89 kB +4.89 kB (new file) 🆕
packages/lib/dist/es.modern/es-ES.js 3.63 kB +3.63 kB (new file) 🆕
packages/lib/dist/es.modern/fi-FI.js 3.68 kB +3.68 kB (new file) 🆕
packages/lib/dist/es.modern/fr-FR.js 3.83 kB +3.83 kB (new file) 🆕
packages/lib/dist/es.modern/hr-HR.js 3.74 kB +3.74 kB (new file) 🆕
packages/lib/dist/es.modern/hu-HU.js 3.92 kB +3.92 kB (new file) 🆕
packages/lib/dist/es.modern/index.js 82.9 kB +82.9 kB (new file) 🆕
packages/lib/dist/es.modern/it-IT.js 3.63 kB +3.63 kB (new file) 🆕
packages/lib/dist/es.modern/ja-JP.js 4.37 kB +4.37 kB (new file) 🆕
packages/lib/dist/es.modern/ko-KR.js 3.99 kB +3.99 kB (new file) 🆕
packages/lib/dist/es.modern/nl-NL.js 3.66 kB +3.66 kB (new file) 🆕
packages/lib/dist/es.modern/no-NO.js 3.59 kB +3.59 kB (new file) 🆕
packages/lib/dist/es.modern/pl-PL.js 4.01 kB +4.01 kB (new file) 🆕
packages/lib/dist/es.modern/pt-BR.js 3.67 kB +3.67 kB (new file) 🆕
packages/lib/dist/es.modern/ro-RO.js 3.87 kB +3.87 kB (new file) 🆕
packages/lib/dist/es.modern/ru-RU.js 4.62 kB +4.62 kB (new file) 🆕
packages/lib/dist/es.modern/sk-SK.js 4 kB +4 kB (new file) 🆕
packages/lib/dist/es.modern/sl-SI.js 3.65 kB +3.65 kB (new file) 🆕
packages/lib/dist/es.modern/sv-SE.js 3.62 kB +3.62 kB (new file) 🆕
packages/lib/dist/es.modern/zh-CN.js 3.89 kB +3.89 kB (new file) 🆕
packages/lib/dist/es.modern/zh-TW.js 4.06 kB +4.06 kB (new file) 🆕

compressed-size-action

sponglord and others added 18 commits November 1, 2021 11:30
* Fixing e2e tests that were failing after changes to attributes on iframes in securedFields release 3.5.4

* Adding missing closing bracket to selectors

* removing log
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](unshiftio/url-parse@1.5.1...1.5.3)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
* fix: e2e for v5

* fix: binLookup error tests

* fix: custom card errors

* fix: removing unused import
* feat: initial draft with issuers on top

* feat: predefined issuers connected to main flow

* feat: added tests + cleanup

* feat: added e2e test case

* feat: preventing ui to show invalid predefined issuers + ui adjustments

* feat: clean up useless changes

* fix: e2e files scanner

* feat: simplified config

* feat: translations

* feat: including highlighted issuers in the dropdown

* fix: i18n

* fix: adjusted margin
* Enhance the object stored in state.errors, for a particular securedField, with the properties that we used to send to the onError handler

* Fixed error handling for securedFields (custom card) playground

* Fixed material design example for securedFields (custom card) playground

* Removed unused import in securedFields playground file
* feat: e2e test for sessions

* fix: merged master and fixed conflict
@m1aw m1aw marked this pull request as ready for review November 4, 2021 15:02
@m1aw m1aw changed the title Feat/babel runtime Use babel to transpile typescript, remove global polyfill and add modern bundle Nov 17, 2021
@sonarcloud
Copy link

sonarcloud bot commented Dec 13, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@m1aw m1aw merged commit 3885a2f into master Dec 13, 2021
@m1aw m1aw deleted the feat/babel-runtime branch December 13, 2021 16:45
@ribeiroguilherme ribeiroguilherme mentioned this pull request Dec 14, 2021
@lynn1286
Copy link

lynn1286 commented Jul 3, 2022

image

I'm using nextjs to build adyen, but webpack chunks is unusually large. Is it wrong for me to use it?
Here's package.json

"@adyen/adyen-web": "^5.15.0",
 "next": "12.1.6",

Here is my code::

import type { ChangeEventHandler } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import { useRouter } from 'next/router'
import classnames from 'classnames'
import useSWR from 'swr'
import adyenCheckout from '@adyen/adyen-web'
import type Dropin from '@adyen/adyen-web/dist/types/components/Dropin'
import type { PaymentResponse } from '@adyen/adyen-web/dist/types/types'
import { paymentMethodsApi } from 'https/adyen-request'
import MessageAlert from '@/components/message/index'
import { usePaymentState } from '@/hooks/index'
import type { SessionsResponse } from '@/types/adyen'
import type { BillingAddress, ResultCode } from '@/hooks/use-payment-state'
import { PaymentStateAction, PaymentModelState } from '@/hooks/use-payment-state'
import '@adyen/adyen-web/dist/adyen.css'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants