[improvement] Improve monorepo (lask + turbo) (#566)

* add lask for packages

* Add turbo

* remove custom scripts

* update turbo scripts

* Improve scripts, update changelogs

* update action to use turbo

* Update .gitignore

* Update main.yml

* Update main.yml

* Update main.yml

* Add docs

* add clean
This commit is contained in:
Steve Ruiz 2022-02-08 11:05:56 +00:00 committed by GitHub
parent bb8cfab474
commit e1fb9a8250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1208 additions and 4798 deletions

View file

@ -5,12 +5,25 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# turbo cache
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v2
with:
path: node_modules/.cache/turbo
key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
turbo-${{ github.job }}-${{ github.ref_name }}-
# install modules # install modules
- name: Install modules - name: Install modules
run: yarn run: yarn
# build # build
- name: Build Packages - name: Build Packages
run: yarn build:packages run: yarn build:packages --cache-dir=".turbo"
# run unit tests # run unit tests
- name: Jest Annotations & Coverage - name: Jest Annotations & Coverage
run: yarn test:ci run: yarn test:ci

3
.gitignore vendored
View file

@ -16,4 +16,5 @@ apps/www/public/worker-*
apps/www/public/sw.js apps/www/public/sw.js
apps/www/public/sw.js.map apps/www/public/sw.js.map
.env .env
firebase.config.* firebase.config.*.turbo
.turbo

1
.turbo/config.json Normal file
View file

@ -0,0 +1 @@
{"teamId":"team_MjXkk3MAaGtBFaHcssVUiMgd","apiUrl":"https://api.vercel.com"}

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": ".", "rootDir": ".",
"baseUrl": ".", "baseUrl": ".",
"allowJs": false, "allowJs": false,

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": "src", "baseUrl": "src",
"emitDeclarationOnly": false, "emitDeclarationOnly": false,

View file

@ -40,12 +40,14 @@
"react-dom": "17.0.2" "react-dom": "17.0.2"
}, },
"devDependencies": { "devDependencies": {
"@tldraw/core": "*",
"@tldraw/tldraw": "*",
"@sentry/webpack-plugin": "^1.17.1", "@sentry/webpack-plugin": "^1.17.1",
"@types/react": "^17.0.19", "@types/react": "^17.0.19",
"@types/react-dom": "^17.0.9", "@types/react-dom": "^17.0.9",
"cors": "^2.8.5", "cors": "^2.8.5",
"eslint": "7.32.0", "eslint": "^8.8.0",
"eslint-config-next": "11.1.2", "eslint-config-next": "^12.0.10",
"puppeteer": "^13.1.1", "puppeteer": "^13.1.1",
"typescript": "^4.5.2" "typescript": "^4.5.2"
}, },

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"baseUrl": ".", "baseUrl": ".",
"rootDir": "src", "rootDir": "src",
"emitDeclarationOnly": false, "emitDeclarationOnly": false,

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"baseUrl": ".", "baseUrl": ".",
"rootDir": "src", "rootDir": "src",
"emitDeclarationOnly": false, "emitDeclarationOnly": false,

View file

