-
Notifications
You must be signed in to change notification settings - Fork 306
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
support ESM #772
Comments
Try this @eng-dibo : webpush.sendNotification(...)` |
I'd be happy to accept a PR if anybody wants to help. It sounds relatively easy to move to ESM (see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-move-my-commonjs-project-to-esm). |
I migrated everything to ESM but have one problem with tests namely testSendNotification.js had before each mocha.beforeEach(function () {
({ sendNotification, setGCMAPIKey, setVapidDetails } = require('../src/index'));
}); and then it deleted cache before each for clean start mocha.beforeEach(function() {
requestBody = null;
requestDetails = null;
// Delete caches of web push libs to start clean between test runs
delete require.cache[path.join(__dirname, '..', 'src', 'index.js')];
delete require.cache[path.join(__dirname, '..', 'src', 'web-push-lib.js')]; How would you recommend me approaching this if we wnat to get rid of require to make it ESM? |
I'm not sure to be honest, I'm not familiar enough with ESM. |
Would you be ok with me adding clearCache method to web-push-lib.js and index.js that would clear all state for testing? I don't think there's other way around that |
What if we simply call |
Maybe if #876 is done first, the need to reset state vanishes. |
try this. |
I want to use
web-push
server functions i.e.generateVAPIDKeys
andsendNotification
, but it seems that web-push doesn't support esm packages, i.e packages that definetype: module
on its package.jsonwhen using the default export the same error occurs because the file is compiled into ESM
The text was updated successfully, but these errors were encountered: