diff --git a/examples/lerna/.gitignore b/examples/lerna/.gitignore new file mode 100644 index 0000000000000..f2b65baf2d5d5 --- /dev/null +++ b/examples/lerna/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +node_modules +.pnp +.pnp.js + +# testing +coverage + +# next.js +.next/ +out/ +build + +# package builds +cjs/ +esm/ + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# turbo +.turbo \ No newline at end of file diff --git a/examples/lerna/README.md b/examples/lerna/README.md new file mode 100644 index 0000000000000..cea9d5a65435f --- /dev/null +++ b/examples/lerna/README.md @@ -0,0 +1,76 @@ +## What's inside? + +This turborepo uses [Yarn](https://classic.yarnpkg.com/lang/en/) as a package manager. It includes the following packages: + +### Apps and Packages + +- `hello world`: a npm package + +Each package/app is 100% [Typescript](https://www.typescriptlang.org/). + +### Utilities + +This turborepo has some additional tools already setup for you: + +- [Typescript](https://www.typescriptlang.org/) for static type checking +- [SWC](https://swc.rs/) for building your code faster +- [Jest](https://jestjs.io) test runner for all things JavaScript + +### Build + +To build all packages, run the following command: + +``` +cd my-turborepo +yarn run build +``` + +### Develop + +To develop all packages, run the following command: + +``` +cd my-turborepo +yarn run dev +``` + +### Publish + +To publish modified packages, run the following command: + +``` +cd my-turborepo +yarn run release +``` + +_This command builds packages before publishing._ + +### Remote Caching + +Turborepo can use a technique known as [Remote Caching (Beta)](https://turborepo.org/docs/features/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. + +By default, Turborepo will cache locally. To enable Remote Caching (Beta) you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands: + +``` +cd my-turborepo +npx turbo login +``` + +This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). + +Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo: + +``` +npx turbo link +``` + +## Useful Links + +Learn more about the power of Turborepo: + +- [Pipelines](https://turborepo.org/docs/features/pipelines) +- [Caching](https://turborepo.org/docs/features/caching) +- [Remote Caching (Beta)](https://turborepo.org/docs/features/remote-caching) +- [Scoped Tasks](https://turborepo.org/docs/features/scopes) +- [Configuration Options](https://turborepo.org/docs/reference/configuration) +- [CLI Usage](https://turborepo.org/docs/reference/command-line-reference) \ No newline at end of file diff --git a/examples/lerna/lerna.json b/examples/lerna/lerna.json new file mode 100644 index 0000000000000..d6707ca0cd64d --- /dev/null +++ b/examples/lerna/lerna.json @@ -0,0 +1,6 @@ +{ + "packages": [ + "packages/*" + ], + "version": "0.0.0" +} diff --git a/examples/lerna/package.json b/examples/lerna/package.json new file mode 100644 index 0000000000000..238cfc0b5059e --- /dev/null +++ b/examples/lerna/package.json @@ -0,0 +1,58 @@ +{ + "name": "root", + "private": true, + "devDependencies": { + "@swc/cli": "^0.1.53", + "@swc/core": "^1.2.119", + "@swc/jest": "^0.2.12", + "jest": "^27.4.4", + "lerna": "^4.0.0", + "nodemon": "^2.0.15", + "swc": "^1.0.11", + "turbo": "latest", + "typescript": "^4.5.3" + }, + "scripts": { + "build": "turbo run build", + "dev": "turbo run dev", + "test": "turbo run test", + "prerelease": "yarn build && lerna version --no-push", + "release": "lerna publish from-git --yes", + "postrelease": "git push --follow-tags origin" + }, + "workspaces": [ + "packages/*" + ], + "turbo": { + "pipeline": { + "build:esm": { + "dependsOn": [ + "^build:esm" + ], + "outputs": [ + "esm/**" + ] + }, + "build:cjs": { + "dependsOn": [ + "^build:cjs" + ], + "outputs": [ + "cjs/**" + ] + }, + "build": { + "dependsOn": [ + "build:esm", + "build:cjs" + ] + }, + "test": { + "outputs": [] + }, + "dev": { + "cache": false + } + } + } +} diff --git a/examples/lerna/packages/hello-world/README.md b/examples/lerna/packages/hello-world/README.md new file mode 100644 index 0000000000000..d7430dfa03ded --- /dev/null +++ b/examples/lerna/packages/hello-world/README.md @@ -0,0 +1,11 @@ +# `hello-world` + +> TODO: description + +## Usage + +``` +const helloWorld = require('hello-world'); + +// TODO: DEMONSTRATE API +``` diff --git a/examples/lerna/packages/hello-world/__tests__/hello-world.test.js b/examples/lerna/packages/hello-world/__tests__/hello-world.test.js new file mode 100644 index 0000000000000..c58ade20f1ae2 --- /dev/null +++ b/examples/lerna/packages/hello-world/__tests__/hello-world.test.js @@ -0,0 +1,7 @@ +import { helloWorld } from '../src/hello-world' + +describe('hello-world', () => { + it('needs tests', () => { + expect(helloWorld()).toBe("hello world!") + }); +}); diff --git a/examples/lerna/packages/hello-world/jest.config.js b/examples/lerna/packages/hello-world/jest.config.js new file mode 100644 index 0000000000000..55ac9a012d99d --- /dev/null +++ b/examples/lerna/packages/hello-world/jest.config.js @@ -0,0 +1,6 @@ +/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ +module.exports = { + transform: { + "^.+\\.(t|j)sx?$": ["@swc/jest"], + } +}; \ No newline at end of file diff --git a/examples/lerna/packages/hello-world/nodemon.json b/examples/lerna/packages/hello-world/nodemon.json new file mode 100644 index 0000000000000..8b69aed52bb6e --- /dev/null +++ b/examples/lerna/packages/hello-world/nodemon.json @@ -0,0 +1,6 @@ +{ + "watch": ["src"], + "ext": "ts,json", + "ignore": ["**/*.test.ts"], + "exec": "yarn build:cjs && yarn build:esm && node ." +} \ No newline at end of file diff --git a/examples/lerna/packages/hello-world/package.json b/examples/lerna/packages/hello-world/package.json new file mode 100644 index 0000000000000..e7924639c26e7 --- /dev/null +++ b/examples/lerna/packages/hello-world/package.json @@ -0,0 +1,26 @@ +{ + "name": "hello-world", + "version": "0.0.0", + "description": "", + "author": "", + "homepage": "", + "license": "", + "main": "cjs/hello-world.js", + "module": "esm/hello-world.js", + "types": "src/hello-world.ts", + "directories": { + "lib": "src", + "test": "__tests__" + }, + "files": [ + "src", + "esm", + "cjs" + ], + "scripts": { + "build:esm": "swc ./src -d esm -C module.type=es6", + "build:cjs": "swc ./src -d cjs -C module.type=commonjs", + "dev": "nodemon --config nodemon.json", + "test": "jest" + } +} diff --git a/examples/lerna/packages/hello-world/src/hello-world.ts b/examples/lerna/packages/hello-world/src/hello-world.ts new file mode 100644 index 0000000000000..1f072c2c173aa --- /dev/null +++ b/examples/lerna/packages/hello-world/src/hello-world.ts @@ -0,0 +1,3 @@ +export function helloWorld() { + return "hello world!" +} \ No newline at end of file diff --git a/examples/lerna/tsconfig.json b/examples/lerna/tsconfig.json new file mode 100644 index 0000000000000..dff93100efaee --- /dev/null +++ b/examples/lerna/tsconfig.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "Default", + "compilerOptions": { + "composite": false, + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "inlineSources": false, + "isolatedModules": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "preserveWatchOutput": true, + "skipLibCheck": true, + "strict": true, + "noImplicitAny": true + }, + "exclude": ["node_modules"] +} \ No newline at end of file