@ -17,7 +17,6 @@
"devDependencies": { "devDependencies": {
"@liveblocks/client": "^0.14.0", "@liveblocks/client": "^0.14.0",
"@liveblocks/react": "^0.14.0", "@liveblocks/react": "^0.14.0",
"@tldraw/tldraw": "^1.6.1",
"@types/node": "^17.0.14", "@types/node": "^17.0.14",
"@types/react": "^17.0.38", "@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11", "@types/react-dom": "^17.0.11",

View file

@ -3,14 +3,16 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"baseUrl": ".", "baseUrl": ".",
"rootDir": "src", "rootDir": "src",
"emitDeclarationOnly": false, "emitDeclarationOnly": false,
"paths": { "paths": {
"~*": ["./src/*"], "~*": ["./src/*"],
"@tldraw/core": ["../../packages/core"], "@tldraw/core": ["../../packages/core"],
"@tldraw/tldraw": ["../../packages/tldraw"] "@tldraw/tldraw": ["../../packages/tldraw"],
"@tldraw/vec": ["../../packages/vec"],
"@tldraw/intersect": ["../../packages/intersect"]
} }
}, },
"references": [ "references": [

View file

@ -1,7 +1,7 @@
{ {
"name": "@tldraw/monorepo", "name": "@tldraw/monorepo",
"private": true, "private": true,
"version": "1.0.0", "version": "1.6.1",
"description": "A tiny little drawing app.", "description": "A tiny little drawing app.",
"author": "@steveruizok", "author": "@steveruizok",
"repository": { "repository": {
@ -10,41 +10,33 @@
}, },
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
"packages/curve", "packages/*",
"packages/vec", "apps/*",
"packages/intersect", "examples/*"
"packages/core",
"packages/tldraw",
"apps/www",
"apps/electron",
"apps/vscode/editor",
"apps/vscode/extension",
"examples/tldraw-example",
"examples/core-example",
"examples/core-example-advanced"
], ],
"scripts": { "scripts": {
"build": "lerna run build --stream", "build": "turbo run build",
"build:www": "yarn build:packages && cd apps/www && yarn build", "build:www": "turbo run build:www",
"build:core": "lerna run build:core", "build:core": "turbo run build:core",
"build:packages": "lerna run build:packages --stream", "build:packages": "turbo run build:packages --stream",
"build:apps": "lerna run build:apps", "build:apps": "turbo run build:apps",
"start": "yarn build:packages && lerna run start --stream --parallel", "start": "turbo run start --stream --parallel",
"start:all": "yarn build:packages && lerna run start:all --stream --parallel", "start:all": "turbo run start:all --stream --parallel",
"start:core": "lerna run start:core --stream --parallel", "start:core": "turbo run start:core --stream --parallel",
"start:www": "yarn build:packages && lerna run start --parallel & cd apps/www && yarn dev", "start:www": "turbo run start --parallel & cd apps/www && yarn dev",
"start:electron": "lerna run start:electron --stream --parallel", "start:electron": "turbo run start:electron --stream --parallel",
"start:vscode": "code apps/vscode/extension & lerna run start:vscode --parallel; ", "start:vscode": "code apps/vscode/extension & turbo run start:vscode --parallel; ",
"publish:patch": "yarn build:packages && yarn test && lerna publish", "publish:patch": "yarn build:packages && yarn test && turbo publish",
"fix:style": "yarn run prettier ./packages/core/src --write && yarn run prettier ./packages/tldraw/src --write", "fix:style": "yarn run prettier ./packages/core/src --write && yarn run prettier ./packages/tldraw/src --write",
"lerna": "lerna", "turbo": "turbo",
"test": "lerna run test --stream", "test": "turbo run test --stream",
"test:ci": "lerna run test:ci --stream", "test:ci": "turbo run test:ci --stream",
"test:watch": "lerna run test:watch --stream", "test:watch": "turbo run test:watch --stream",
"docs": "lerna run typedoc", "docs": "turbo run typedoc",
"docs:watch": "lerna run typedoc --watch", "docs:watch": "turbo run typedoc --watch",
"postinstall": "husky install", "postinstall": "husky install",
"pretty-quick": "pretty-quick" "pretty-quick": "pretty-quick",
"clean": "turbo run clean"
}, },
"devDependencies": { "devDependencies": {
"@swc-node/jest": "^1.4.3", "@swc-node/jest": "^1.4.3",
@ -62,20 +54,26 @@
"husky": "^7.0.4", "husky": "^7.0.4",
"init-package-json": "^2.0.5", "init-package-json": "^2.0.5",
"jest": "^27.4.7", "jest": "^27.4.7",
"lerna": "^4.0.0", "lask": "^0.0.29",
"lint-staged": "^12.3.3", "lint-staged": "^12.3.3",
"mobx": "^6.3.8",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "^3.1.3", "pretty-quick": "^3.1.3",
"react": ">=16.8",
"react-dom": "^16.8 || ^17.0",
"resize-observer-polyfill": "^1.5.1", "resize-observer-polyfill": "^1.5.1",
"source-map-loader": "^3.0.1", "source-map-loader": "^3.0.1",
"tslib": "^2.3.1", "tslib": "^2.3.1",
"turbo": "^1.1.2",
"typedoc": "^0.22.11", "typedoc": "^0.22.11",
"typescript": "^4.5.5" "typescript": "^4.5.5",
"webpack": "^5.68.0"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
"pre-commit": "pretty-quick --staged", "pre-commit": "pretty-quick --staged",
"pre-push": "fix:style && eslint && test" "pre-push": "fix:style && eslint && test"
} }
} },
"packageManager": "yarn@1.22.17"
} }

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 1.7.0
- Simplifies monorepo and dependencies.
## 1.5.0 ## 1.5.0
- Fix propagation on pointer move events. - Fix propagation on pointer move events.

