Skip to content

Commit

Permalink
Replace tsc with SWC for package compilation and file watching (verce…
Browse files Browse the repository at this point in the history
…l#675)

* Updated turbo version

* Added taskr to packages/local

* Move json files

* Include missing extension

* Fixed prettierignore

* Updated swc plugin

* Moved swc plugin to its own package

* Added note

* Removed unused package

* Added watch for file changes

* Added taskr deps to every package

* Added taskfile to every package

* Updated scripts in every package

* Added 2 utiity scripts

* Fix turbo dev script

* Update swc plugin to include jsx import

* Updated build script in main package.json
  • Loading branch information
lfades authored Feb 9, 2022
1 parent c11b1ca commit 541491f
Show file tree
Hide file tree
Showing 29 changed files with 1,637 additions and 152 deletions.
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Every package defines its prettier config
node_modules
packages
site
dist
.next
public
48 changes: 6 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,20 @@
"packages/*"
],
"scripts": {
"build": "turbo run build --scope=next-commerce --include-dependencies --no-deps",
"dev": "turbo run dev",
"start": "turbo run start",
"prettier-fix": "prettier --write ."
},
"turbo": {
"baseBranch": "origin/main",
"pipeline": {
"build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
]
},
"next-commerce#build": {
"dependsOn": [
"^build",
"$COMMERCE_PROVIDER"
],
"outputs": [
".next/**"
]
},
"test": {
"dependsOn": [
"^build"
],
"outputs": []
},
"lint": {
"outputs": []
},
"prettier-fix": {
"outputs": []
},
"dev": {
"cache": false
},
"start": {
"cache": false
}
}
},
"devDependencies": {
"husky": "^7.0.4",
"prettier": "^2.5.1",
"turbo": "^1.0.28"
"turbo": "^1.1.2"
},
"husky": {
"hooks": {
"pre-commit": "turbo run lint"
}
}
},
"packageManager": "[email protected]"
}
12 changes: 9 additions & 3 deletions packages/bigcommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"prettier-fix": "prettier --write .",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"generate:definitions": "node scripts/generate-definitions.js"
},
"sideEffects": false,
Expand Down Expand Up @@ -59,6 +60,9 @@
"react-dom": "^17"
},
"devDependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/cookie": "^0.4.1",
"@types/jsonwebtoken": "^8.5.7",
"@types/lodash.debounce": "^4.0.6",
Expand All @@ -69,6 +73,8 @@
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/bigcommerce/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
11 changes: 9 additions & 2 deletions packages/commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"prettier-fix": "prettier --write ."
},
"sideEffects": false,
Expand Down Expand Up @@ -57,6 +59,9 @@
"react-dom": "^17"
},
"devDependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/js-cookie": "^3.0.1",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
Expand All @@ -65,6 +70,8 @@
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/commerce/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
11 changes: 9 additions & 2 deletions packages/commercejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"prettier-fix": "prettier --write ."
},
"sideEffects": false,
Expand Down Expand Up @@ -54,6 +56,9 @@
"react-dom": "^17"
},
"devDependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/chec__commerce.js": "^2.8.4",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
Expand All @@ -62,6 +67,8 @@
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/commercejs/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
11 changes: 9 additions & 2 deletions packages/kibocommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"prettier-fix": "prettier --write .",
"generate": "graphql-codegen"
},
Expand Down Expand Up @@ -60,13 +62,18 @@
"@graphql-codegen/schema-ast": "^2.4.1",
"@graphql-codegen/typescript": "^2.4.2",
"@graphql-codegen/typescript-operations": "^2.2.2",
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/kibocommerce/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
11 changes: 9 additions & 2 deletions packages/local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"prettier-fix": "prettier --write ."
},
"sideEffects": false,
Expand Down Expand Up @@ -54,13 +56,18 @@
"react-dom": "^17"
},
"devDependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/local/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
11 changes: 9 additions & 2 deletions packages/ordercloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "rm -fr dist/* && tsc",
"dev": "npm run build -- --watch",
"release": "taskr release",
"build": "taskr build",
"dev": "taskr",
"types": "tsc --emitDeclarationOnly",
"prettier-fix": "prettier --write ."
},
"sideEffects": false,
Expand Down Expand Up @@ -55,13 +57,18 @@
"react-dom": "^17"
},
"devDependencies": {
"@taskr/clear": "^1.1.0",
"@taskr/esnext": "^1.1.0",
"@taskr/watch": "^1.1.0",
"@types/node": "^17.0.8",
"@types/react": "^17.0.38",
"lint-staged": "^12.1.7",
"next": "^12.0.8",
"prettier": "^2.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"taskr": "^1.1.0",
"taskr-swc": "^0.0.1",
"typescript": "^4.5.4"
},
"lint-staged": {
Expand Down
20 changes: 20 additions & 0 deletions packages/ordercloud/taskfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export async function build(task, opts) {
await task
.source('src/**/*.+(ts|tsx|js)')
.swc({ dev: opts.dev, outDir: 'dist', baseUrl: 'src' })
.target('dist')
.source('src/**/*.+(cjs|json)')
.target('dist')
task.$.log('Compiled src files')
}

export async function release(task) {
await task.clear('dist').start('build')
}

export default async function dev(task) {
const opts = { dev: true }
await task.clear('dist')
await task.start('build', opts)
await task.watch('src/**/*.+(ts|tsx|js|cjs|json)', 'build', opts)
}
Loading

0 comments on commit 541491f

Please sign in to comment.