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

Offer an easier way to upgrade the polyfill in a WebExtension #7

Closed
kumar303 opened this issue Nov 15, 2016 · 5 comments
Closed

Offer an easier way to upgrade the polyfill in a WebExtension #7

kumar303 opened this issue Nov 15, 2016 · 5 comments

Comments

@kumar303
Copy link

The documentation currently suggests this approach for installing the polyfill in a WebExtension:

  • Clone the webextension-polyfill repo
  • Build the polyfill distribution
  • Copy the distribution into your WebExtension source

This works fine the first time but it doesn't offer an easy way to upgrade the polyfill when the upstream source changes.

Can you document (or implement) a better way? There would be a couple ways to approach it. The first thing that comes to mind is this:

  • Add a package.json to the WebExtension
  • Declare webextension-polyfill as a dependency
  • Configure the WebExtension project with babel to allow imports from node_modules and build an es6-friendly distribution for your WebExtension source files
  • Every time the dependencies are upgraded, the polyfill will be upgraded

Perhaps there is a simpler way that does not involve babel transpilation. Maybe with bower ?

@ivantsov
Copy link

Why don't publish this project as an npm package? It would solve lots of problems.

@fiveNinePlusR
Copy link

I would like this as well. Is there something technical that would stop this from happening?

josephfrazier added a commit to josephfrazier/webextension-polyfill that referenced this issue Jan 26, 2017
This addresses [issue 7] by making it possible for users to run:

```sh
npm install https://github.com/mozilla/webextension-polyfill
```

and download a module that they can use with a bundler as follows:

```js
import browser from 'webextension-polyfill';
```

Also, add a [prepublish script] so that users don't need to run `grunt`
manually. In addition, specify [files] in package.json so that this
module can be published to npm without including miscellanea. This can
be verified by running:

```sh
npm pack && tar -tvf webextension-polyfill-0.1.0.tgz
```

The `dist/` files would be generated upon publishing the package,
meaning that users could run `npm install webextension-polyfill`, then
load the following files into their extension, without having to build
them:

```
node_modules/webextension-polyfill/dist/browser-polyfill.js
node_modules/webextension-polyfill/dist/browser-polyfill.min.js
```

[issue 7]: mozilla#7
[files]: https://docs.npmjs.com/files/package.json#files
[prepublish script]: https://docs.npmjs.com/misc/scripts
josephfrazier added a commit to josephfrazier/webextension-polyfill that referenced this issue Jan 26, 2017
This addresses [issue 7] by making it possible for users to run:

```sh
npm install https://github.com/mozilla/webextension-polyfill
```

and download a module that they can use with a bundler as follows:

```js
import browser from 'webextension-polyfill';
```

Also, add a [prepublish script] so that users don't need to run `grunt`
manually. In addition, specify [files] in package.json so that this
module can be published to npm without including miscellanea. This can
be verified by running:

```sh
npm pack && tar -tvf webextension-polyfill-0.1.0.tgz
```

The `dist/` files would be generated upon publishing the package,
meaning that users could run `npm install webextension-polyfill`, then
load the following files into their extension, without having to build
them:

```
node_modules/webextension-polyfill/dist/browser-polyfill.js
node_modules/webextension-polyfill/dist/browser-polyfill.min.js
```

[issue 7]: mozilla#7
[files]: https://docs.npmjs.com/files/package.json#files
[prepublish script]: https://docs.npmjs.com/misc/scripts
@josephfrazier
Copy link
Contributor

josephfrazier commented Jan 26, 2017

See #17 for a patch that makes it possible to npm install from github and use with a bundler. If it's merged and subsequently published to npm, it will also be possible to npm install the pre-built dist/ files, so that no build tools or bundlers are needed.


If you'd like, you can go ahead and install it from github using:

npm install --save https://github.com/mozilla/webextension-polyfill#99faff94ffbf03094361875a10e1692acc4b8662

josephfrazier added a commit to josephfrazier/webextension-polyfill that referenced this issue Jan 31, 2017
This addresses [issue 7] by making it possible for users to run:

```sh
npm install webextension-polyfill
```

and download a module that they can use with a bundler as follows:

```js
import browser from 'webextension-polyfill';
```

Also, add a [prepublish script] so that users who clone the repo don't
need to run `grunt` manually. In addition, specify [files] in
package.json so that this module can be published to npm without
including miscellanea. This can be verified by running:

```sh
npm pack && tar -tvf webextension-polyfill-0.1.0.tgz
```

[issue 7]: mozilla#7
[files]: https://docs.npmjs.com/files/package.json#files
[prepublish script]: https://docs.npmjs.com/misc/scripts
rpl pushed a commit to rpl/webextension-polyfill that referenced this issue Apr 11, 2017
This addresses [issue 7] by making it possible for users to run:

```sh
npm install webextension-polyfill
```

and download a module that they can use with a bundler as follows:

```js
import browser from 'webextension-polyfill';
```

Also, add a [prepublish script] so that users who clone the repo don't
need to run `grunt` manually. In addition, specify [files] in
package.json so that this module can be published to npm without
including miscellanea. This can be verified by running:

```sh
npm pack && tar -tvf webextension-polyfill-0.1.0.tgz
```

[issue 7]: mozilla#7
[files]: https://docs.npmjs.com/files/package.json#files
[prepublish script]: https://docs.npmjs.com/misc/scripts
@rpl
Copy link
Member

rpl commented Apr 13, 2017

This should now be fixed (by #17, #35):

the built files are published on npm:

The npm package provides the polyfill wrapped as an UMD module and so, besides being used with bundling tools like browserify or webpack, it can also be used to retrieve a defined version when the project doesn't use (or doesn't want to use) a module bundler.

In #20 we are going to discuss how to provide the built files also on a public static url, as an additional way to retrieve the released versions without building the polyfill from sources.

@rpl rpl closed this as completed Apr 13, 2017
@Purexo
Copy link

Purexo commented Jul 21, 2017

Adding build in github release could be nice ;-)

So anyone can dl the build and place it in his project.

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

No branches or pull requests

6 participants