View file

@ -18,23 +18,23 @@
"files": [ "files": [
"dist/**/*" "dist/**/*"
], ],
"main": "./dist/cjs/index.js", "main": "./dist/index.js",
"module": "./dist/esm/index.js", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts", "types": "./dist/index.d.ts",
"source": "./dist/index.ts",
"scripts": { "scripts": {
"start:core": "yarn start", "start": "yarn lask -d",
"build": "yarn lask",
"start:packages": "yarn start", "start:packages": "yarn start",
"start": "node scripts/dev & yarn types:dev", "start:core": "yarn start",
"build:core": "yarn build", "build:core": "yarn build",
"build:packages": "yarn build", "build:packages": "yarn build",
"build": "node scripts/build && yarn types:build",
"types:dev": "tsc -w --p tsconfig.build.json",
"types:build": "tsc -p tsconfig.build.json && tsconfig-replace-paths -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx", "lint": "eslint src/ --ext .ts,.tsx",
"clean": "rm -rf dist", "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"test": "jest", "test": "jest",
"test:ci": "jest --ci --runInBand --updateSnapshot", "test:ci": "jest --ci --runInBand --updateSnapshot",
"test:watch": "jest --watchAll" "test:watch": "jest --watchAll",
"docs": "typedoc"
}, },
"dependencies": { "dependencies": {
"@tldraw/intersect": "^1.6.1", "@tldraw/intersect": "^1.6.1",
@ -48,15 +48,20 @@
"react-dom": "^16.8 || ^17.0" "react-dom": "^16.8 || ^17.0"
}, },
"devDependencies": { "devDependencies": {
"@tldraw/intersect": "*",
"@tldraw/vec": "*",
"@swc-node/jest": "^1.4.3", "@swc-node/jest": "^1.4.3",
"@testing-library/jest-dom": "^5.16.2", "@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2", "@testing-library/react": "^12.1.2",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.14", "@types/node": "^17.0.14",
"@types/react": "^17.0.38", "@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"lask": "^0.0.29",
"mobx": "^6.3.8", "mobx": "^6.3.8",
"tsconfig-replace-paths": "^0.0.11" "react": ">=16.8",
"react-dom": "^16.8 || ^17.0"
}, },
"jest": { "jest": {
"setupFilesAfterEnv": [ "setupFilesAfterEnv": [

View file

@ -1,75 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/cjs',
minify: false,
bundle: true,
format: 'cjs',
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.build.json',
external: Object.keys(pkg.dependencies ?? {}).concat(Object.keys(pkg.peerDependencies ?? {})),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmResult = esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmSize = Object.values(esmResult.metafile.outputs).reduce(
(acc, { bytes }) => acc + bytes,
0
)
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
jslog(
`${pkg.name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
jslog(`× ${pkg.name}: Build failed due to an error.`)
jslog(e)
}
}
main()

View file

@ -1,33 +0,0 @@
/* eslint-disable */
const esbuild = require('esbuild')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
esbuild.build({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
incremental: true,
sourcemap: true,
watch: {
onRebuild(error) {
if (error) {
jslog(`× ${pkg.name}: An error in prevented the rebuild.`)
return
}
jslog(`${pkg.name}: Rebuilt.`)
},
},
})
}
main()

View file

@ -10,14 +10,11 @@
"dist", "dist",
"docs" "docs"
], ],
"include": ["src/**/*"],
"compilerOptions": { "compilerOptions": {
"composite": false, "composite": false,
"incremental": false, "incremental": false,
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"useDefineForClassFields": true,
"sourceMap": true "sourceMap": true
}, }
"references": [{ "path": "../vec" }, { "path": "../intersect" }]
} }

View file

@ -0,0 +1,21 @@
{
"extends": "./tsconfig.json",
"include": ["src"],
"exclude": [
"node_modules",
"**/*.test.tsx",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.spec.ts",
"src/test",
"dist",
"docs"
],
"compilerOptions": {
"composite": false,
"incremental": false,
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}

View file

@ -4,7 +4,7 @@
"compilerOptions": { "compilerOptions": {
"experimentalDecorators": true, "experimentalDecorators": true,
"useDefineForClassFields": true, "useDefineForClassFields": true,
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 1.7.0
- Simplifies monorepo and dependencies.
## 1.4.3 ## 1.4.3
- Update README - Update README

View file

@ -19,20 +19,22 @@
"files": [ "files": [
"dist/**/*" "dist/**/*"
], ],
"main": "./dist/cjs/index.js", "main": "./dist/index.js",
"module": "./dist/esm/index.js", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts", "types": "./dist/index.d.ts",
"source": "./dist/index.ts",
"scripts": { "scripts": {
"start": "yarn lask -d",
"build": "yarn lask",
"start:packages": "yarn start", "start:packages": "yarn start",
"start:core": "yarn start", "start:core": "yarn start",
"start": "node scripts/dev & yarn types:dev",
"build:core": "yarn build", "build:core": "yarn build",
"build:packages": "yarn build", "build:packages": "yarn build",
"build": "node scripts/build && yarn types:build",
"types:dev": "tsc -w --p tsconfig.build.json",
"types:build": "tsc -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx", "lint": "eslint src/ --ext .ts,.tsx",
"clean": "rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"gitHead": "3ab5db27b9e83736fdae934474e80e90c854922c" "gitHead": "3ab5db27b9e83736fdae934474e80e90c854922c",
"devDependencies": {
"lask": "^0.0.29"
}
} }

View file

@ -1,69 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/cjs',
minify: false,
bundle: true,
format: 'cjs',
target: 'es6',
tsconfig: './tsconfig.build.json',
metafile: false,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmResult = esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmSize = Object.values(esmResult.metafile.outputs).reduce(
(acc, { bytes }) => acc + bytes,
0
)
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
jslog(
`${pkg.name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
jslog(`× ${pkg.name}: Build failed due to an error.`)
jslog(e)
}
}
main()

View file

@ -1,31 +0,0 @@
/* eslint-disable */
const esbuild = require('esbuild')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
try {
await esbuild.build({
entryPoints: ['src/index.tsx'],
outfile: 'dist/index.js',
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': '"development"',
},
watch: {
onRebuild(err) {
err ? error('❌ Failed') : jslog('✅ Updated')
},
},
})
} catch (err) {
process.exit(1)
}
}
main()

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": "." "baseUrl": "."
}, },

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 1.7.0
- Simplifies monorepo and dependencies.
## 1.4.3 ## 1.4.3
- Update README - Update README

