Skip to content

Commit 5cdd0a1

Browse files
authored
feat: convert repository to ESM (#37)
BREAKING CHANGE: Transition to ESM only Converts the repository to use ESM syntax, enabling module support. - Adds `"type": "module"` to `package.json` to specify ESM support. - Updates `app.js` and `netlify/functions/webhooks.js` by replacing `require` statements with `import` statements and changing `module.exports` to `export default`. - Modifies `test.js` to use ESM import/export syntax, including updating `require` statements to `import` and changing `module.exports` to `export default` for the test suite.
1 parent 1bef11c commit 5cdd0a1

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @param {import('probot').Probot} app
33
*/
4-
module.exports = (app) => {
4+
export default (app) => {
55
app.log.info("Yay! The app was loaded!");
66

77
app.on("issues.opened", async (context) => {

netlify/functions/webhooks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { createProbot } = require("probot");
2-
const app = require("../../app");
1+
import { createProbot } from "probot";
2+
import app from "../../app.js";
33

44
const probot = createProbot();
55
const loadingApp = probot.load(app);
@@ -10,7 +10,7 @@ const loadingApp = probot.load(app);
1010
* @param {import("@netlify/functions").HandlerEvent} event
1111
* @param {import("@netlify/functions").HandlerContext} context
1212
*/
13-
exports.handler = async function (event, context) {
13+
export const handler = async function (event, context) {
1414
try {
1515
await loadingApp;
1616

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"description": "Probot & Netlify Functions example",
66
"main": "app.js",
7+
"type": "module",
78
"scripts": {
89
"start": "probot run ./app.js",
910
"test": "node test.js"

test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
const { suite } = require("uvu");
2-
const assert = require("uvu/assert");
1+
import { suite } from "uvu";
2+
import * as assert from "uvu/assert";
33

4-
const nock = require("nock");
4+
import nock from "nock";
55
nock.disableNetConnect();
66

7-
const { Probot, ProbotOctokit } = require("probot");
7+
import { Probot, ProbotOctokit } from "probot";
88

9-
const app = require("./app");
9+
import app from "./app.js";
1010

1111
/** @type {import('probot').Probot */
1212
let probot;

0 commit comments

Comments
 (0)