-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Es modules #641
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
base: main
Are you sure you want to change the base?
Es modules #641
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request converts the sockjs-client library from CommonJS to ES modules, upgrading it to use modern JavaScript syntax and ES module imports/exports. The changes involve updating all files to use ES6 class syntax, arrow functions, and ES modules while also implementing linting improvements.
- Conversion from CommonJS (
require
/module.exports
) to ES modules (import
/export
) - Migration from function constructors to ES6 classes with static properties
- Modernization of JavaScript syntax including arrow functions and destructuring
Reviewed Changes
Copilot reviewed 60 out of 61 changed files in this pull request and generated 7 comments.
File | Description |
---|---|
package.json | Updates module type, dependencies, Node version requirements, and adds xo linting configuration |
lib/ files | Comprehensive conversion to ES modules with modern class syntax throughout all source files |
.eslintrc/.eslintignore | Removes old ESLint configuration files in favor of xo linting |
let source; | ||
let prop; | ||
for (source in args) { | ||
if (Object.prototype.hasOwnProperty.call(args, source)) { | ||
for (prop in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, prop)) { | ||
obj[prop] = source[prop]; | ||
object[prop] = source[prop]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for...in
loop is iterating over array indices rather than array elements. This should be for (const source of args)
to iterate over the actual source objects.
Copilot uses AI. Check for mistakes.
import {attachEvent, detachEvent} from '../utils/event.js'; | ||
import {createIframe, iframeEnabled} from '../utils/iframe.js'; | ||
import {getOrigin, addPath, isOriginEqual} from '../utils/url.js'; | ||
import {version} from '../package.json'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing from package.json may not work in all ES module environments. Consider creating a separate version.js file or using a different approach to access the version.
Copilot uses AI. Check for mistakes.
debug = require('debug')('sockjs-client:main'); | ||
} | ||
import {URL} from 'url-parse'; | ||
import {version} from '../package.json'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importing from package.json may not work in all ES module environments. Consider creating a separate version.js file or using a different approach to access the version.
import {version} from '../package.json'; | |
import {version} from './version.js'; |
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
No description provided.