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
@@ -4,7 +4,7 @@ import { BaseControllerPlugin } from "@clusterio/controller";
|
||||
import { Static } from "@sinclair/typebox";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
const { RateLimiter } = lib;
|
||||
import { RateLimiter } from "@clusterio/lib";
|
||||
|
||||
import {
|
||||
ContributionEvent,
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
TechnologySync,
|
||||
SyncTechnologiesRequest,
|
||||
TechnologyProgress,
|
||||
} from "./messages";
|
||||
} from "./messages.js";
|
||||
|
||||
type Technology = {
|
||||
level: number,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type * as lib from "@clusterio/lib";
|
||||
|
||||
import * as messages from "./messages";
|
||||
import * as messages from "./messages.js";
|
||||
|
||||
export const plugin: lib.PluginDeclaration = {
|
||||
name: "research_sync",
|
||||
title: "Research Sync",
|
||||
description: "Synchronises technology research progress between instances.",
|
||||
instanceEntrypoint: "dist/node/instance",
|
||||
controllerEntrypoint: "dist/node/controller",
|
||||
instanceEntrypoint: "dist/node/instance.js",
|
||||
controllerEntrypoint: "dist/node/controller.js",
|
||||
|
||||
features: [
|
||||
"SavePatching",
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
FinishedEvent,
|
||||
TechnologySync,
|
||||
SyncTechnologiesRequest,
|
||||
} from "./messages";
|
||||
} from "./messages.js";
|
||||
|
||||
// ./module/sync.lua
|
||||
type IpcContribution = {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"access": "public"
|
||||
},
|
||||
|
||||
"type": "module",
|
||||
"main": "dist/node/index.js",
|
||||
"scripts": {
|
||||
"prepare": "tsc --build && webpack-cli --mode production",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// These are libraries that does not have any units test, they are
|
||||
// required here in order to track coverage for them.
|
||||
|
||||
"use strict";
|
||||
require("../dist/node/instance");
|
||||
require("../dist/node/controller");
|
||||
import "../dist/node/instance.js";
|
||||
import "../dist/node/controller.js";
|
||||
File renamed without changes.
Reference in new issue
Block a user