Skip to content

Commit

Permalink
Merge pull request #15 from KemingHe/fix-jsdombundlingissue-keminghe
Browse files Browse the repository at this point in the history
Fixed issue where node-only jsdom code fails to load if import package to edge env
  • Loading branch information
KemingHe authored Sep 22, 2024
2 parents ac02327 + b07272d commit b59eb8a
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
22
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [4.0.0](https://github.com/KemingHe/OSU/compare/v3.1.1...v4.0.0) (2024-09-22)


### ⚠ BREAKING CHANGES

* **package.json:** due to the sync/async import (bundling) separation, all previously defined import
will work as normal whilst async must be imported through @keminghe/osu/async

### Bug Fixes

* **package.json:** separated synd and async exports ([3ffb464](https://github.com/KemingHe/OSU/commit/3ffb464c36b6f69fdd2ef8967d2769073c63a681))

## [3.1.1](https://github.com/KemingHe/OSU/compare/v3.1.0...v3.1.1) (2024-09-21)

## [3.1.0](https://github.com/KemingHe/OSU/compare/v3.0.0...v3.1.0) (2024-09-21)
Expand Down
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<span>&nbsp;</span>
<a href="https://nodejs.org/en" >
<img
src="https://img.shields.io/badge/Supports-node18+-blue"
alt="supports node18+ (link to nodejs.org)"
src="https://img.shields.io/badge/Supports-node 8.1+-blue"
alt="supports node8.1+ (link to nodejs.org)"
/>
</a>
<span>&nbsp;</span>
Expand All @@ -42,20 +42,20 @@

> [!IMPORTANT]
>
> **Now requires Node 18 and up!** Please upgrade your node version.
> **Async** accessors depend on [`jsdom`](https://github.com/jsdom/jsdom) and are `node`-only. For example: `import { getResearchPostingsAsync } from "@keminghe/osu/async";`
>
> **Versions 1.1.0 and below are DEPRECATED!** Please upgrade to the latest version.
> Use import from the **synchronous** `@keminghe/osu` if you are working in a browswer environment.
> [!NOTE]
>
> Build by students, for students, with :heart:. **NOT** affiliated nor endorsed by official OSU.
> Build by students, for students, with :heart:. **NOT** affiliated by *official* OSU.
>
> * Publicly-available data about OSU undergrad majors [here](https://undergrad.osu.edu/majors-and-academics/majors).
> * Publicly-available data about OSU student organizations [here](https://activities.osu.edu/involvement/student_organizations).
> * Publicly-available *official* data about OSU undergrad majors [here](https://undergrad.osu.edu/majors-and-academics/majors).
> * Publicly-available *official* data about OSU student orgs [here](https://activities.osu.edu/involvement/student_organizations).
## :gear: Installation

Requires [Node.js](https://nodejs.org/en/download/package-manager) >= **18**
Requires [Node.js](https://nodejs.org/en/download/package-manager) >= **8.1.0** (es2017)

```bash
# Using npm:
Expand Down Expand Up @@ -105,28 +105,42 @@ BUCKEYEMAIL_PATTERN.test("[email protected]"); // true
### Accessing All Undergrad Majors

```typescript
import { getUndergradMajors, type UndergradMajor } from "@keminghe/osu";
import {
getUndergradMajors,
type UndergradMajor,
UndergradMajorSchema,
} from "@keminghe/osu";

const majors: UndergradMajor[] = getUndergradMajors();
UndergradMajorSchema.array().parse(majors);
console.log(majors);
```

### Accessing All Student Organizations

```typescript
import { getStudentOrgs, type StudentOrg } from "@keminghe/osu";
import {
getStudentOrgs,
type StudentOrg,
StudentOrgSchema,
} from "@keminghe/osu";

const orgs: StudentOrg[] = getStudentOrgs();
StudentOrgSchema.array().parse(orgs);
console.log(orgs);
```

### Accessing All Undergrad Research Postings
### Accessing All Undergrad Research Postings (Async!)

```typescript
import { getResearchPostingsAsync } from "@keminghe/osu";
import { ResearchPostingSchema, type ResearchPosting } from "@keminghe/osu";

// IMPORTANT: note the different async import path.
import { getResearchPostingsAsync } from "@keminghe/osu/async";

getResearchPostingsAsync()
.then((researchPostings) => {
ResearchPostingSchema.array().parse(researchPostings);
console.log(researchPostings);
})
.catch((error) => {
Expand Down
28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keminghe/osu",
"version": "3.1.1",
"version": "4.0.0",
"description": "Unofficial, publicly available data about The Ohio State University.",
"keywords": [
"data",
Expand All @@ -15,7 +15,25 @@
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./async": {
"import": "./dist/index.async.mjs",
"require": "./dist/index.async.js"
}
},
"types": "dist/index.d.ts",
"typesVersions": {
"*": {
"async": [
"./dist/index.async.d.ts"
]
}
},
"sideEffects": false,
"files": [
"dist",
"README.md",
Expand Down Expand Up @@ -50,8 +68,9 @@
"build": "tsup",
"postbuild": "echo 'Build complete: src/ -> dist/'"
},
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b",
"dependencies": {
"jsdom": "^25.0.0",
"jsdom": "^25.0.1",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -76,7 +95,7 @@
"vitest": "^2.1.1"
},
"engines": {
"node": ">=14"
"node": ">=8.10.0"
},
"os": [
"linux",
Expand All @@ -86,6 +105,5 @@
"cpu": [
"x64",
"arm64"
],
"packageManager": "[email protected]+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
]
}
Loading

0 comments on commit b59eb8a

Please sign in to comment.