mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23: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,6 +1,6 @@
|
||||
import { CommandTree, Command } from "@clusterio/lib";
|
||||
import { BaseCtlPlugin } from "@clusterio/ctl";
|
||||
import { ChatEvent } from "./messages";
|
||||
import { ChatEvent } from "./messages.js";
|
||||
|
||||
const globalChatCommands = new CommandTree({
|
||||
name: "global-chat", description: "Global Chat plugin commands",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type * as lib from "@clusterio/lib";
|
||||
|
||||
import { ChatEvent } from "./messages";
|
||||
import { ChatEvent } from "./messages.js";
|
||||
|
||||
export const plugin: lib.PluginDeclaration = {
|
||||
name: "global_chat",
|
||||
title: "Global Chat",
|
||||
description: "Forwards chat between instances.",
|
||||
instanceEntrypoint: "dist/node/instance",
|
||||
ctlEntrypoint: "dist/node/control",
|
||||
instanceEntrypoint: "dist/node/instance.js",
|
||||
ctlEntrypoint: "dist/node/control.js",
|
||||
|
||||
features: [
|
||||
"ScriptCommands",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { BaseInstancePlugin } from "@clusterio/host";
|
||||
import { ChatEvent } from "./messages";
|
||||
import { ChatEvent } from "./messages.js";
|
||||
|
||||
/**
|
||||
* Removes server-specific tags from messages.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
|
||||
"type": "module",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build && webpack-cli --mode production",
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const lib = require("@clusterio/lib");
|
||||
|
||||
const mock = require("../../../test/mock");
|
||||
const lines = require("../../../test/lib/factorio/lines");
|
||||
const instance = require("../dist/node/instance");
|
||||
const info = require("../dist/node/index").plugin;
|
||||
const { ChatEvent } = require("../dist/node/messages");
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import * as mock from "../../../test/mock.js";
|
||||
import * as lines from "../../../test/lib/factorio/lines.js";
|
||||
import * as instance from "../dist/node/instance.js";
|
||||
import { plugin as info } from "../dist/node/index.js";
|
||||
import { ChatEvent } from "../dist/node/messages.js";
|
||||
|
||||
describe("global_chat plugin", function() {
|
||||
describe("removeTags()", function() {
|
||||
|
||||
File renamed without changes.
Reference in new issue
Block a user