Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Expose a consistent API for both ESM and CJS #555

Merged
merged 3 commits into from Jul 29, 2020
Merged

Expose a consistent API for both ESM and CJS #555

merged 3 commits into from Jul 29, 2020

Conversation

willdurand
Copy link
Member

@willdurand willdurand commented Jul 13, 2020

Fixes #517


This will require a new major version as the default import has changed (and it might not work with web-ext, see below), but the API should be more consistent now. I also ported some "test-util" code from web-ext.

Patch for web-ext:

diff --git a/src/cmd/sign.js b/src/cmd/sign.js
index a011ea4..8472c73 100644
--- a/src/cmd/sign.js
+++ b/src/cmd/sign.js
@@ -2,7 +2,7 @@
 import path from 'path';
 
 import {fs} from 'mz';
-import defaultAddonSigner from 'sign-addon';
+import { signAddon as defaultAddonSigner } from 'sign-addon';
 
 import defaultBuilder from './build';
 import getValidatedManifest, {getManifestId} from '../util/manifest';

@willdurand willdurand requested a review from rpl July 13, 2020 13:52
Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand this looks good (well, it is basically the same test we landed in the web-ext repo :-P), follows just a couple of nits

In particular I'm wondering if it would be a good idea to use tmp-promise and avoid copy and paste the TempDir class from the web-ext repo just for one functional test, what do you think?

(As an additional side note, we have to also rebase this pull request to fix the conflicts with the package-lock.json file, I guess that we may have merged some renovatebot pull request in the meantime).

package.json Show resolved Hide resolved
tests/functional/imports.spec.js Show resolved Hide resolved
tests/test-util.js Outdated Show resolved Hide resolved
@willdurand
Copy link
Member Author

I updated this patch.

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand this looks good to me, there are a couple of nits, but the actual reason why I haven't just accepted this version is that it looks that we should move shelljs and tmp (and I guess also the packages related to the typescript type definitions) from the dependencies to the devDependencies (and also update the package-lock.json to reflect that change).

tests/fixtures/require-as-cjs/test-require.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tests/functional/imports.spec.js Show resolved Hide resolved
tests/functional/imports.spec.js Outdated Show resolved Hide resolved
@willdurand willdurand requested a review from rpl July 28, 2020 19:49
@willdurand
Copy link
Member Author

Thanks for the review!

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@willdurand lgtm, r+wc (I think that we can move also the two @types/shell and @types/tmp dependencies to devDependencies, right?)

package.json Outdated Show resolved Hide resolved
@willdurand willdurand merged commit ff1d903 into master Jul 29, 2020
@willdurand willdurand deleted the esm branch July 29, 2020 10:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot import signAddon directly in ES modules on nodejs
2 participants