diff --git a/.gitignore b/.gitignore index 164de0f21..d2f6a9155 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ node_modules dist tester tester-react +package-lock.json # Local Netlify folder .netlify diff --git a/README.md b/README.md index de5514a52..5b492f3b4 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/src/index.ts b/src/index.ts index 7bf8b6834..dc7c5e651 100755 --- a/src/index.ts +++ b/src/index.ts @@ -296,6 +296,7 @@ prog ? 'tsdx test --env=jsdom --passWithNoTests' : 'tsdx test', lint: 'tsdx lint', + prepare: 'tsdx build', }, peerDependencies: template === 'react' ? { react: '>=16' } : {}, husky: {