Skip to content

Commit 45f1f37

Browse files
authored
feat: Add an UMD fallback (#104)
1 parent bf68549 commit 45f1f37

File tree

10 files changed

+1376
-88
lines changed

10 files changed

+1376
-88
lines changed

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Publish
22
on:
33
schedule:
44
- cron: '0 0 * * *'
5+
workflow_dispatch:
56
jobs:
67
publish:
78
name: Publish
@@ -16,6 +17,8 @@ jobs:
1617
node-version: current
1718
- name: Install dependencies
1819
run: npm ci
20+
- name: Build
21+
run: npm run build
1922
- name: Run tests
2023
run: npm test
2124
- name: Publish

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
branches:
55
- main
66
pull_request:
7+
workflow_dispatch:
78
jobs:
89
test:
910
name: Test
@@ -18,5 +19,7 @@ jobs:
1819
node-version: ${{ matrix.node_version }}
1920
- name: Install dependencies
2021
run: npm ci --no-audit
22+
- name: Build
23+
run: npm run build
2124
- name: Run tests
2225
run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
npm-debug.*
3+
umd/index.js

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ In some use cases, however, it is required to be able to reliably work with and
2727
Usage
2828
-----
2929

30-
The class is compatible with CommonJS and AMD loaders and is exposed globally as `Long` if neither is available.
30+
The package exports an ECMAScript module with an UMD fallback.
3131

32-
```javascript
32+
```js
3333
import Long from "long";
3434

3535
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
@@ -38,6 +38,8 @@ console.log(longVal.toString());
3838
...
3939
```
4040

41+
Note that mixing ESM and CommonJS is not recommended as it yield different classes with the same functionality.
42+
4143
API
4244
---
4345

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,4 @@ declare class Long {
423423
xor(other: Long | number | string): Long;
424424
}
425425

426-
export default Long;
426+
export = Long; // compatible with `import Long from "long"`

0 commit comments

Comments
 (0)