Skip to content

Commit 388c616

Browse files
feat: provide an ESM build with and without debug
See also: socketio/engine.io-client@00d7e7d
1 parent 75530b4 commit 388c616

10 files changed

+55
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
dist/
3+
build/

lib/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isBinary } from "./is-binary";
1+
import { isBinary } from "./is-binary.js";
22

33
/**
44
* Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.

lib/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import Emitter = require("component-emitter");
2-
import { deconstructPacket, reconstructPacket } from "./binary";
3-
import { isBinary, hasBinary } from "./is-binary";
1+
import Emitter from "@socket.io/component-emitter";
2+
import { deconstructPacket, reconstructPacket } from "./binary.js";
3+
import { isBinary, hasBinary } from "./is-binary.js";
4+
import debugModule from "debug"; // debug()
45

5-
const debug = require("debug")("socket.io-parser");
6+
const debug = debugModule("socket.io-parser"); // debug()
67

78
/**
89
* Protocol version.

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
"url": "https://github.com/socketio/socket.io-parser.git"
88
},
99
"files": [
10-
"dist/"
10+
"build/"
1111
],
12-
"main": "./dist/index.js",
13-
"types": "./dist/index.d.ts",
12+
"main": "./build/cjs/index.js",
13+
"module": "./build/esm/index.js",
14+
"types": "./build/esm/index.d.ts",
15+
"exports": {
16+
"import": {
17+
"node": "./build/esm-debug/index.js",
18+
"default": "./build/esm/index.js"
19+
},
20+
"require": "./build/cjs/index.js"
21+
},
1422
"dependencies": {
15-
"@types/component-emitter": "^1.2.10",
16-
"component-emitter": "~1.3.0",
23+
"@socket.io/component-emitter": "~2.0.0",
1724
"debug": "~4.3.1"
1825
},
1926
"devDependencies": {
@@ -33,7 +40,7 @@
3340
"zuul-ngrok": "4.0.0"
3441
},
3542
"scripts": {
36-
"compile": "rimraf ./dist && tsc",
43+
"compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh",
3744
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
3845
"test:node": "mocha --reporter dot --bail test/index.js",
3946
"test:browser": "zuul test/index.js --no-coverage",

postcompile.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
cp ./support/package.cjs.json ./build/cjs/package.json
4+
cp ./support/package.esm.json ./build/esm/package.json
5+
6+
cp -r ./build/esm/ ./build/esm-debug/
7+
8+
sed -i '/debug(/d' ./build/esm/*.js

support/package.cjs.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

support/package.esm.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

tsconfig.esm.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "build/esm/",
4+
"target": "es2018",
5+
"module": "esnext",
6+
"moduleResolution": "node",
7+
"declaration": true
8+
},
9+
"include": [
10+
"./lib/**/*"
11+
]
12+
}

tsconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"compilerOptions": {
3-
"outDir": "./dist",
4-
"allowJs": false,
5-
"target": "es2017",
3+
"outDir": "build/cjs/",
4+
"target": "es2018", // Node.js 10 (https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping)
65
"module": "commonjs",
7-
"declaration": true
6+
"declaration": false
87
},
98
"include": [
109
"./lib/**/*"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy