Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Fix ESM/CJS compatibility#1
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| find dist -name '*.d.ts' -print0 | while IFS= read -r -d $'\0' file; do | ||
| echo " $file -> ${file%.d.ts}.d.cts" | ||
| cp "$file" "${file%.d.ts}.d.cts" | ||
| echo " $file -> ${file%.d.ts}.d.mts" | ||
| cp "$file" "${file%.d.ts}.d.mts" | ||
| rm "$file" | ||
| done | ||
| find dist -name '*.d.cts' -print0 | while IFS= read -r -d $'\0' file; do | ||
| echo " $file" | ||
| sed -e 's/\.d\.ts/.d.cts/' -i.bak "$file" | ||
| sed -e 's/\.js/.cjs/' -i.bak "$file" | ||
| done | ||
| find dist -name '*.d.mts' -print0 | while IFS= read -r -d $'\0' file; do | ||
| echo " $file" | ||
| sed -e 's/\.d\.ts/.d.mts/' -i.bak "$file" | ||
| sed -e 's/\.js/.mjs/' -i.bak "$file" | ||
| done | ||
| find dist -name '*.bak' -print0 | xargs -0 rm |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| export * from './error' | ||
| export * from './struct' | ||
| export * from './structs/coercions' | ||
| export * from './structs/refinements' | ||
| export * from './structs/types' | ||
| export * from './structs/utilities' | ||
| export * from './error.js' | ||
| export * from './struct.js' | ||
| export * from './structs/coercions.js' | ||
| export * from './structs/refinements.js' | ||
| export * from './structs/types.js' | ||
| export * from './structs/utilities.js' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { describe, it } from 'vitest' | ||
| import { strictEqual } from 'assert' | ||
| import { is, string } from '../../src' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { describe, it } from 'vitest' | ||
| import { deepStrictEqual, throws } from 'assert' | ||
| import { | ||
| mask, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import { describe, it } from 'vitest' | ||
| import { deepStrictEqual, strictEqual } from 'assert' | ||
| import { | ||
| validate, | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "include": ["./**/*.ts"] | ||
| "include": ["./**/*.ts"], | ||
| "compilerOptions": { | ||
| "lib": ["esnext"], | ||
| "skipLibCheck": true | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unfortunate we have to do this. If we don't do this, then we get type errors from
vitest. It seems that there are some requirements we may not be following here thatvitestdoes, one of which is to use amoduleResolutionofbundler(this can be observed in thevitestrepo and in another project that usesvitest, such as this one). However, that would require using TypeScript 5. Upgrading that in this project causes all kinds of errors, and I didn't want to bother with that considering this is just a temporary solution.