From bc4c5ee8615ca2370cd9ed04f27c1d932c636b36 Mon Sep 17 00:00:00 2001
From: Joe Flateau <joe@joeflateau.net>
Date: Thu, 14 Nov 2019 21:33:22 -0500
Subject: [PATCH 1/2] add prepare script

---
 .gitignore   | 1 +
 README.md    | 6 ++++++
 package.json | 7 ++++---
 src/index.ts | 1 +
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/.gitignore b/.gitignore
index d9ba4b95e..2da87778c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,5 +8,6 @@ node_modules
 dist
 tester
 tester-react
+package-lock.json
 # Local Netlify folder
 .netlify
diff --git a/README.md b/README.md
index dc0b2ff10..dbc3833fd 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,7 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b
   - [`npm run build` or `yarn build`](#npm-run-build-or-yarn-build)
   - [`npm test` or `yarn test`](#npm-test-or-yarn-test)
   - [`npm run lint` or `yarn lint`](#npm-run-lint-or-yarn-lint)
+  - [`prepare` script](#prepare-script)
 - [Optimizations](#optimizations)
   - [Development-only Expressions + Treeshaking](#development-only-expressions--treeshaking)
     - [Rollup Treeshaking](#rollup-treeshaking)
@@ -89,6 +90,11 @@ By default, runs tests related to files changed since the last commit.
 Runs Eslint with Prettier on .ts and .tsx files.
 If you want to customize eslint you can add an `eslint` block to your package.json, or you can run `yarn lint --write-file` and edit the generated `.eslintrc.js` file.
 
+### `prepare` script
+
+Bundles and packages to the `dist` folder.
+Runs automatically when you run either `npm publish` or `yarn publish`. The `prepare` script will run the equivalent of `npm run build` or `yarn build`. It will also be run if your module is installed as a git dependency (ie: `"mymodule": "github:myuser/mymodule#some-branch"`) so it can be depended on without checking the transpiled code into git.
+
 ## Optimizations
 
 Aside from just bundling your module into different formats, TSDX comes with some optimizations for your convenience. They yield objectively better code and smaller bundle sizes.
diff --git a/package.json b/package.json
index 59decd5c1..a0ebe767c 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,7 @@
   "scripts": {
     "prepare": "tsc -p tsconfig.json",
     "build": "tsc -p tsconfig.json",
-    "lint": "yarn build && yarn lint:post-build",
+    "lint": "yon build && yon lint:post-build",
     "lint:post-build": "node dist/index.js lint src test --ignore-pattern 'test/tests/lint'",
     "test": "jest --config ./test/jest.config.json"
   },
@@ -112,11 +112,12 @@
     "husky": "^3.0.9",
     "pretty-quick": "^2.0.0",
     "ps-tree": "^1.2.0",
-    "react": "^16.8.6"
+    "react": "^16.8.6",
+    "yarn-or-npm": "^3.0.1"
   },
   "husky": {
     "hooks": {
-      "pre-commit": "pretty-quick --staged --pattern '!test/tests/lint/**' && yarn lint"
+      "pre-commit": "pretty-quick --staged --pattern '!test/tests/lint/**' && yon lint"
     }
   },
   "prettier": {
diff --git a/src/index.ts b/src/index.ts
index a3eedaea5..f9334319b 100755
--- a/src/index.ts
+++ b/src/index.ts
@@ -288,6 +288,7 @@ prog
               ? 'tsdx test --env=jsdom --passWithNoTests'
               : 'tsdx test',
           lint: 'tsdx lint',
+          prepare: 'tsdx build',
         },
         peerDependencies: template === 'react' ? { react: '>=16' } : {},
         husky: {

From 30e4b6db4ac40d8726cd7a66a929f7455fd44ca6 Mon Sep 17 00:00:00 2001
From: Joe Flateau <joe@joeflateau.net>
Date: Tue, 3 Dec 2019 13:46:57 -0800
Subject: [PATCH 2/2] remove yarn-or-npm

---
 package.json | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/package.json b/package.json
index a0ebe767c..59decd5c1 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,7 @@
   "scripts": {
     "prepare": "tsc -p tsconfig.json",
     "build": "tsc -p tsconfig.json",
-    "lint": "yon build && yon lint:post-build",
+    "lint": "yarn build && yarn lint:post-build",
     "lint:post-build": "node dist/index.js lint src test --ignore-pattern 'test/tests/lint'",
     "test": "jest --config ./test/jest.config.json"
   },
@@ -112,12 +112,11 @@
     "husky": "^3.0.9",
     "pretty-quick": "^2.0.0",
     "ps-tree": "^1.2.0",
-    "react": "^16.8.6",
-    "yarn-or-npm": "^3.0.1"
+    "react": "^16.8.6"
   },
   "husky": {
     "hooks": {
-      "pre-commit": "pretty-quick --staged --pattern '!test/tests/lint/**' && yon lint"
+      "pre-commit": "pretty-quick --staged --pattern '!test/tests/lint/**' && yarn lint"
     }
   },
   "prettier": {