
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
generator-packages
Advanced tools
Get a webapp up and running with one command.

This yeoman generator does two things:
Scaling a react/redux application is difficult and the traditional layer-based organization starts showing its cracks quickly. In my experience a better approach is a feature-based organization and this generator helps building that organization easier.
Read the blog article on the underlying philosophy: https://github.com/neurosnap/blog/blob/master/scaling-js-codebase-multiple-platforms.md
import auth from '@myapp/auth';yarn global add yoyarn global add generator-packagesyo packages
Follow the steps to complete it!
Then run the dev server:
make dev
Open browser to http://localhost:8000
Once the command finishes, it will copy files into project folder, install all necessary dependencies, and allow the developer to start building quickly
<project-folder>/
  packages/          # all features are built as if they were npm packages here
    web-app/         # this is the main web-app package that brings all other packages together
      app.ts         # root react component that pulls everything together
      index.ts       # init file that creates redux and renders `app`
      packages.ts    # where all packages are registered and root reducer is created
      store.ts       # redux store and middleware setup
      types.ts       # redux State definition
  public/
    index.html       # main html file
    index.css        # a place to put global css
  webpack/           # webpack files for dev and prod
    common.js
    dev.js
    prod.js
  .gitignore
  index.ts           # this is what webpack uses as the entry point to the app
  jest.config.js     # jest configuration file for testing
  Makefile           # all task runner commands
  package.json
  prettier.config.js # js auto formatter
  README.md
  tests.js           # file that jest uses before every test
  tsconfig.js        # typescript configuration file
  tslint.json        # lint configuration file
The primary command simply builds the scaffolding for the app, the next step is to add new features to the application.

yo packages:create
Follow the steps to complete it!
This will create a new package under packages where the developer can start
building the feature.  It will also link the package up to the main web-app
by adding the package to the web-app/packages.ts file.  This is necessary in order
for any reducers that were built in the new package.
The :create command will build a new feature and create some example files
of how to setup a new package.  A package can technically have any interface,
but for the main layers of the application, the index.ts file should export the following:
interface Module {
  reducers?: { [key: string]: (state: any, action: any) => any };
  effects?: { [key: string]: (action: any) => any };
  selectors?: { [key: string]: (state: any) => any };
  actions?: { [key: string]: (payload: any) => { type: string; payload: any } };
}
Keep in mind, they are all optional, but if you want the web-app to add a
packages reducers then it must be exports as a key, and that applies for
every other layer in the package.
Let's say the new feature is named todo
<project-folder>/
  packages/
    todo/
      index.ts
      slice.ts
      effects.ts
This command will also add the package to the packages.ts file.
For example here is a diff of packages.ts:
import { combineReducers, Reducer } from 'redux';
import use from 'redux-package-loader';
import { State } from './types';
const corePackages = [
  require('@myapp/auth'),
+ require('@myapp/todo'),
];
// this will automatically grab all reducers for each package and load
// them into the rootReducer and rootSaga
const packages = use(corePackages);
const rootReducer: Reducer<State> = combineReducers(packages.reducers);
export { packages, rootReducer };
FAQs
Get a webapp up and running with one command.
The npm package generator-packages receives a total of 0 weekly downloads. As such, generator-packages popularity was classified as not popular.
We found that generator-packages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.