Skip to content

Does not always work with yarn workspaces / monorepos #70

Closed

Description

@buschtoens

I'm running into problems with ember-cli-version-checker with the following setup: I have a monorepo with an engine, that uses @ember-decorators/babel-transforms to enable decorators. The engine uses ember-cli-babel@7, which babel-transforms checks for using ember-cli-version-checker. This works for the engine itself, however it does not work for the engine's dummy app.

Here's why: the dummy app is an instance of EmberAddon and has no root property. Therefore basedir is undefined.

jsonPath = resolve.sync(this.name + '/package.json', {
basedir: addon.root,
});

This means that require.sync determines the basedir using the physical location of the caller file, npm-dependency-version-checker.js in that case:

var basedir = opts.basedir || path.dirname(caller());

And this is where it breaks. ember-cli-version-checker has been hoisted to the workspace root, consequently resolve will start the lookup from there. However, the version of ember-cli-babel@7 that is used by the engine has not been hoisted. Instead, ember-cli-babel@6 has been hoisted.

Related to #47.

Activity

  1. buschtoens commented on Nov 21, 2018

    @buschtoens
    ContributorAuthor

    I am no ember-cli wizard, but I would guess, that we could just do this:

    jsonPath = resolve.sync(this.name + '/package.json', { 
      basedir: addon.root || addon.project && addon.project.root
    }); 

    The slightly safer way would be to use get-project, however that would potentially throw an error. But maybe this is what we really want?

    const getProject = require('./get-project');
    
    // ...
    
    jsonPath = resolve.sync(this.name + '/package.json', { 
      basedir: addon.root || getProject(addon).root
    }); 
  2. ef4 commented on Nov 26, 2018

    @ef4

    I just hit this bug. It gets reproduced if you try to use ember-decorators when ember-cli-babel needs to be resolved relative to a non-default basedir. This is the VersionChecker that fails:

    https://github.com/ember-decorators/ember-decorators/blob/d96c7c86a36f242a2c8b52d3add333baeeeab947/packages/babel-transforms/index.js#L20

  3. alexlafroscia commented on Jan 23, 2019

    @alexlafroscia

    In case anyone comes across this in the future: @ember-decorators/babel-transforms just released 5.1.2 that bumps the ember-cli-version-checker version and (should) fix this issue if you're using that package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions