mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Fix running Clusterio from published packages
Since the move to ES modules and pnpm 12, packages installed from npm fail to start: - The package imports of @clusterio/lib point Node at TypeScript sources, which Node refuses to strip types from inside node_modules. - The controller, host and ctl import their package.json from next to the compiled entrypoint, a copy pnpm leaves out of the package. - ctl, host and web_ui have no .npmignore, so pnpm packs them using the repository .gitignore and leaves out nearly all of dist/. Resolve the package imports to the compiled files at runtime while keeping the sources for type checking, import package.json by package name so it resolves to the real file, and add .npmignore files so pnpm packs the same files as npm.
This commit is contained in:
1 parent
ae6e25d1b9
commit
b411c5bef8
8 files changed
+15
-6
No files matched your search
@@ -32,7 +32,7 @@ import { ConsoleTransport, levels, logger } from "@clusterio/lib";
|
||||
import Controller from "./src/Controller.js";
|
||||
import UserManager from "./src/UserManager.js";
|
||||
import UserRecord from "./src/UserRecord.js";
|
||||
import packageConfig from "./package.json" with { type: "json" };
|
||||
import packageConfig from "@clusterio/controller/package.json" with { type: "json" };
|
||||
|
||||
// globals
|
||||
let controller: Controller;
|
||||
|
||||
@@ -12,7 +12,7 @@ import ControlConnection from "./ControlConnection.js";
|
||||
import HostConnection from "./HostConnection.js";
|
||||
import WsServerConnector from "./WsServerConnector.js";
|
||||
|
||||
import packageConfig from "../package.json" with { type: "json" };
|
||||
import packageConfig from "@clusterio/controller/package.json" with { type: "json" };
|
||||
|
||||
const wsMessageCounter = new lib.Counter(
|
||||
"clusterio_controller_websocket_message_total",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Without an .npmignore pnpm packs using the repository .gitignore, which leaves out dist/
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import yargs, { type Argv } from "yargs";
|
||||
import path from "path";
|
||||
import packageConfig from "./package.json" with { type: "json" };
|
||||
import packageConfig from "@clusterio/ctl/package.json" with { type: "json" };
|
||||
import { strict as assert } from "assert";
|
||||
|
||||
// Reduce startup time by lazy compiling schemas.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Without an .npmignore pnpm packs using the repository .gitignore, which leaves out dist/
|
||||
@@ -15,7 +15,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "path";
|
||||
import yargs from "yargs";
|
||||
import packageConfig from "./package.json" with { type: "json" };
|
||||
import packageConfig from "@clusterio/host/package.json" with { type: "json" };
|
||||
import winston from "winston";
|
||||
import "winston-daily-rotate-file";
|
||||
|
||||
|
||||
@@ -25,11 +25,17 @@
|
||||
"type": "module",
|
||||
"imports": {
|
||||
"#WebSocket": {
|
||||
"node": "./src/link/WebSocket.node.ts",
|
||||
"node": {
|
||||
"types": "./src/link/WebSocket.node.ts",
|
||||
"default": "./dist/node/src/link/WebSocket.node.js"
|
||||
},
|
||||
"import": "./src/link/WebSocket.browser.ts"
|
||||
},
|
||||
"#is_deep_strict_equal": {
|
||||
"node": "./src/is_deep_strict_equal.node.ts",
|
||||
"node": {
|
||||
"types": "./src/is_deep_strict_equal.node.ts",
|
||||
"default": "./dist/node/src/is_deep_strict_equal.node.js"
|
||||
},
|
||||
"import": "./src/is_deep_strict_equal.browser.ts"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# Without an .npmignore pnpm packs using the repository .gitignore, which leaves out dist/
|
||||
Reference in new issue
Block a user