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

Major version proposal #26

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

oscarleonnogales
Copy link

JIRA

Summary

  • Setup the base config to support vitest
  • Build library contents with Vite instead of tsc
  • Update to node v18
  • Update to latest major version of TypeScript (5)
  • Other dev dependency updates
  • Removed jest support
  • Changed import and export statements into ES6 syntax inside the /src directory.
  • Created index.ts file as the entry point to the library. This is a breaking change, and the import statements to use our modules will now change: import { loadScript, loadStylesheet } from @braintree/asset-loader or var loadScript = require("@braintree/asset-loader").loadScript
  • Removed necessary files so we are not referencing the dist directory directly from the source code.
  • Moved load-script.ts and load-stylesheet.ts to src/lib/ directory

Why Vitest

Vitest is a "blazingly fast" unit test framework, and allows us to leave the test suite running in a watch-mode environment while we continue to make changes to our code. Only the necessary tests will re-run depending on what files were changed, making it much quicker to make changes without having to wait for the entire test suite to re-run.

Vitest has also been designed with a Jest compatible API, in order to make the migration from Jest as simple as possible. The API is essentially the same as Jest with some very minor differences.

Why Create index.ts as the entry point

  • Removes the risk of circular dependencies (we currently have some modules that rely on others)
  • Easier to add or remove additional imports
  • Allows us to remove any references to the dist folder from the source code
  • Consistency across some of our other repositories

Why use Vite instead of tsc

  • Lets us simultaneously output two different files index.js for ESM support and index.umd.cjs for CJS support.
  • ES6 output which all modern browsers fully support
  • Allows us to write and target newer ES versions during development that will get compiled to ES6.

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@oscarleonnogales oscarleonnogales requested a review from a team as a code owner November 7, 2023 19:34
Copy link

@hollabaq86 hollabaq86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some general questions and comments

# Unreleased

- BREAKING CHANGES
- Update exports to support ES6 syntax

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a lot for one PR. Ideally, I would prefer each of these entries to be a separate PR so that it's easier to understand what's changing and why in the commit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree that it seems like a lot, but it's hard to break this up into smaller PRs because the changes all rely on each other. The description should give a clear overview of what's changing, but I still recommend cloning this branch and looking at the file structure locally. No functionality was changed to loadScript and loadStylesheet which is essentially the only 2 things this library is doing.

@@ -35,23 +42,14 @@
"eslint": "^8.47.0",
"eslint-config-braintree": "^6.0.0-typescript-prep-rc.2",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.3",
"jest-environment-jsdom": "^29.6.3",
"happy-dom": "^10.11.2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happy-dom and why are we using it?

Copy link
Author

@oscarleonnogales oscarleonnogales Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a JS implementation of a web browser (mocking one essentially) that we use for running our tests. Can use this or jsdom.

tsconfig.json Outdated
"strict": true,
"target": "es5",
"lib": ["es2015", "dom"]
"noUncheckedIndexedAccess": true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we sort these options alphabetically?

tsconfig.json Outdated
"lib": ["es2015", "dom"]
"noUncheckedIndexedAccess": true,
"esModuleInterop": true,
"skipLibCheck": true,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting this to true? What are we skipping, here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping any TS checks inside the node_modules folder

Copy link
Contributor

@jplukarski jplukarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge in the main branch to include the changes that were made on Nov 29th? Also, resolve all conflicts?

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.

3 participants