View file

@ -18,23 +18,26 @@
"files": [ "files": [
"dist/**/*" "dist/**/*"
], ],
"main": "./dist/cjs/index.js", "main": "./dist/index.js",
"module": "./dist/esm/index.js", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts", "types": "./dist/index.d.ts",
"source": "./src/index.ts",
"scripts": { "scripts": {
"start": "yarn lask -d",
"build": "yarn lask",
"start:packages": "yarn start", "start:packages": "yarn start",
"start:core": "yarn start", "start:core": "yarn start",
"start": "node scripts/dev & yarn types:dev",
"build:packages": "yarn build",
"build:core": "yarn build", "build:core": "yarn build",
"build": "node scripts/build && yarn types:build", "build:packages": "yarn build",
"types:dev": "tsc -w --p tsconfig.build.json",
"types:build": "tsc -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx", "lint": "eslint src/ --ext .ts,.tsx",
"clean": "rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"dependencies": { "dependencies": {
"@tldraw/vec": "^1.6.1" "@tldraw/vec": "^1.6.1"
}, },
"devDependencies": {
"@tldraw/vec": "*",
"lask": "^0.0.29"
},
"gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296" "gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296"
} }

View file

@ -1,71 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/cjs',
minify: false,
bundle: true,
format: 'cjs',
target: 'es6',
tsconfig: './tsconfig.build.json',
external: Object.keys(pkg.dependencies),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmResult = esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
external: Object.keys(pkg.dependencies),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmSize = Object.values(esmResult.metafile.outputs).reduce(
(acc, { bytes }) => acc + bytes,
0
)
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
jslog(
`${pkg.name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
jslog(`× ${pkg.name}: Build failed due to an error.`)
jslog(e)
}
}
main()

View file

@ -1,31 +0,0 @@
/* eslint-disable */
const esbuild = require('esbuild')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
try {
await esbuild.build({
entryPoints: ['src/index.tsx'],
outfile: 'dist/index.js',
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': '"development"',
},
watch: {
onRebuild(err) {
err ? error('❌ Failed') : jslog('✅ Updated')
},
},
})
} catch (err) {
process.exit(1)
}
}
main()

View file

@ -2,7 +2,7 @@
"extends": "../../tsconfig.base.json", "extends": "../../tsconfig.base.json",
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": "." "baseUrl": "."
}, },

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 1.7.0
- Simplifies monorepo and dependencies.
## 1.6.1 ## 1.6.1
- Fix label colors on arrows and triangles in dark mode - Fix label colors on arrows and triangles in dark mode

View file

@ -18,22 +18,23 @@
"files": [ "files": [
"dist/**/*" "dist/**/*"
], ],
"main": "./dist/cjs/index.js", "main": "./dist/index.js",
"module": "./dist/esm/index.js", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts", "types": "./dist/index.d.ts",
"source": "./src/index.ts",
"scripts": { "scripts": {
"start": "node scripts/dev & yarn types:dev", "start": "yarn lask -d",
"build": "yarn lask",
"start:packages": "yarn start", "start:packages": "yarn start",
"build": "node scripts/build && yarn types:build", "start:core": "yarn start",
"build:core": "yarn build",
"build:packages": "yarn build", "build:packages": "yarn build",
"types:dev": "tsc -w",
"types:build": "tsc -p tsconfig.build.json && tsconfig-replace-paths -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx", "lint": "eslint src/ --ext .ts,.tsx",
"clean": "rm -rf dist", "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
"ts-node": "ts-node",
"test": "jest", "test": "jest",
"test:ci": "jest --ci --runInBand --updateSnapshot", "test:ci": "jest --ci --runInBand --updateSnapshot",
"test:watch": "jest --watchAll" "test:watch": "jest --watchAll",
"docs": "typedoc"
}, },
"peerDependencies": { "peerDependencies": {
"react": ">=16.8", "react": ">=16.8",
@ -59,16 +60,21 @@
"zustand": "^3.6.9" "zustand": "^3.6.9"
}, },
"devDependencies": { "devDependencies": {
"@tldraw/core": "*",
"@tldraw/intersect": "*",
"@tldraw/vec": "*",
"@swc-node/jest": "^1.4.3", "@swc-node/jest": "^1.4.3",
"@testing-library/jest-dom": "^5.16.2", "@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2", "@testing-library/react": "^12.1.2",
"@types/node": "^17.0.14", "@types/node": "^17.0.14",
"@types/react": "^17.0.38",
"@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2", "@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0", "eslint": "^8.8.0",
"lerna": "^4.0.0", "lask": "^0.0.29",
"lint-staged": "^12.3.3", "mobx": "^6.3.8",
"tsconfig-replace-paths": "^0.0.11" "react": ">=16.8",
"react-dom": "^16.8 || ^17.0"
}, },
"jest": { "jest": {
"setupFilesAfterEnv": [ "setupFilesAfterEnv": [

View file

@ -1,75 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/cjs',
minify: false,
bundle: true,
format: 'cjs',
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.json',
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmResult = esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmSize = Object.values(esmResult.metafile.outputs).reduce(
(acc, { bytes }) => acc + bytes,
0
)
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
jslog(
`${pkg.name}: Built pkg. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
jslog(`× ${pkg.name}: Build failed due to an error.`)
jslog(e)
}
}
main()

