jonschlinkert / gray-matter

Smarter YAML front matter parser, used by metalsmith, Gatsby, Netlify, Assemble, mapbox-gl, phenomic, vuejs vitepress, TinaCMS, Shopify Polaris, Ant Design, Astro, hashicorp, garden, slidev, saber, sourcegraph, and many others. Simple to use, and battle tested. Parses YAML by default but can also parse JSON Front Matter, Coffee Front Matter, TOML Front Matter, and has support for custom parsers. Please follow gray-matter's author: https://github.com/jonschlinkert
https://github.com/jonschlinkert
MIT License
3.97k stars 138 forks source link

Distribute for use by browsers. #93

Closed vvasuki closed 5 years ago

vvasuki commented 5 years ago

most of the modules I've installed as a js novice come with files ready to use in web browsers. I find it hard to figure out how to browserify this. Perhaps you could distribute this library that way as well or provide instructions for how to browserify it on the README?

robertmassaioli commented 5 years ago

To be honest, I just use webpack in all of my projects which works well for Gray Matter.

Maybe @jonschlinkert knows of a public example of using Gray Matter that @vvasuki could look at for inspiration.

vvasuki commented 5 years ago

To clarify - when I install the package with npm, I just want to be able to include use the library as in the below cases:

    <script src="{{ relURL "node_modules/jquery/dist/jquery.min.js" }}"></script>
    <script src="{{ relURL "node_modules/jquery-csv/src/jquery.csv.min.js" }}"></script>
    <script src="{{ relURL "node_modules/jquery-ui-dist/jquery-ui.min.js" }}"></script>
    <script src="{{ relURL "node_modules/bootstrap/dist/js/bootstrap.min.js" }}"></script>
    <script src="{{ relURL "node_modules/@sanskrit-coders/sanscript/sanscript.js" }}"></script>
    <script src="{{ relURL "node_modules/showdown/dist/showdown.js" }}"></script>

I don't like bundling all the js-s into a single bundle.js (seems to make debugging harder).

robertmassaioli commented 5 years ago

I don't like bundling all the js-s into a single bundle.js (seems to make debugging harder).

I think it might be a better idea to work out how to debug bundled code (via .map files) than to perform all of the manual labour with script includes.

I don't think this is a problem with this library; more with your use case. I'm going to close this as won't fix. If you want to package this library into a single JS file for your own use cases you should be able to use the browserify docs to do that.

patarapolw commented 4 years ago

In my latter packages, I also parcel-ify browser.js, to be able to auto-distribute to unpkg -- https://dev.to/patarapolw/npm-repo-with-pure-browser-version-and-also-with-tests-and-linting-28jo

@vvasuki Parcel is an effortless bundler, unlike Webpack.

// browser.js
import matter from 'gray-matter'
Object.assign(window, { matter })

Then, parcel build browser.js. Here you go, parcel'd version.