Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save erwinverdonk/71c3cb4c72960d5fc897adb8635dfee7 to your computer and use it in GitHub Desktop.

Select an option

Save erwinverdonk/71c3cb4c72960d5fc897adb8635dfee7 to your computer and use it in GitHub Desktop.

Revisions

  1. @tracker1 tracker1 revised this gist Oct 23, 2014. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions 01-directory-structure.md
    Original file line number Diff line number Diff line change
    @@ -10,10 +10,6 @@ Beyond a suggested structure, no tooling recommendations, or sub-module structur
    * `src/` is intended for code that needs to be manipulated before it can be used
    * `build/` is for any scripts or tooling needed to build your project
    * `dist/` is for compiled modules that can be used with other systems.
    * `(module)-(version).browser.js` is a version of your module that is built to be used in a browser
    * `(module)-(version).browser.min.js` is the browser version minified
    * `(module)-(version).amd.js` is a module built for use with AMD
    * `(module)-(version).amd.min.js` is a minified version of the module for AMD
    * `bin/` is for any executable scripts, or compiled binaries used with, or built from your module.
    * `test/` is for all of your project/module's test scripts
    * `unit/` is a sub-directory for unit tests
    @@ -37,7 +33,7 @@ If you have scripts/tools that are needed in order to build your project, they s

    If your project/module is to be built for use with other platforms (either directly in the browser), or in an `AMD` system (such as `require.js`), then these outputted files should reside under the `dist` directory.

    It is recommended to use a `(module)-(version).(platform).[min].js` format for the files that output into this directory.
    It is recommended to use a `(module)-(version).(platform).[min].js` format for the files that output into this directory. For example `foo-0.1.0.browser.min.js` or `foo-0.1.0.amd.js`.

    ## bin

  2. @tracker1 tracker1 created this gist Oct 23, 2014.
    48 changes: 48 additions & 0 deletions 01-directory-structure.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    # Directory structure for JavaScript/Node Projects

    While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

    Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

    ## Directories

    * `lib/` is intended for code that can run as-is
    * `src/` is intended for code that needs to be manipulated before it can be used
    * `build/` is for any scripts or tooling needed to build your project
    * `dist/` is for compiled modules that can be used with other systems.
    * `(module)-(version).browser.js` is a version of your module that is built to be used in a browser
    * `(module)-(version).browser.min.js` is the browser version minified
    * `(module)-(version).amd.js` is a module built for use with AMD
    * `(module)-(version).amd.min.js` is a minified version of the module for AMD
    * `bin/` is for any executable scripts, or compiled binaries used with, or built from your module.
    * `test/` is for all of your project/module's test scripts
    * `unit/` is a sub-directory for unit tests
    * `integration/` is a sub-directory for integration tests
    * `env/` is for any environment that's needed for testing

    ## lib & src

    The difference in using `lib` vs `src` should be:

    * `lib` if you can use node's `require()` directly
    * `src` if you can not, or the file must otherwise be manipulated before use

    If you are committing copies of module/files that are from other systems, the use of `(lib|src)/vendor/(vendor-name)/(project-name)/` is suggested.

    ## build

    If you have scripts/tools that are needed in order to build your project, they should reside in the `build` directory. Examples include scripts to fetch externally sourced data as part of your build process. Another example would be using `build/tasks/` as a directory for separating tasks in a project.

    ## dist

    If your project/module is to be built for use with other platforms (either directly in the browser), or in an `AMD` system (such as `require.js`), then these outputted files should reside under the `dist` directory.

    It is recommended to use a `(module)-(version).(platform).[min].js` format for the files that output into this directory.

    ## bin

    The `bin` folder is for any system modules your package will use and/or generate.

    * The compiled `node_gyp` output for your module's binary code.
    * Pre-compiled platform binaries
    * <code>[package.json/bin](http://browsenpm.org/package.json#bin)</code> scripts for your module