View file

@ -1,33 +0,0 @@
/* eslint-disable */
const esbuild = require('esbuild')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
esbuild.build({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment',
tsconfig: './tsconfig.build.json',
external: Object.keys(pkg.dependencies).concat(Object.keys(pkg.peerDependencies)),
sourcemap: true,
incremental: true,
watch: {
onRebuild(error) {
if (error) {
jslog(`× ${pkg.name}: An error in prevented the rebuild.`)
return
}
jslog(`${pkg.name}: Rebuilt.`)
},
},
})
}
main()

View file

@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */ /* eslint-disable @typescript-eslint/no-non-null-assertion */
import { TLBounds, TLTransformInfo, Utils, TLPageState, TLHandle } from '@tldraw/core' import { TLBounds, TLTransformInfo, Utils, TLPageState } from '@tldraw/core'
import { import {
TDSnapshot, TDSnapshot,
ShapeStyles,
ShapesWithProp, ShapesWithProp,
TDShape, TDShape,
TDBinding, TDBinding,
@ -16,7 +15,6 @@ import {
import { Vec } from '@tldraw/vec' import { Vec } from '@tldraw/vec'
import type { TDShapeUtil } from './shapes/TDShapeUtil' import type { TDShapeUtil } from './shapes/TDShapeUtil'
import { getShapeUtil } from './shapes' import { getShapeUtil } from './shapes'
import type { TldrawApp } from './TldrawApp'
import { deepCopy } from './StateManager/copy' import { deepCopy } from './StateManager/copy'
import { intersectRayBounds, intersectRayEllipse, intersectRayLineSegment } from '@tldraw/intersect' import { intersectRayBounds, intersectRayEllipse, intersectRayLineSegment } from '@tldraw/intersect'
import { getTrianglePoints } from './shapes/TriangleUtil/triangleHelpers' import { getTrianglePoints } from './shapes/TriangleUtil/triangleHelpers'

View file

@ -79,7 +79,6 @@ import { LineTool } from './tools/LineTool'
import { ArrowTool } from './tools/ArrowTool' import { ArrowTool } from './tools/ArrowTool'
import { StickyTool } from './tools/StickyTool' import { StickyTool } from './tools/StickyTool'
import { StateManager } from './StateManager' import { StateManager } from './StateManager'
import { deepCopy } from './StateManager/copy'
const uuid = Utils.uniqueId() const uuid = Utils.uniqueId()

View file

@ -17,6 +17,5 @@
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"sourceMap": true "sourceMap": true
}, }
"references": [{ "path": "../vec" }, { "path": "../intersect" }, { "path": "../core" }]
} }

