Skip to content

Migrate to ES modules - #476

Merged
Cooldude2606 merged 1 commit into
explosivegaming:mainfrom
bbassie:feature/esm-migration
Sep 12, 2026
Merged

Migrate to ES modules#476
Cooldude2606 merged 1 commit into
explosivegaming:mainfrom
bbassie:feature/esm-migration

Conversation

@bbassie

@bbassie bbassie commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Stacked on #475. Until that one merges, this diff includes its commit as well; the ES module change alone is the second commit.

Clusterio merged clusterio/clusterio#984, which converts its packages to ES modules. A CommonJS plugin can no longer import @clusterio/lib (TS1479), and plugin entrypoints must name the full file including .js. This is why CI on main is red.

Every package gets "type": "module", entrypoints and relative imports carry the .js extension, and the webpack configs are renamed to .cjs because webpack-cli loads them with require. tsconfig.node.json moves from node16 to nodenext to match clusterio, which needs it for the JSON import attributes in its sources. Web component imports stay extension-less, as in clusterio, since webpack's extensionAlias only maps .js to .ts.

The tap tests and the shared helpers under test/ use import and import.meta.dirname. Two things needed a fix beyond the syntax. The test scripts pass --type-strip-only, because tap's TypeScript loader compiled lib's new #is_deep_strict_equal subpath import without a default export, while Node's own type stripping handles it. The lua runner resolves fengari with createRequire(testFile), since a bare import from test/lua/ does not reach the plugin's devDependencies.

Verified in a clusterio master checkout with this repository under external_plugins: all eight packages build, the reference checks pass, and the tap suites pass with 523 and 575 assertions, the same counts as the last green CI run. Loading the built exp_scenario and exp_groups declarations under Node shows 111 and 18 permissions.

Changelog

### Changes
- Migrated the plugins to ES modules to follow clusterio. #476

🤖 Generated with Claude Code

Clusterio #984 converted its packages to ESM, so a CommonJS plugin can
no longer import @clusterio/lib and plugin entrypoints must name the
full file. Every package gets "type": "module", entrypoints and relative
imports carry the .js extension, and the webpack configs become .cjs as
webpack-cli loads them with require. tsconfig.node.json moves from
node16 to nodenext to match clusterio, which needs it for the JSON
import attributes in its sources.

The tap tests and the shared test helpers use import and
import.meta.dirname. The test scripts pass --type-strip-only so tap
leaves lib's .ts subpath imports to Node's own type stripping, as its
TypeScript loader compiled them without a default export. The lua
runner resolves fengari from the test file it is given, since a bare
import from the shared test directory does not reach the plugin's
devDependencies.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Cooldude2606
Cooldude2606 merged commit 06fc108 into explosivegaming:main Sep 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants