Glench / ExtPay

The JavaScript library for ExtensionPay.com — payments for your browser extensions, no server needed.
https://extensionpay.com
Other
483 stars 62 forks source link

Fix importing issue with Webpack #42

Closed henrikra closed 2 years ago

henrikra commented 2 years ago

Description

I noticed in this issue that importing this library does not work with Webpack correctly https://github.com/Glench/ExtPay/issues/41

Solution

The solution is to remove browser field because it was pointing to version of global ExtPay which is meant to be used when you want to have global variable ExtPay. But since package.json is meant for npm modules this is not what we want to do.

Very big libraries which are meant for browser do no use browser field of package.json. Great example from Vue.js (https://github.com/vuejs/vue/blob/main/package.json#L6). They only specify main + other fields but nobody uses browser.

How to test?

Use ExtPay library in Webpack and Rollup or some other bundler and see if you can now just import ExtPay like this

import ExtPay from 'extpay';

const extPay = ExtPay("some-id");

and run the code to see if you get any errors. If you don't then everything is cool!

Fixes #41

henrikra commented 2 years ago

@Glench There are basically two options to fix this issue:

  1. Remove the browser field like I did in this PR OR
  2. Keep browser field but change its value to ./dist/ExtPay.module.js

I am fine with either 👍

henrikra commented 2 years ago

It won't 👍