View file

@ -0,0 +1,21 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"**/*.test.tsx",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.spec.ts",
"src/test",
"dist",
"docs"
],
"compilerOptions": {
"skipLibCheck": true,
"composite": false,
"incremental": false,
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}

View file

@ -3,7 +3,7 @@
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"include": ["src"], "include": ["src"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## 1.7.0
- Simplifies monorepo and dependencies.
## 1.6.1 ## 1.6.1
- Change `vec.toFixed` to always round to two decimal places. This drops the second parameter, which was previously available for custom precisions, but which was defaulted to 2 (its current behavior). - Change `vec.toFixed` to always round to two decimal places. This drops the second parameter, which was previously available for custom precisions, but which was defaulted to 2 (its current behavior).

View file

@ -17,20 +17,22 @@
"files": [ "files": [
"dist/**/*" "dist/**/*"
], ],
"main": "./dist/cjs/index.js", "main": "./dist/index.js",
"module": "./dist/esm/index.js", "module": "./dist/index.mjs",
"types": "./dist/types/index.d.ts", "types": "./dist/index.d.ts",
"source": "./src/index.ts",
"scripts": { "scripts": {
"start": "yarn lask -d",
"build": "yarn lask",
"start:packages": "yarn start", "start:packages": "yarn start",
"start:core": "yarn start", "start:core": "yarn start",
"start": "node scripts/dev & yarn types:dev",
"build:core": "yarn build", "build:core": "yarn build",
"build:packages": "yarn build", "build:packages": "yarn build",
"build": "node scripts/build && yarn types:build",
"types:dev": "tsc -w --p tsconfig.build.json",
"types:build": "tsc -p tsconfig.build.json",
"lint": "eslint src/ --ext .ts,.tsx", "lint": "eslint src/ --ext .ts,.tsx",
"clean": "rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296" "gitHead": "4b1137849ad07da36fc8f0f19cb64e7535a79296",
"devDependencies": {
"lask": "^0.0.29"
}
} }

View file

@ -1,69 +0,0 @@
/* eslint-disable */
const fs = require('fs')
const esbuild = require('esbuild')
const { gzip } = require('zlib')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
if (fs.existsSync('./dist')) {
fs.rmSync('./dist', { recursive: true }, (e) => {
if (e) {
throw e
}
})
}
try {
esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/cjs',
minify: false,
bundle: true,
format: 'cjs',
target: 'es6',
tsconfig: './tsconfig.build.json',
metafile: false,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmResult = esbuild.buildSync({
entryPoints: ['./src/index.ts'],
outdir: 'dist/esm',
minify: false,
bundle: true,
format: 'esm',
target: 'es6',
tsconfig: './tsconfig.build.json',
metafile: true,
sourcemap: true,
define: {
'process.env.NODE_ENV': '"production"',
},
})
const esmSize = Object.values(esmResult.metafile.outputs).reduce(
(acc, { bytes }) => acc + bytes,
0
)
fs.readFile('./dist/esm/index.js', (_err, data) => {
gzip(data, (_err, result) => {
jslog(
`${pkg.name}: Built package. ${(esmSize / 1000).toFixed(2)}kb (${(
result.length / 1000
).toFixed(2)}kb minified)`
)
})
})
} catch (e) {
jslog(`× ${pkg.name}: Build failed due to an error.`)
jslog(e)
}
}
main()

