mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Migrate to ECMAScript Modules
Migrate the usage of CommonJS specific code and imports to ESM. Roughly summarised this: - Changes all require() calls to import statement or expressions. - Changes usage of module.exports to export statements. - Replaces require.resolve with import.meta.resolve. - Replaces conditional imports with conditional subpath imports. - Replaces module === require.main with import.meta.main. - Adds the full filename with extention to all relative imports. - Changes all usage of __dirname and __filename to their import.meta equivalents. - Sets "type": "module" in package.json files. - Removes usage of "use strict". - Adds .ts an an alias of .js for the webpack build. Due to differences in how require and import resolves files the plugin entrypoints will have to include the filename and extension after this migration in order to work.
This commit is contained in:
1 parent
b69111dda3
commit
5dcaca4d0b
261 files changed
+1115
-1330
No files matched your search
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
const { JsonBoolean, JsonString } = require("@clusterio/lib");
|
||||
import { JsonBoolean, JsonString } from "@clusterio/lib";
|
||||
|
||||
// Sent from ctl to the controller, which answers with the text it was given
|
||||
// and broadcasts a HostEcho to the hosts.
|
||||
class ControllerEcho {
|
||||
export class ControllerEcho {
|
||||
static type = "request";
|
||||
static src = "control";
|
||||
static dst = "controller";
|
||||
@@ -21,7 +20,7 @@ class ControllerEcho {
|
||||
}
|
||||
|
||||
// Broadcast from the controller to the hosts by broadcastEventToHosts.
|
||||
class HostEcho {
|
||||
export class HostEcho {
|
||||
static type = "event";
|
||||
static src = "controller";
|
||||
static dst = "host";
|
||||
@@ -39,7 +38,7 @@ class HostEcho {
|
||||
|
||||
// Sent from ctl to a host, which answers with whether it received the given
|
||||
// text via a HostEcho.
|
||||
class HostEchoReceived {
|
||||
export class HostEchoReceived {
|
||||
static type = "request";
|
||||
static src = "control";
|
||||
static dst = "host";
|
||||
@@ -55,9 +54,3 @@ class HostEchoReceived {
|
||||
toJSON() { return this.text; }
|
||||
static fromJSON(json) { return new this(json); }
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ControllerEcho,
|
||||
HostEcho,
|
||||
HostEchoReceived,
|
||||
};
|
||||
Reference in new issue
Block a user