From cfb2094b6cdfe60d33c27131060f299e1c2217a8 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Tue, 5 Nov 2019 17:10:22 +0100 Subject: [PATCH 1/6] add --transpileOnly flag Ref jaredpalmer/tsdx#243 --- src/createRollupConfig.ts | 1 + src/index.ts | 9 ++++++++- src/types.ts | 2 ++ test/tests/tsdx-build.test.js | 7 ++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/createRollupConfig.ts b/src/createRollupConfig.ts index d679b39fd..6fc224a96 100644 --- a/src/createRollupConfig.ts +++ b/src/createRollupConfig.ts @@ -142,6 +142,7 @@ export function createRollupConfig(opts: TsdxOptions) { target: 'esnext', }, }, + check: opts.transpileOnly === false, }), babelPluginTsdx({ exclude: 'node_modules/**', diff --git a/src/index.ts b/src/index.ts index 13f753fd2..e82800d3d 100755 --- a/src/index.ts +++ b/src/index.ts @@ -288,7 +288,10 @@ prog scripts: { start: 'tsdx watch', build: 'tsdx build', - test: template === 'react' ? 'tsdx test --env=jsdom --passWithNoTests' : 'tsdx test', + test: + template === 'react' + ? 'tsdx test --env=jsdom --passWithNoTests' + : 'tsdx test', lint: 'tsdx lint', }, peerDependencies: template === 'react' ? { react: '>=16' } : {}, @@ -358,6 +361,8 @@ prog .example('watch --noClean') .option('--tsconfig', 'Specify custom tsconfig path') .example('watch --tsconfig ./tsconfig.foo.json') + .option('--transpileOnly, -T', 'Skip type checking', false) + .example('build --transpileOnly') .option('--extractErrors', 'Extract invariant errors to ./errors/codes.json.') .example('build --extractErrors') .action(async (dirtyOpts: any) => { @@ -420,6 +425,8 @@ prog .example('build --format cjs,esm') .option('--tsconfig', 'Specify custom tsconfig path') .example('build --tsconfig ./tsconfig.foo.json') + .option('--transpileOnly, -T', 'Skip type checking', false) + .example('build --transpileOnly') .option( '--extractErrors', 'Extract errors to ./errors/codes.json and provide a url for decoding.' diff --git a/src/types.ts b/src/types.ts index ff40dd5f8..ef136136a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,4 +17,6 @@ export interface TsdxOptions { minify?: boolean; // Is this the very first rollup config (and thus should one-off metadata be extracted)? writeMeta?: boolean; + // Only transpile, do not type check (makes compilation faster) + transpileOnly?: boolean; } diff --git a/test/tests/tsdx-build.test.js b/test/tests/tsdx-build.test.js index 7c34af7c5..a9bc48c8e 100644 --- a/test/tests/tsdx-build.test.js +++ b/test/tests/tsdx-build.test.js @@ -1,7 +1,6 @@ /** * @jest-environment node */ -'use strict'; const shell = require('shelljs'); const util = require('../fixtures/util'); @@ -85,6 +84,12 @@ describe('tsdx build', () => { expect(code).toBe(1); }); + it('should only transpile and not type check', () => { + util.setupStageWithFixture(stageName, 'build-invalid'); + const code = shell.exec('node ../dist/index.js build --transpileOnly').code; + expect(code).toBe(0); + }); + afterEach(() => { util.teardownStage(stageName); }); From ce8b4d50a78b7f2cc706bf1622c0c0fa4063359c Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Wed, 6 Nov 2019 08:10:58 +0100 Subject: [PATCH 2/6] Document --transpileOnly flag --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc0b2ff10..a390a8803 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b - [Development-only Expressions + Treeshaking](#development-only-expressions--treeshaking) - [Rollup Treeshaking](#rollup-treeshaking) - [Advanced `babel-plugin-dev-expressions`](#advanced-babel-plugin-dev-expressions) - - [`__DEV__`](#__dev__) + - [`__DEV__`](#dev) - [`invariant`](#invariant) - [`warning`](#warning) - [Using lodash](#using-lodash) @@ -35,6 +35,7 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b - [`tsdx lint`](#tsdx-lint) - [Author](#author) - [License](#license) +- [Contributors ✨](#contributors-%e2%9c%a8) @@ -309,7 +310,7 @@ The `options` object contains the following: export interface TsdxOptions { // path to file input: string; - // Safe name (for UMD) + // Name of package name: string; // JS target target: 'node' | 'browser'; @@ -319,12 +320,14 @@ export interface TsdxOptions { env: 'development' | 'production'; // Path to tsconfig file tsconfig?: string; - // Is opt-in invariant error extraction active? + // Is error extraction running? extractErrors?: boolean; // Is minifying? minify?: boolean; // Is this the very first rollup config (and thus should one-off metadata be extracted)? writeMeta?: boolean; + // Only transpile, do not type check (makes compilation faster) + transpileOnly?: boolean; } ``` @@ -389,6 +392,7 @@ Options --tsconfig Specify your custom tsconfig path (default /tsconfig.json) --verbose Keep outdated console output in watch mode instead of clearing the screen --noClean Don't clean the dist folder + -T, --transpileOnly Skip type checking -h, --help Displays this message Examples @@ -398,6 +402,7 @@ Examples $ tsdx watch --format cjs,esm,umd $ tsdx watch --tsconfig ./tsconfig.foo.json $ tsdx watch --noClean + $ tsdx watch --transpileOnly ``` ### `tsdx build` @@ -416,6 +421,7 @@ Options --format Specify module format(s) (default cjs,esm) --extractErrors Opt-in to extracting invariant error codes --tsconfig Specify your custom tsconfig path (default /tsconfig.json) + -T, --transpileOnly Skip type checking -h, --help Displays this message Examples @@ -425,6 +431,7 @@ Examples $ tsdx build --format cjs,esm,umd $ tsdx build --extractErrors $ tsdx build --tsconfig ./tsconfig.foo.json + $ tsdx build --transpileOnly ``` ### `tsdx test` From 76a7d66518ba7fd810f40203eff3569d02109f01 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Wed, 6 Nov 2019 08:45:01 +0100 Subject: [PATCH 3/6] Make test check that stuff is build --- test/tests/tsdx-build.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/tests/tsdx-build.test.js b/test/tests/tsdx-build.test.js index a9bc48c8e..b91bc9808 100644 --- a/test/tests/tsdx-build.test.js +++ b/test/tests/tsdx-build.test.js @@ -87,6 +87,18 @@ describe('tsdx build', () => { it('should only transpile and not type check', () => { util.setupStageWithFixture(stageName, 'build-invalid'); const code = shell.exec('node ../dist/index.js build --transpileOnly').code; + + expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-invalid.cjs.development.js') + ).toBeTruthy(); + expect( + shell.test('-f', 'dist/build-invalid.cjs.production.min.js') + ).toBeTruthy(); + expect(shell.test('-f', 'dist/build-invalid.esm.js')).toBeTruthy(); + + expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); + expect(code).toBe(0); }); From 97fa11230857044e99211eb8da4aef3cda3c119f Mon Sep 17 00:00:00 2001 From: swyx Date: Wed, 6 Nov 2019 19:50:56 +0100 Subject: [PATCH 4/6] fix anchor id --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a390a8803..c21a8724b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b - [Development-only Expressions + Treeshaking](#development-only-expressions--treeshaking) - [Rollup Treeshaking](#rollup-treeshaking) - [Advanced `babel-plugin-dev-expressions`](#advanced-babel-plugin-dev-expressions) - - [`__DEV__`](#dev) + - [`__DEV__`](#__dev__) - [`invariant`](#invariant) - [`warning`](#warning) - [Using lodash](#using-lodash) From 4e54d7bc93029020981971e4bb61bcd9dda7c009 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Thu, 19 Dec 2019 09:39:27 +0100 Subject: [PATCH 5/6] remove shorthand --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 97b3be8f6..7e608b5ea 100755 --- a/src/index.ts +++ b/src/index.ts @@ -335,7 +335,7 @@ prog .example('watch --noClean') .option('--tsconfig', 'Specify custom tsconfig path') .example('watch --tsconfig ./tsconfig.foo.json') - .option('--transpileOnly, -T', 'Skip type checking', false) + .option('--transpileOnly', 'Skip type checking', false) .example('build --transpileOnly') .option('--extractErrors', 'Extract invariant errors to ./errors/codes.json.') .example('build --extractErrors') @@ -399,7 +399,7 @@ prog .example('build --format cjs,esm') .option('--tsconfig', 'Specify custom tsconfig path') .example('build --tsconfig ./tsconfig.foo.json') - .option('--transpileOnly, -T', 'Skip type checking', false) + .option('--transpileOnly', 'Skip type checking', false) .example('build --transpileOnly') .option( '--extractErrors', From 0d21bb79dcf37cdfbb567a02a48ec6d6c1659189 Mon Sep 17 00:00:00 2001 From: Sebastian Sebald Date: Thu, 19 Dec 2019 09:43:30 +0100 Subject: [PATCH 6/6] remove docs --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 68b50de7d..be6250669 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,18 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b - [Features](#features) - [Quick Start](#quick-start) - - [`npm start` or `yarn start`](#npm-start-or-yarn-start) - - [`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) + - [npm start or yarn start](#npm-start-or-yarn-start) + - [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) - - [Advanced `babel-plugin-dev-expressions`](#advanced-babel-plugin-dev-expressions) - - [`__DEV__`](#__dev__) - - [`invariant`](#invariant) - - [`warning`](#warning) + - [Advanced babel-plugin-dev-expressions](#advanced-babel-plugin-dev-expressions) + - [__DEV__](#dev) + - [invariant](#invariant) + - [warning](#warning) - [Using lodash](#using-lodash) - [Error extraction](#error-extraction) - [Customization](#customization) @@ -30,10 +30,10 @@ Despite all the recent hype, setting up a new TypeScript (x React) library can b - [Inspiration](#inspiration) - [Comparison to Microbundle](#comparison-to-microbundle) - [API Reference](#api-reference) - - [`tsdx watch`](#tsdx-watch) - - [`tsdx build`](#tsdx-build) - - [`tsdx test`](#tsdx-test) - - [`tsdx lint`](#tsdx-lint) + - [tsdx watch](#tsdx-watch) + - [tsdx build](#tsdx-build) + - [tsdx test](#tsdx-test) + - [tsdx lint](#tsdx-lint) - [Author](#author) - [License](#license) - [Contributors ✨](#contributors-%e2%9c%a8) @@ -398,7 +398,7 @@ Options --tsconfig Specify your custom tsconfig path (default /tsconfig.json) --verbose Keep outdated console output in watch mode instead of clearing the screen --noClean Don't clean the dist folder - -T, --transpileOnly Skip type checking + --transpileOnly Skip type checking -h, --help Displays this message Examples @@ -427,7 +427,7 @@ Options --format Specify module format(s) (default cjs,esm) --extractErrors Opt-in to extracting invariant error codes --tsconfig Specify your custom tsconfig path (default /tsconfig.json) - -T, --transpileOnly Skip type checking + --transpileOnly Skip type checking -h, --help Displays this message Examples