Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 34b5ccc

Browse files
committed
Merge pull request #26 from rollup/handle-abstract-classes
Handle abstract classes
2 parents 0b14ac8 + a67275d commit 34b5ccc

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## master
44
* Do not duplicate TypeScript's helpers ([#24](https://github.com/rollup/rollup-plugin-typescript/issues/24)
5+
* Handle `export abstract class` ([#23](https://github.com/rollup/rollup-plugin-typescript/issues/23)
56

67
### 0.4.1
78
* Does not attempt resolve or transform `.d.ts` files ([#22](https://github.com/rollup/rollup-plugin-typescript/pull/22))

src/fixExportClass.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ export default function fix ( code: string, id: string ): string {
3636
// Erase comments, strings etc. to avoid erroneous matches for the Regex.
3737
const cleanCode = tippex.erase( code );
3838

39-
const re = /export\s+(default\s+)?class(?:\s+(\w+))?/g;
39+
const re = /export\s+(default\s+)?((?:abstract\s+)?class)(?:\s+(\w+))?/g;
4040
let match;
4141

4242
while ( match = re.exec( cleanCode ) ) {
4343
// To keep source maps intact, replace non-whitespace characters with spaces.
44-
code = erase( code, match.index, match[ 0 ].indexOf( 'class' ) );
44+
code = erase( code, match.index, match[ 0 ].indexOf( match[ 2 ] ) );
4545

46-
let name = match[ 2 ];
46+
let name = match[ 3 ];
4747

4848
if ( match[ 1 ] ) { // it is a default export
4949

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export abstract class A {}

test/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ describe( 'rollup-plugin-typescript', function () {
7272
});
7373
});
7474

75+
it( 'works with named exports for abstract classes', function () {
76+
return bundle( 'sample/export-abstract-class/main.ts' ).then(function ( bundle ) {
77+
const code = bundle.generate().code;
78+
assert.ok( code.length > 0, code );
79+
});
80+
});
81+
7582
it( 'should use named exports for classes', function () {
7683
return bundle( 'sample/export-class/main.ts' ).then( function ( bundle ) {
7784
assert.equal( evaluate( bundle ).foo, 'bar' );

0 commit comments

Comments
 (0)