Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export an esm module #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iambumblehead
Copy link

additionally export an esm module file

an indirect solution to iambumblehead/esmock#312

cc Filipoliko

I use a similar formulae to this with form-urlencoded and it is used by many people for both cjs and esm.

@iambumblehead
Copy link
Author

need to replace the require/import calls...

@iambumblehead iambumblehead force-pushed the additionally-export-esm-module branch 2 times, most recently from 08b6291 to 88f0335 Compare October 4, 2024 17:52
@iambumblehead
Copy link
Author

using this patch, the related sample test passes with this branch

diff --git a/repro.test.mjs b/repro.test.mjs
index d32fe0c..b5ca1f1 100644
--- a/repro.test.mjs
+++ b/repro.test.mjs
@@ -12,7 +12,9 @@ test('parseChangelog', async () => {
             read: mock.fn(() => content),
         },
         'line-reader': { // This does not get mocked in `changelog-parser` module
-            readLine: mock.fn(() => content),
+            eachLine: async (fpath, cb, eol) => {
+              cb('content')
+            },
         }
     });
 
@@ -20,5 +22,8 @@ test('parseChangelog', async () => {
         filePath: 'fake',
     });
 
-    assert.equal(changelog, content);
+    assert.deepEqual(changelog, {
+       versions: [],
+       description: content
+    });
 });

tbh I'm not sure if the patch to changelog-parser is needed. part of the issue at the esmock ticket is the line-reader's "readLine" is mocked at 'changelog-parser' but changelog-parser never imports readLine so of course nothing happens.

@Filipoliko try mocking eachLine rather than readLine I would try myself but unfortunately have to take care of something right now.

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