voltace / browser-cookies

Tiny cookies library for the browser
The Unlicense
89 stars 19 forks source link

Where's the browser bundle? #12

Open lmj0011 opened 7 years ago

lmj0011 commented 7 years ago

I noticed only the src is available after install this package. There's not a browerify bundle

voltace commented 7 years ago

The common way of working with browserify is for users to create their own bundles:

Step 1) Install browser-cookies package using npm:

npm install browser-cookies

Step 2) Write some code that uses browser-cookies:

/* filename: yourcode.js */
var cookies = require('browser-cookies');
cookies.set('someCookie', 'someValue');

Step 3) Create your own bundle using browserify:

browserify yourcode.js -o bundle.js

Does this answer your question, or do you have a different case?

lmj0011 commented 7 years ago

The common way of working with browserify is for users to create their own bundles:

most vendors do this already

https://github.com/pagekit/vue-resource/blob/develop/dist/vue-resource.js https://github.com/mzabriskie/axios/blob/master/dist/axios.js https://github.com/t4t5/sweetalert/blob/master/dist/sweetalert-dev.js

voltace commented 7 years ago

I'm OK with exporting a bundled (IIFE) version of browser-cookies to the npm package.

From the examples listed in your post above I prefer the approach taken by vue-resource to export multiple targets (CommonJS, es2015 and IIFE) while keeping the CommonJS target as the default script used by npm. I'd like to refrain from adding an IIFE to the CommonJS export as this would increase the file size for all CommonJS users, hence the preference for separate targets.

So far I've always developed using bundlers like Browserify and Rollup. For my understanding how do you typically use a package like Vue without a bundler, for example did you inspect the Vue distribution README to determine which exported file to use and do you include Vue as a separate script in your production environment?

dawsbot commented 6 years ago

Use this url: https://wzrd.in/standalone/browser-cookies@latest

It's a dope service called wzrd.in. Should probably tell the world more about that, add the link to the readme and close this ticket 👌

alik0211 commented 5 years ago

@voltace you're offering a way too complicated to get an browser-cookies for a browser.

A good way: upload a minified build to npm and add a link to the CDN(unpkg or jsdelivr).

You can see an example in my library for working with cookies in javascript — hardtack. If you will use the code from my library, please provide a link to it.