Skip to content

Commit

Permalink
add --transpileOnly flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sebald committed Nov 5, 2019
1 parent 6225b8e commit cfb2094
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function createRollupConfig(opts: TsdxOptions) {
target: 'esnext',
},
},
check: opts.transpileOnly === false,
}),
babelPluginTsdx({
exclude: 'node_modules/**',
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } : {},
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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.'
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 6 additions & 1 deletion test/tests/tsdx-build.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @jest-environment node
*/
'use strict';

const shell = require('shelljs');
const util = require('../fixtures/util');
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit cfb2094

Please sign in to comment.