Skip to content

Convert from CommonJS to ESM#362

Merged
dawidd6 merged 5 commits into
masterfrom
copilot/change-commonjs-to-esm
Jan 30, 2026
Merged

Convert from CommonJS to ESM#362
dawidd6 merged 5 commits into
masterfrom
copilot/change-commonjs-to-esm

Conversation

Copilot AI commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Convert from CommonJS to ESM

  • Add "type": "module" to package.json to enable ESM
  • Convert all require() statements to import statements in main.js
    • Changed const core = require('@actions/core') to import core from '@actions/core'
    • Changed const exec = require('@actions/exec') to import exec from '@actions/exec'
    • Changed const github = require('@actions/github') to import github from '@actions/github'
    • Changed const artifact = require('@actions/artifact') to import artifact from '@actions/artifact'
    • Changed const AdmZip = require('adm-zip') to import AdmZip from 'adm-zip'
    • Changed const filesize = require('filesize') to import { filesize } from 'filesize' (named export)
    • Changed const pathname = require('path') to import pathname from 'node:path' (with node: prefix)
    • Changed const fs = require('fs') to import fs from 'node:fs' (with node: prefix)
  • Used node: protocol prefix for built-in modules (best practice for ESM)
  • Fixed undeclared variable filtered - added const declaration (ESM strict mode requirement)
  • Fixed filesize function calls from filesize.filesize() to filesize() (named import)
  • Verified ESM imports work correctly with Node.js 20
  • Verified no syntax errors with node --check main.js
  • All CI issues resolved

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 30, 2026 13:33
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert CommonJS modules to ESM importing Convert from CommonJS to ESM Jan 30, 2026
Copilot AI requested a review from dawidd6 January 30, 2026 13:37
@dawidd6 dawidd6 marked this pull request as ready for review January 30, 2026 13:56
@dawidd6

dawidd6 commented Jan 30, 2026

Copy link
Copy Markdown
Owner

@copilot CI failed, please fix

Copilot AI and others added 2 commits January 30, 2026 14:01
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>
Co-authored-by: dawidd6 <9713907+dawidd6@users.noreply.github.com>

Copilot AI commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot CI failed, please fix

Fixed in commits 3e1c740 and e56b1fd. The CI failure was caused by two ESM strict mode issues:

  1. Undeclared variable filtered (required const declaration)
  2. Incorrect filesize.filesize() calls (should be filesize() for named import)

@dawidd6 dawidd6 merged commit 5ce83d2 into master Jan 30, 2026
23 checks passed
@dawidd6 dawidd6 deleted the copilot/change-commonjs-to-esm branch January 30, 2026 14:05
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