Skip to content

Commit

Permalink
feat: serve ESM bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Oct 13, 2021
1 parent eb5fdbd commit 60edecb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client-dist/socket.io.esm.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions client-dist/socket.io.esm.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class Server<
this.clientPathRegex = new RegExp(
"^" +
escapedPath +
"/socket\\.io(\\.min|\\.msgpack\\.min)?\\.js(\\.map)?(?:\\?|$)"
"/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)"
);
return this;
}
Expand Down
7 changes: 7 additions & 0 deletions test/socket.io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ describe("socket.io", () => {
testSourceMap("socket.io.msgpack.min.js.map")
);

it("should serve the ESM bundle", testSource("socket.io.esm.min.js"));

it(
"should serve the source map for the ESM bundle",
testSourceMap("socket.io.esm.min.js.map")
);

it("should handle 304", (done) => {
const srv = createServer();
new Server(srv);
Expand Down

2 comments on commit 60edecb

@chriskrycho
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey folks, heads up that this seems to have broken testem. I'm investigating with a number of other folks in the Ember community (Ember's test infra uses testem which uses socket.io) as a bunch of our CI builds started failing today. The surfacing issue is io.connect is not a function: it looks like testem expects io to be a namespace-style object in the global namespace—it's just loading it directly via <script> tag. I'm still poking around and trying to see exactly why and what the fix might be – reading this change, it's not obvious to me why it's serving the rolled-up ESM rather than the default globals build.

@chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented on 60edecb Oct 14, 2021

Choose a reason for hiding this comment

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

Correction: Testem is serving it via Express app which requires socketIO as the default CJS export and expecting that to serve it. This makes me suspect the issue is (related to?) the update to the API of engine.io in its 6.0.0.

Possibly related (but, I think, not identical): #4120

[I'm opening an issue to track this and will move these comments there.]

Edit: #4121

Please sign in to comment.