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

Question: Using relative dependencies and git branches #202

Closed
43081j opened this issue Dec 9, 2020 · 3 comments · Fixed by #206
Closed

Question: Using relative dependencies and git branches #202

43081j opened this issue Dec 9, 2020 · 3 comments · Fixed by #206
Assignees

Comments

@43081j
Copy link

43081j commented Dec 9, 2020

@aomarks this is basically the setup i was telling you about:

  • package.json
  • dist
    • /main.js
    • /some-other-chunk.js
  • benchmarks
    • /package.json
    • /default.html

My root package.json is the main project which is pretty much structured like the MWC repo but not a monorepo (so its a big repo, single package of many components).

My benchmarks directory contains a tiny package.json to stop tach from going up the tree and trying to install my root package's dependencies rather than the root package itself:

{
  "name": "ui-benchmarks",
  "private": true,
  "version": "0.0.0",
  "devDependencies": {},
  "scripts": {},
  "dependencies": {
    "ui": "/code/ui"
  }
}

my tach config looks like this:

{
  "$schema": "https://raw.githubusercontent.com/Polymer/tachometer/master/config.schema.json",
  "root": "./benchmarks",
  "benchmarks": [
    {
      "name": "default-benchmark",
      "url": "benchmarks/default.html"
    },
    {
      "name": "default-benchmark",
      "url": "benchmarks/default.html",
      "packageVersions": {
        "label": "master",
        "dependencies": {
          "ui": {
            "kind": "git",
            "repo": "SOME_SSH_URL",
            "ref": "master",
            "setupCommands": [
              "npm i",
              "npm run build"
            ]
          }
        }
      }
    }
  ]
}

and my benchmarks/default.html simply does this for now:

      import 'ui/dist/main.js';
      import * as bench from '/bench.js';
      bench.start();
      for (let i = 0; i < 1000; i++) { }
      bench.stop();

All of this works, though it never resolves the horizon (maybe because they're the same source pretty much right now?).

Anyhow, while this does work, my issue is that the benchmark package.json had this remember:

  "dependencies": {
    "ui": "/code/ui"
  }

which means i cant just check it in because it wont work on other peoples machines... but i also can't make it relative like this:

  "dependencies": {
    "ui": "../"
  }

because tach moves a copy to a temp directory, which means ../ won't be the current ../ but will be some parent temp directory. so the import never gets resolved, which means it doesn't get transformed by node-resolve in your koa plugin.

am i just doing all of this a silly way? really i want to be able to run the same benchmark against my repo's master branch and the current state of it.

it'd be super nice if that was possible without having to pull from a remote (since i already have it locally, it'd be faster), but that would just be extra and isn't a necessity here.

@aomarks
Copy link
Member

aomarks commented Feb 1, 2021

Hi @43081j -- sorry for the extremely long delay getting to this 😞

I think the ../ pattern for a local git repo you used is totally valid. I've made this work properly in #206 by resolving those paths to be absolute first. I created a setup similar to what you described, and it's working for me now.

@43081j
Copy link
Author

43081j commented Feb 1, 2021

Don't worry about it, great that you've had chance to look into it. I'll have a read through the PR too and give it a go once it lands 👍

@aomarks aomarks self-assigned this Feb 2, 2021
@aomarks
Copy link
Member

aomarks commented Feb 4, 2021

Fix released in 0.5.6

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 a pull request may close this issue.

2 participants