Skip to content

Commit

Permalink
add prepare script
Browse files Browse the repository at this point in the history
  • Loading branch information
joeflateau committed Nov 15, 2019
1 parent 6252b70 commit bc4c5ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ node_modules
dist
tester
tester-react
package-lock.json
# Local Netlify folder
.netlify
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",

This comment has been minimized.

Copy link
@jaredpalmer

jaredpalmer Dec 3, 2019

Owner

?

This comment has been minimized.

Copy link
@joeflateau

joeflateau Dec 3, 2019

Author Contributor

I'll revert these in this PR and open a new one w/ yarn-or-npm (which you can then close if you still don't like it, but at least not muddy up this PR).

"lint:post-build": "node dist/index.js lint src test --ignore-pattern 'test/tests/lint'",
"test": "jest --config ./test/jest.config.json"
},
Expand Down Expand Up @@ -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"

This comment has been minimized.

Copy link
@jaredpalmer

jaredpalmer Dec 3, 2019

Owner

Not a fan of this. People aren’t expecting it

},
"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": {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ prog
? 'tsdx test --env=jsdom --passWithNoTests'
: 'tsdx test',
lint: 'tsdx lint',
prepare: 'tsdx build',
},
peerDependencies: template === 'react' ? { react: '>=16' } : {},
husky: {
Expand Down

0 comments on commit bc4c5ee

Please sign in to comment.