这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions examples/lerna/.gitignore
Original file line number Diff line number Diff line change
@@ -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
76 changes: 76 additions & 0 deletions examples/lerna/README.md
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions examples/lerna/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "0.0.0"
}
58 changes: 58 additions & 0 deletions examples/lerna/package.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
11 changes: 11 additions & 0 deletions examples/lerna/packages/hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `hello-world`

> TODO: description

## Usage

```
const helloWorld = require('hello-world');

// TODO: DEMONSTRATE API
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { helloWorld } from '../src/hello-world'

describe('hello-world', () => {
it('needs tests', () => {
expect(helloWorld()).toBe("hello world!")
});
});
6 changes: 6 additions & 0 deletions examples/lerna/packages/hello-world/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
transform: {
"^.+\\.(t|j)sx?$": ["@swc/jest"],
}
};
6 changes: 6 additions & 0 deletions examples/lerna/packages/hello-world/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": "ts,json",
"ignore": ["**/*.test.ts"],
"exec": "yarn build:cjs && yarn build:esm && node ."
}
26 changes: 26 additions & 0 deletions examples/lerna/packages/hello-world/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 3 additions & 0 deletions examples/lerna/packages/hello-world/src/hello-world.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function helloWorld() {
return "hello world!"
}
20 changes: 20 additions & 0 deletions examples/lerna/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}