Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0] - 2022-10-27

### Added

- Allow defining typescript project with `-p` parameter to define a different `tsconfig.ts` file. p.eg: `package-build -p tsconfig.build.json`. This is useful to have a `tsconfig.json` in the root to allow IDE and library implementation to get a project file including files even if they won't be included in the NPM package (.spec, .test, .stories). Otherwise, a project including these files will transform every file defined, even those not desired in the final bundle, not only forcing to exclude them explicitly but increasing compilation times and errors. By default `tsconfig.json` will be used as it usually does.

## [0.0.2] - 2021-11-02

- Initial version
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Install this package as a dev dependency in your package, then create scripts in

NOTICE: this package doesn't clean your build directories in each run, so you'd probably want to append something like `rimraf` to your dependencies.

#### Parameters

- `-w` to watch the files.
- `-p` to define a different `tsconfig.ts` file. p.eg: `package-build -p tsconfig.build.json`.

### Publish a new version

- Update [CHANGELOG](./CHANGELOG.md) with new features, breaking changes, etc
Expand Down
6 changes: 3 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const watch = (config) => {
watcher.on('event', (event) => eventHandler(event));
};

const build = async (withWatch = false) => {
const build = async (withWatch = false, project) => {
const dirname = process.cwd();
console.log(`Bundling ${dirname}`);
const { input, output } = getRollupConfig(dirname);
const { input, output } = getRollupConfig(dirname, project);

if (withWatch) {
watch({ ...input, output });
Expand All @@ -60,4 +60,4 @@ const build = async (withWatch = false) => {

const argv = minimist(process.argv.slice(2));

build(argv.w);
build(argv.w, argv.p);
7 changes: 5 additions & 2 deletions getRollupConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const compileTypings = (cwd) => () => {
});
};

module.exports = (dirname) => {
module.exports = (dirname, project) => {
const pkgPath = path.join(dirname, 'package.json');
// eslint-disable-next-line import/no-dynamic-require, global-require
const pkg = require(pkgPath);
Expand All @@ -40,7 +40,10 @@ module.exports = (dirname) => {
return external.includes(namespace);
},
plugins: [
command(compileTypings(dirname), { exitOnFail: true, wait: true }),
command(compileTypings(project || dirname), {
exitOnFail: true,
wait: true,
}),
resolve({ extensions }),
commonjs(),
babel({
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cabify/package-build",
"version": "0.0.2",
"version": "0.1.0",
"description": "Common configuration & scripts for building TS packages with rollup",
"license": "Apache-2.0",
"main": "build.js",
Expand All @@ -17,7 +17,6 @@
"format:check": "prettier --check .",
"typecheck": "echo 'No typecheck to perform'",
"test:ci": "echo 'No test to perform'",

"publish:major": "npm version major",
"publish:minor": "npm version minor",
"publish:patch": "npm version patch",
Expand Down