View file

@ -1,31 +0,0 @@
/* eslint-disable */
const esbuild = require('esbuild')
const pkg = require('../package.json')
const { log: jslog } = console
async function main() {
try {
await esbuild.build({
entryPoints: ['src/index.tsx'],
outfile: 'dist/index.js',
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': '"development"',
},
watch: {
onRebuild(err) {
err ? error('❌ Failed') : jslog('✅ Updated')
},
},
})
} catch (err) {
process.exit(1)
}
}
main()

View file

@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"exclude": [
"node_modules",
"**/*.test.tsx",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.spec.ts",
"src/test",
"dist",
"docs"
],
"compilerOptions": {
"composite": false,
"incremental": false,
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
}

View file

@ -3,7 +3,7 @@
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "dist", "docs"], "exclude": ["node_modules", "dist", "docs"],
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/types", "outDir": "./dist",
"rootDir": "src", "rootDir": "src",
"baseUrl": "." "baseUrl": "."
}, },

View file

@ -10,7 +10,6 @@
"experimentalDecorators": true, "experimentalDecorators": true,
"forceConsistentCasingInFileNames": false, "forceConsistentCasingInFileNames": false,
"importHelpers": true, "importHelpers": true,
"importsNotUsedAsValues": "error",
"resolveJsonModule": true, "resolveJsonModule": true,
"incremental": true, "incremental": true,
"jsx": "preserve", "jsx": "preserve",
@ -27,6 +26,7 @@
"strictFunctionTypes": true, "strictFunctionTypes": true,
"strictNullChecks": true, "strictNullChecks": true,
"stripInternal": true, "stripInternal": true,
"useDefineForClassFields": true,
"target": "es6", "target": "es6",
"typeRoots": ["node_modules/@types", "node_modules/jest"], "typeRoots": ["node_modules/@types", "node_modules/jest"],
"types": ["node", "jest", "@testing-library/jest-dom", "@testing-library/react"] "types": ["node", "jest", "@testing-library/jest-dom", "@testing-library/react"]

111
turbo.json Normal file
View file

@ -0,0 +1,111 @@
{
"npmClient": "yarn",
"baseBranch": "origin/main",
"pipeline": {
"start": {
"cache": false
},
"start:packages": {
"cache": false
},
"start:core": {
"cache": false
},
"start:apps": {
"cache": false
},
"start:www": {
"cache": false
},
"start:electron": {
"cache": false
},
"start:vscode": {
"cache": false
},
"typedoc": {
"dependsOn": [
"^build"
],
"outputs": [
"docs"
]
},
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
},
"build:packages": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
]
},
"build:core": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
]
},
"build:apps": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
},
"build:www": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
".next/**"
]
},
"test": {
"dependsOn": [
"build"
],
"outputs": []
},
"test:ci": {
"dependsOn": [
"build"
],
"outputs": [
"coverage/**"
]
},
"lint": {
"dependsOn": [
"build"
],
"outputs": []
},
"clean": {
"cache": false
},
"deploy": {
"dependsOn": [
"build",
"test"
],
"outputs": [
"dist/**",
".next/**"
]
}
}
}

5019
yarn.lock

File diff suppressed because it is too large Load diff