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

Monorepo Structure (Using Ocular) #18

Merged
merged 9 commits into from
Sep 10, 2019
Merged

Monorepo Structure (Using Ocular) #18

merged 9 commits into from
Sep 10, 2019

Conversation

kenns29
Copy link
Collaborator

@kenns29 kenns29 commented Sep 9, 2019

Tested using the website and example folder:
installation steps:

  1. yarn
  2. yarn build
  3. cd example; yarn
  4. cd website; yarn; yarn start

Notes:

  1. The packages folder is renamed as "modules", following ocular convention.
  2. Each module name uses the @MLVis namespace, e.g. @mlvis/feature-list-view.
  3. moved the "react", "antd", "styled-components" and "reselect" dependency of each module to peerDependencies.
  4. temporarily added these dependencies ("react", "antd", "styled-components" and "reselect") into the devDependencies of the root package.json for development purpose (Ib mentioned it may be better to also add these to devDependencies in each of the modules so that they don't have to appear as devDependencies in the root package.json).
  5. Please pay attention to alias.config.js and make sure it is satisfactory:
const resolve = require('path').resolve;
const fs = require('fs');

const ROOT = resolve(__dirname, '.');
const MODULES_ROOT = resolve(ROOT, 'modules');
const ROOT_ALIAS = 'packages';

module.exports = () =>
  fs.readdirSync(MODULES_ROOT).reduce((aliasMap, pkg) => {
    // src/some-package
    const packagePath = resolve(MODULES_ROOT, pkg);
    if (!fs.lstatSync(packagePath).isDirectory()) {
      return aliasMap;
    }
    // packages/some-package/package.json
    const packageJsonPath = resolve(packagePath, 'package.json');
    // bypass alias mapping if no package.json exists
    if (!fs.existsSync(packageJsonPath)) {
      return aliasMap;
    }
    const packageInfo = require(packageJsonPath);
    // @mlvis/some-package => some-package
    const packageName = packageInfo.name.replace(/^(@mlvis\/)/, '');

    // TODO: use this instead when each module is done refactoring
    // {@mlvis/some-package: './modules/some-package/src'}
    // aliasMap[packageInfo.name] = resolve(packageDir, packageName, 'src');

    // TODO: replace all reference to packages/... to @mlvis/some-package inside
    // each module
    // {'packages/some-package' : './modules/some-package/src'}
    aliasMap[`${ROOT_ALIAS}/${pkg}`] = resolve(MODULES_ROOT, pkg, 'src');
    return aliasMap;
  }, {});
  1. The current structure requires each module to be published under a common org namespace in npm (considering @MLVis). We may also consider the option to have a large module with sub-packages, e.g. mlvis/manifold. However, this approach is currently not supported by ocular dev tools.

image

@CLAassistant
Copy link

CLAassistant commented Sep 9, 2019

CLA assistant check
All committers have signed the CLA.

@chrisirhc
Copy link
Contributor

Looks like the tests failed on eslint

package.json Show resolved Hide resolved
@kenns29 kenns29 changed the title Mono Repo Structure (Using Ocular) Monorepo Structure (Using Ocular) Sep 9, 2019
package.json Show resolved Hide resolved
alias.config.js Show resolved Hide resolved
modules/manifold/package.json Show resolved Hide resolved
modules/manifold/package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
Copy link
Contributor

@gnavvy gnavvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing the description field in feature-list-view & mlvis-common.
The description for multi-way-plot, segment-filters, etc. are off (currently copied from Manifold's).

Otherwise LGTM.

modules/manifold/package.json Outdated Show resolved Hide resolved
modules/feature-list-view/package.json Show resolved Hide resolved
Copy link

@Firenze11 Firenze11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also change kepler version to 1.1.5. Otherwise LGTM

@kenns29 kenns29 mentioned this pull request Sep 9, 2019
@kenns29 kenns29 merged commit fb51f70 into master Sep 10, 2019
@kenns29 kenns29 deleted the hong/monorepo branch September 10, 2019 00:14
Firenze11 pushed a commit that referenced this pull request Sep 10, 2019
Using the monorepo structure for the repository (leveraging ocular).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants