Skip to content

Commit

Permalink
We now bundle dual ESM/CJS packages
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Jun 7, 2024
1 parent c4cb837 commit 571c5b3
Show file tree
Hide file tree
Showing 44 changed files with 7,441 additions and 3,034 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ docker/src/
node_modules/
.idea/

.vscode
.vscode

.parcel-cache
14 changes: 12 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,19 @@ Departing from version 2.x, there's been some minor API changes. A breaking chan

`client.login` now throws an error in case of failed login. Enclose the code using that method in a `try/catch` block to mitigate unhandled exceptions.

## Migrating to 8.x
## Migrating to 9.x

Starting with v8.0.0, the library switched to using ESNext (ESM). The consumers of this package version must ensure they use `import` instead of `require` to import resources from this package.
Starting with v9.0.0 this is a hybrid ES Modules / CommonJS library.

Additionally, all of the exports formerly in the `lib/` directory are now bundled and exported from `rpc-websockets` itself. Any inner dependencies that you used to import can now be imported from the main package.

```ts
// Before
import WebSocketFactory from "rpc-websockets/dist/lib/client/websocket.cjs";

// After
import { WebSocket as WebSocketFactory } from "rpc-websockets";
```

## Client

Expand Down
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["@parcel/babel-plugin-transform-runtime"]
}
2 changes: 1 addition & 1 deletion build-browser-bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { build } from "esbuild"
import babelPlugin from "esbuild-plugin-babel"

await build({
entryPoints: ["./dist/index.browser.cjs"],
entryPoints: ["./dist/index.browser.mjs"],
outfile: "./dist/index.browser-bundle.js",
bundle: true,
format: "iife",
Expand Down
7 changes: 1 addition & 6 deletions dist/index.browser-bundle.js

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions dist/index.browser.cjs

This file was deleted.

5 changes: 0 additions & 5 deletions dist/index.browser.d.cts

This file was deleted.

Loading

0 comments on commit 571c5b3

Please sign in to comment.