mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +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,8 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const { HostDetails } = require("@clusterio/lib");
|
||||
import assert from "node:assert/strict";
|
||||
import { HostDetails } from "@clusterio/lib";
|
||||
|
||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../common");
|
||||
import { testMatrix, testRoundTripJsonSerialisable } from "../../common.js";
|
||||
|
||||
describe("lib/data/HostDetails", function () {
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const { InstanceDetails } = require("@clusterio/lib");
|
||||
import assert from "node:assert/strict";
|
||||
import { InstanceDetails } from "@clusterio/lib";
|
||||
|
||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../common");
|
||||
import { testMatrix, testRoundTripJsonSerialisable } from "../../common.js";
|
||||
|
||||
describe("lib/data/InstanceDetails", function () {
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("path");
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
const lib = require("@clusterio/lib");
|
||||
const libBuildMod = require("@clusterio/lib/build_mod");
|
||||
const { ModInfo, ModDependency } = lib;
|
||||
import * as lib from "@clusterio/lib";
|
||||
import * as libBuildMod from "@clusterio/lib/build_mod.js";
|
||||
import { ModInfo, ModDependency } from "@clusterio/lib";
|
||||
|
||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../common");
|
||||
import { testMatrix, testRoundTripJsonSerialisable } from "../../common.js";
|
||||
|
||||
describe("lib/data/ModInfo", function() {
|
||||
describe("class ModDependency", function() {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const zlib = require("zlib");
|
||||
import assert from "node:assert/strict";
|
||||
import zlib from "node:zlib";
|
||||
|
||||
const lib = require("@clusterio/lib");
|
||||
const { ModInfo, ModPack, getInstalledModUpdates, applyModRecordAdvisories } = lib;
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { ModInfo, ModPack, getInstalledModUpdates, applyModRecordAdvisories } from "@clusterio/lib";
|
||||
|
||||
|
||||
describe("lib/data/ModPack", function() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const lib = require("@clusterio/lib");
|
||||
import assert from "node:assert/strict";
|
||||
import * as lib from "@clusterio/lib";
|
||||
|
||||
describe("lib/data/Role", function() {
|
||||
let defaultPermissions;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
const lib = require("@clusterio/lib");
|
||||
const { SystemInfo } = lib;
|
||||
import { SystemInfo } from "@clusterio/lib";
|
||||
|
||||
|
||||
describe("lib/data/SystemInfo", function() {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const { UserDetails, PlayerStats } = require("@clusterio/lib");
|
||||
import assert from "node:assert/strict";
|
||||
import { UserDetails, PlayerStats } from "@clusterio/lib";
|
||||
|
||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../common");
|
||||
import { testMatrix, testRoundTripJsonSerialisable } from "../../common.js";
|
||||
|
||||
describe("lib/data/UserDetails", function () {
|
||||
it("should be round trip serialisable", function () {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const lib = require("@clusterio/lib");
|
||||
const { Address } = lib;
|
||||
import assert from "node:assert/strict";
|
||||
import { Address } from "@clusterio/lib";
|
||||
|
||||
describe("lib/data/messages_core", function() {
|
||||
describe("class Address", function() {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const lib = require("@clusterio/lib");
|
||||
import assert from "node:assert/strict";
|
||||
import * as lib from "@clusterio/lib";
|
||||
|
||||
const { testMatrix, testRoundTripJsonSerialisable } = require("../../common");
|
||||
import { testMatrix, testRoundTripJsonSerialisable } from "../../common.js";
|
||||
|
||||
describe("lib/data/version", function() {
|
||||
describe("isVersionEquality()", function() {
|
||||
|
||||
Reference in new issue
Block a user