Open2
JavaScript アクションでも ES Module を使いたい [GitHub Actions]
Node.js 対応。
Node.js としては動くがアクションとして実行するとエラーになる。
file:///home/runner/work/nostr/nostr/webpack:/javascript-action/external node-commonjs "os":1
module.exports = require("os");
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/work/nostr/nostr/dist/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at Object.2037 (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/external node-commonjs "os":1:1)
at __nccwpck_require__ (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/webpack/bootstrap:21:1)
at Object.7351 (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/node_modules/@actions/core/lib/command.js:23:1)
at __nccwpck_require__ (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/webpack/bootstrap:21:1)
at Object.2186 (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/node_modules/@actions/core/lib/core.js:32:1)
at __nccwpck_require__ (file:///home/runner/work/nostr/nostr/webpack:/javascript-action/webpack/bootstrap:21:1)
at file:///home/runner/work/nostr/nostr/dist/index.js:7483:12
at file:///home/runner/work/nostr/nostr/dist/index.js:8821:3
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
↑のエラーの解決方法が分からなかったのと Jest もまだ ES Module は experimental のようだったので諦めた。
情報求む。