Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set type to ESM module, update CommonJS .js files to .cjs #88

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "node",
"request": "launch",
"name": "websocket server",
"program": "${workspaceFolder}/bin/server.js"
"program": "${workspaceFolder}/bin/server.cjs"
}
]
}
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/server.js → bin/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const WebSocket = require('ws')
const http = require('http')
const wss = new WebSocket.Server({ noServer: true })
const setupWSConnection = require('./utils.js').setupWSConnection
const setupWSConnection = require('./utils.cjs').setupWSConnection

const host = process.env.HOST || 'localhost'
const port = process.env.PORT || 1234
Expand Down
4 changes: 2 additions & 2 deletions bin/utils.js → bin/utils.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const map = require('lib0/dist/map.cjs')

const debounce = require('lodash.debounce')

const callbackHandler = require('./callback.js').callbackHandler
const isCallbackSet = require('./callback.js').isCallbackSet
const callbackHandler = require('./callback.cjs').callbackHandler
const isCallbackSet = require('./callback.cjs').isCallbackSet

const CALLBACK_DEBOUNCE_WAIT = parseInt(process.env.CALLBACK_DEBOUNCE_WAIT) || 2000
const CALLBACK_DEBOUNCE_MAXWAIT = parseInt(process.env.CALLBACK_DEBOUNCE_MAXWAIT) || 10000
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
"main": "./dist/y-websocket.cjs",
"module": "./src/y-websocket.js",
"types": "./dist/src/y-websocket.d.ts",
"type": "module",
"sideEffects": false,
"funding": {
"type": "GitHub Sponsors ❤",
"url": "https://github.com/sponsors/dmonad"
},
"scripts": {
"start": "node ./bin/server.js",
"start": "node ./bin/server.cjs",
"dist": "rm -rf dist && rollup -c && tsc",
"lint": "standard && tsc",
"test": "npm run lint",
"preversion": "npm run lint && npm run dist && test -e dist/src/y-websocket.d.ts && test -e dist/y-websocket.cjs"
},
"bin": {
"y-websocket-server": "./bin/server.js"
"y-websocket-server": "./bin/server.cjs"
},
"files": [
"dist/*",
Expand All @@ -27,8 +28,8 @@
],
"exports": {
"./package.json": "./package.json",
"./bin/utils": "./bin/utils.js",
"./bin/callback": "./bin/callback.js",
"./bin/utils": "./bin/utils.cjs",
"./bin/callback": "./bin/callback.cjs",
".": {
"import": "./src/y-websocket.js",
"require": "./dist/y-websocket.cjs"
Expand Down