Migrate to ES modules - #476
Merged
Merged
Conversation
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
force-pushed
the
feature/esm-migration
branch
from
September 12, 2026 00:10
82ee52e to
7fd66c6
Compare
Cooldude2606
approved these changes
Sep 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onmainis red.Every package gets
"type": "module", entrypoints and relative imports carry the.jsextension, and the webpack configs are renamed to.cjsbecause webpack-cli loads them withrequire.tsconfig.node.jsonmoves fromnode16tonodenextto match clusterio, which needs it for the JSON import attributes in its sources. Web component imports stay extension-less, as in clusterio, since webpack'sextensionAliasonly maps.jsto.ts.The tap tests and the shared helpers under
test/useimportandimport.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_equalsubpath import without a default export, while Node's own type stripping handles it. The lua runner resolves fengari withcreateRequire(testFile), since a bare import fromtest/lua/does not reach the plugin's devDependencies.Verified in a clusterio
mastercheckout with this repository underexternal_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 builtexp_scenarioandexp_groupsdeclarations under Node shows 111 and 18 permissions.Changelog
🤖 Generated with Claude Code