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

chore: Change testing to use cjs. #636

Merged
merged 3 commits into from
Oct 28, 2024
Merged

chore: Change testing to use cjs. #636

merged 3 commits into from
Oct 28, 2024

Conversation

kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Oct 25, 2024

BEGIN_COMMIT_OVERRIDE
chore: Change browser packages testing to use CJS.
feat: Vendor escapeStringRegexp to simplify builds.
END_COMMIT_OVERRIDE

SDK-816

@@ -1,5 +1,4 @@
import { jest } from '@jest/globals';
Copy link
Member Author

Choose a reason for hiding this comment

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

I put the TextEncoder and a crypto fix into a setup script.

Copy link
Member Author

Choose a reason for hiding this comment

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

Converted to JSON to remove the decision of ESM/CJS.

@@ -30,14 +30,12 @@
"build": "tsc --noEmit && rollup -c rollup.config.js",
"lint": "eslint . --ext .ts,.tsx",
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand",
"test": "npx jest --runInBand",
Copy link
Member Author

Choose a reason for hiding this comment

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

No longer require experimental options.

One of the many benefits is that I can get the debugger to work for this package now.

@@ -62,6 +60,7 @@
"prettier": "^3.0.0",
"rimraf": "^5.0.5",
"rollup": "^3.23.0",
"rollup-plugin-visualizer": "^5.12.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

This should have been a dev dependency to begin with.

"coverage": "yarn test --coverage",
"check": "yarn prettier && yarn lint && yarn build && yarn test"
},
"dependencies": {
"@launchdarkly/js-client-sdk-common": "1.10.0",
"escape-string-regexp": "^5.0.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

This package is ESM only, just vendoring it removes that as a factor in the builds.


Object.assign(window, { TextDecoder, TextEncoder });

Object.defineProperty(global.self, "crypto", {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to resolve the "digest of undefined" issue.

@kinyoklion kinyoklion marked this pull request as ready for review October 25, 2024 17:18
@kinyoklion kinyoklion requested a review from a team as a code owner October 25, 2024 17:18
@kinyoklion kinyoklion merged commit 48cac54 into main Oct 28, 2024
21 checks passed
@kinyoklion kinyoklion deleted the rlamb/simplify-testing branch October 28, 2024 14:37
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.

2 participants