Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize /dist to simplify CommonJS import #53

Closed
rodneyrehm opened this issue Nov 13, 2015 · 2 comments
Closed

reorganize /dist to simplify CommonJS import #53

rodneyrehm opened this issue Nov 13, 2015 · 2 comments

Comments

@rodneyrehm
Copy link
Member

While discussing ally with @darobin, it became clear that using modules (with systems like browserify) is not ideal yet. We're assuming two things:

  1. users will (at least currently) prefer CommonJS modules
  2. users of AMD and ES6 can configure paths and are used to it

the current structure is

node_modules/ally.js/
├── dist
│   ├── ally.min.js (UMD)
│   ├── ally.min.js.map (UMD)
│   ├── amd
│   │   └── <AMD files>
│   └── common
│       └── <CJS files>
└── src
    └── <ES6 files>

the proposed structure is

node_modules/ally.js/
├── ally.min.js (UMD)
├── ally.min.js.map (UMD)
├── <CJS files>
├── amd
│   └── <AMD files>
└── src
    └── <ES6 files>

which would allow the following - without any configuration - in CommonJS based systems:

// load ally.min.js UMD bundle
var bundle = require('ally.js');
// load the same structure as the UMD bundle, but from CommonJS modules
var bundleFromModules = require('ally.js/ally');
// load a specific module
var module = require('ally.js/query/focusable');

You can configure AMD to load the UMD:

require.config({
  paths: {
    'ally.js': 'node_modules/ally.js/ally.min',
  }
});
// load ally.min.js UMD bundle
var bundle = require('ally.js');

OR you can configure AMD to load the modules:

require.config({
  paths: {
    'ally.js': 'node_modules/ally.js/amd',
  }
});
// load the same structure as the UMD bundle, but from AMD modules
var bundleFromModules = require('ally.js/ally');
// load a specific module
var module = require('ally.js/query/focusable');

The same applies to es6-module-loader.

@rodneyrehm rodneyrehm added this to the 1.0.0 - Focus Management milestone Nov 13, 2015
@rodneyrehm
Copy link
Member Author

The approach to solve this with minimal effort would be:

  1. use the prepublish script to copy the meta files (package.json, README.md, CHANGELOG.md, LICENSE.txt) to dist
  2. copy src to dist/src
  3. move dist/common/* to dist/*
  4. remove "files" from dist/package.json

and run npm publish dist to deploy the dist rather than the project root.

@rodneyrehm
Copy link
Member Author

available to test in 1.0.0-beta.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant