Skip to content

Commit

Permalink
chore(turbo): flip turbo caching glob from allow-list to deny-list (m…
Browse files Browse the repository at this point in the history
…edusajs#2772)

### What

Flip Turborepo cache glob pattern from an allow-list to deny-list pattern.

### Why

Packages within medusa's monorepo will output their build to a `dist` directory. 

This convention does not apply to plugins since the core plugin loader expects the content of plugin packages `src` directory to be outputted at the root of the package. 

i.e. `packages/foobar-plugin/src/utils/index.ts` -> `packages/foobar-plugin/utils/index.js`

Manually maintaining an allow-list of known plugin output directories is not scalable. When a directory exists in a plugin package but is not know to the allow-list, the directory will not be re-built on subsequent builds. Troubleshooting the issue requires intimate knowledge of Turborepo caching strategies.

### How

By using a deny-list glob pattern, plugin packages can now declare any not-known directory within their `src` folder without facing any potential omission issues during the build process.

We declare `src` and its content as the only directory for turbo cache to ignore.

### Additional scope

* Use `turbo.json` file content in cache hashing algorithm in order to break CI cache when changes are made to the Turborepo config.
* Upgraded turbo minor verion.
* Added missing dependency to medusa package.

### Test
* Delete previously built output in packages. Run `yarn build --force` (replace any existing cache)
  * Expect all src content to be outputted
* Run `yarn build` right after
  * Expect a fast build time since cache will be fresh
* Add a new directory with an index.ts file in a plugin package src folder. Run `yarn build` 
  * Expect a fast build time, except for the modified plugin package.
  * Expect the newly added directory to be outputted.
* Delete the newly outputted directory. Run `yarn build`
  * Expect the outputted directory to reappear. 

### References
* https://github.com/medusajs/medusa/blob/5093b82f3a28323e99b6b133ae87c76fac01a298/packages/medusa/src/loaders/plugins.ts
* https://turbo.build/repo/docs/reference/configuration#outputs
* https://turbo.build/repo/docs/reference/configuration#globaldependencies

Resolves CORE-891
  • Loading branch information
patrick-medusajs authored Dec 13, 2022
1 parent 29135c0 commit 17c3f34
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 130 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-pens-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/medusa": patch
---

fix: add missing medusa-telemetry dependency to package.json
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"resolve-cwd": "^3.0.0",
"ts-jest": "^26.5.6",
"ts-node": "^10.9.1",
"turbo": "^1.3.1",
"turbo": "^1.6.3",
"typedoc": "0.23.10",
"typedoc-frontmatter-plugin": "link:docs-util/typedoc-plugins/typedoc-frontmatter-plugin",
"typedoc-monorepo-link-types": "^0.0.2",
Expand All @@ -58,14 +58,14 @@
"scripts": {
"hooks:install": "husky install",
"hooks:uninstall": "husky uninstall",
"build": "turbo run build",
"build": "turbo run build --no-daemon",
"lint": "eslint --ignore-path .eslintignore --ext .js,.ts,.tsx .",
"prettier": "prettier",
"jest": "jest",
"test": "turbo run test --filter=!integration-tests-api --filter=!integration-tests-plugins",
"test:integration": "turbo run test --filter=integration-tests-api --filter=integration-tests-plugins",
"test:integration:api": "turbo run test --filter=integration-tests-api",
"test:integration:plugins": "turbo run test --filter=integration-tests-plugins",
"test": "turbo run test --no-daemon --filter=!integration-tests-api --filter=!integration-tests-plugins",
"test:integration": "turbo run test --no-daemon --filter=integration-tests-api --filter=integration-tests-plugins",
"test:integration:api": "turbo run test --no-daemon --filter=integration-tests-api",
"test:integration:plugins": "turbo run test --no-daemon --filter=integration-tests-plugins",
"openapi:generate": "node ./scripts/build-openapi.js",
"generate:services": "typedoc --options typedoc.services.js",
"generate:js-client": "typedoc --options typedoc.js-client.js",
Expand Down
1 change: 1 addition & 0 deletions packages/medusa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"iso8601-duration": "^1.3.0",
"jsonwebtoken": "^8.5.1",
"medusa-core-utils": "^1.1.36",
"medusa-telemetry": "^0.0.15",
"medusa-test-utils": "^1.1.37",
"morgan": "^1.9.1",
"multer": "^1.4.2",
Expand Down
21 changes: 8 additions & 13 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/master",
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
"api/**",
"helpers/**",
"loaders/**",
"migrations/**",
"models/**",
"repositories/**",
"services/**",
"subscribers/**",
"utils/**"
"!node_modules/**",
"!src/**",
"/*/**"
]
},
"test": {
Expand All @@ -25,5 +17,8 @@
],
"outputs": []
}
}
},
"globalDependencies": [
"turbo.json"
]
}
143 changes: 32 additions & 111 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4431,6 +4431,7 @@ __metadata:
jsonwebtoken: ^8.5.1
medusa-core-utils: ^1.1.36
medusa-interfaces: ^1.3.3
medusa-telemetry: ^0.0.15
medusa-test-utils: ^1.1.37
morgan: ^1.9.1
multer: ^1.4.2
Expand Down Expand Up @@ -24450,7 +24451,7 @@ __metadata:
languageName: unknown
linkType: soft

