Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
refactor: use yarn workspaces for easier install
Browse files Browse the repository at this point in the history
the goal: when someone clones this repo and runs `yarn` to install
dependencies, all of the dependencies for the templates get installed as
well. Additionally, this is done in such a way that linting works for
these projects.

This is a little bit tricky! Each template has a file at
`assembly/tsconfig.json` which has an `extends` directive. This
`extends` points to `../node_modules/assemblyscript/[...]`. So the
installation of packages for each of these templates must be done in
such a way that this relative lookup does not break. That's what the
`nohoist` option does.

Note that typescript supports some version of module resolution, rather
than relative path, for the `extends` option. I tried to use this
briefly and ran into problems, whereas `nohoist` worked very quickly. It
seems like other people have had problems with `extends` pointing to
packages as well:
microsoft/TypeScript#18865 (comment)

This also adds the `yarn.lock`, since we have no config preventing it,
and this is considered best practice
(https://classic.yarnpkg.com/blog/2016/11/24/lockfiles-for-all/)
  • Loading branch information
chadoh committed Feb 7, 2020
1 parent cc6d4cb commit 9913c04
Show file tree
Hide file tree
Showing 3 changed files with 1,782 additions and 38 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,10 @@
"webpack-cli": "^3.3.4",
"webpack-dev-server": "^3.7.1",
"webpackbar": "^4.0.0"
},
"private": true,
"workspaces": {
"packages": [ "templates/*" ],
"nohoist": [ "**/assemblyscript" ]
}
}
2 changes: 1 addition & 1 deletion templates/02-counter/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@wasm/token_contract_ts",
"name": "@wasm/counter_ts",
"description": "",
"version": "0.0.1",
"scripts": {
Expand Down
Loading

0 comments on commit 9913c04

Please sign in to comment.