npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-magepack

v3.0.1

Published

A yeoman generator for creating a react/redux based webpack enabled module for Magento 2

Downloads

1

Readme

MAGEPACK

A Yeoman generator for a Magento 2 ready, ReactJS/Redux application

Install

  1. Install yeoman npm install -g yo
  2. Install magepack npm install -g generator-magepack
  3. Done!

Get started

  1. Go to your target directory
  2. Run yo magepack
  3. Follow the prompts
  4. Once yeoman has finsihed, run npm i

Start dev

Run the dev server npm run dev.

A sample application is included as a starting point. Making use of ReactJS and Redux, the main application files can be found in view/frontend/web/js/src.

The view/frontend/web/js/src/index.entry.js file pulls together your application for bundling. The view/frontend/web/js/dist/ contains the final application distributable.

The structure of the generated files follows the structure of a Magento 2 JavaScript application. You can use this generator directly in app/code, app/design or vendor/ampersand/module.

You will need to update the view/frontend/web/js/App.js at the very least before being 100% Magento-ready:

define(
-   ['react', 'react-dom', 'prop-types', 'redux', 'react-redux', 'redux-thunk', 'app.min'], 
+   ['react', 'react-dom', 'prop-types', 'redux', 'react-redux', 'redux-thunk', 'Vendor_Module/js/dist/app.min'], 
    function(React, ReactDOM, PropTypes, Redux, ReactRedux, ReduxThunk, ReactApp) {

Commands

  • npm run dev to start a webpack dev server on http://localhost:8080/webpack-dev-server/
  • npm test to run any Jest spec files in view/frontend/web/js/spec/ (this command will also run a full build)
  • npm run lint to run ESLint against your files
  • npm run build to run the production webpack build of your module

Other

Linting

ESLint is used for linting. http://eslint.org/

Rules can be found under the eslintConfig key in package.json.

ESLint will be run automatically on every npm run build and npm run dev.

Prettier

Prettier is an opinionated code formatter. https://prettier.io/playground/

This will be run either by your editor (requires setup) or as a precommit hook. This will re-format your files that are marked as "staged" via git add before you commit.

Tests

Unit

Jest is used for unit testing. https://facebook.github.io/jest/

Test files should be added to: view/frontend/web/js/spec/ in the format filename.spec.js

Unit tests can be run via npm test.

Snapshot

Snapshot testing is available, see documentation here: http://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshot-testing-with-jest

You should commit snapshots to version control.