"medusa-telemetry@0.0.15, medusa-telemetry@workspace:packages/medusa-telemetry":
"medusa-telemetry@0.0.15, medusa-telemetry@^0.0.15, medusa-telemetry@workspace:packages/medusa-telemetry":
version: 0.0.0-use.local
resolution: "medusa-telemetry@workspace:packages/medusa-telemetry"
dependencies:
Expand Down Expand Up @@ -30158,7 +30159,7 @@ __metadata:
swagger-inline: ^3.2.2
ts-jest: ^26.5.6
ts-node: ^10.9.1
turbo: ^1.3.1
turbo: ^1.6.3
typedoc: 0.23.10
typedoc-frontmatter-plugin: "link:docs-util/typedoc-plugins/typedoc-frontmatter-plugin"
typedoc-monorepo-link-types: ^0.0.2
Expand Down Expand Up @@ -33201,154 +33202,74 @@ __metadata:
languageName: node
linkType: hard

"turbo-android-arm64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-android-arm64@npm:1.3.1"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard

"turbo-darwin-64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-darwin-64@npm:1.3.1"
"turbo-darwin-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-darwin-64@npm:1.6.3"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"turbo-darwin-arm64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-darwin-arm64@npm:1.3.1"
"turbo-darwin-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-darwin-arm64@npm:1.6.3"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"turbo-freebsd-64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-freebsd-64@npm:1.3.1"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard

"turbo-freebsd-arm64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-freebsd-arm64@npm:1.3.1"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard

"turbo-linux-32@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-32@npm:1.3.1"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard

"turbo-linux-64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-64@npm:1.3.1"
"turbo-linux-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-linux-64@npm:1.6.3"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard

"turbo-linux-arm64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-arm64@npm:1.3.1"
"turbo-linux-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-linux-arm64@npm:1.6.3"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard

"turbo-linux-arm@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-arm@npm:1.3.1"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard

"turbo-linux-mips64le@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-mips64le@npm:1.3.1"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard

"turbo-linux-ppc64le@npm:1.3.1":
version: 1.3.1
resolution: "turbo-linux-ppc64le@npm:1.3.1"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard

"turbo-windows-32@npm:1.3.1":
version: 1.3.1
resolution: "turbo-windows-32@npm:1.3.1"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"turbo-windows-64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-windows-64@npm:1.3.1"
"turbo-windows-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-windows-64@npm:1.6.3"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"turbo-windows-arm64@npm:1.3.1":
version: 1.3.1
resolution: "turbo-windows-arm64@npm:1.3.1"
"turbo-windows-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-windows-arm64@npm:1.6.3"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"turbo@npm:^1.3.1":
version: 1.3.1
resolution: "turbo@npm:1.3.1"
dependencies:
turbo-android-arm64: 1.3.1
turbo-darwin-64: 1.3.1
turbo-darwin-arm64: 1.3.1
turbo-freebsd-64: 1.3.1
turbo-freebsd-arm64: 1.3.1
turbo-linux-32: 1.3.1
turbo-linux-64: 1.3.1
turbo-linux-arm: 1.3.1
turbo-linux-arm64: 1.3.1
turbo-linux-mips64le: 1.3.1
turbo-linux-ppc64le: 1.3.1
turbo-windows-32: 1.3.1
turbo-windows-64: 1.3.1
turbo-windows-arm64: 1.3.1
"turbo@npm:^1.6.3":
version: 1.6.3
resolution: "turbo@npm:1.6.3"
dependencies:
turbo-darwin-64: 1.6.3
turbo-darwin-arm64: 1.6.3
turbo-linux-64: 1.6.3
turbo-linux-arm64: 1.6.3
turbo-windows-64: 1.6.3
turbo-windows-arm64: 1.6.3
dependenciesMeta:
turbo-android-arm64:
optional: true
turbo-darwin-64:
optional: true
turbo-darwin-arm64:
optional: true
turbo-freebsd-64:
optional: true
turbo-freebsd-arm64:
optional: true
turbo-linux-32:
optional: true
turbo-linux-64:
optional: true
turbo-linux-arm:
optional: true
turbo-linux-arm64:
optional: true
turbo-linux-mips64le:
optional: true
turbo-linux-ppc64le:
optional: true
turbo-windows-32:
optional: true
turbo-windows-64:
optional: true
turbo-windows-arm64:
optional: true
bin:
turbo: bin/turbo
checksum: 62093ccfb8cce6d8e6c7161f50660e8d5d1fbdbcf2e2f8514a001fdef7cdc9fa0f21013c4507b7020f2d66b4ab313a436b9d4a5aa10358ebe11b98acd7a939ea
checksum: 9335cd7f676b4e439ac1f66eba496fe31f3f9a7d09346824f94c26d7b8602ff2231056441a448b739ec2d68c3e4ae43f07c9cd79a73d94275a89fc1f9a19475a
languageName: node
linkType: hard

Expand Down

0 comments on commit 17c3f34

Please sign in to comment.