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

Commit 954ccce

Browse files
authored
Merge pull request #60 from rollup/build-conflict
Build conflict
2 parents ebc9c82 + 224dd5d commit 954ccce

File tree

8 files changed

+37
-78
lines changed

8 files changed

+37
-78
lines changed

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.7.7",
44
"description": "Seamless integration between Rollup and TypeScript.",
55
"main": "dist/rollup-plugin-typescript.cjs.js",
6-
"jsnext:main": "dist/rollup-plugin-typescript.es6.js",
6+
"module": "dist/rollup-plugin-typescript.es.js",
7+
"jsnext:main": "dist/rollup-plugin-typescript.es.js",
78
"files": [
89
"dist",
910
"src",
@@ -22,8 +23,8 @@
2223
"prepublish": "npm run test",
2324
"pretest": "npm run build",
2425
"build:cjs": "rollup -c -f cjs -o dist/rollup-plugin-typescript.cjs.js",
25-
"build:es6": "rollup -c -o dist/rollup-plugin-typescript.es6.js",
26-
"build": "npm run build:cjs && npm run build:es6",
26+
"build:es": "rollup -c -o dist/rollup-plugin-typescript.es.js",
27+
"build": "npm run build:cjs && npm run build:es",
2728
"prebuild": "rimraf dist/*"
2829
},
2930
"dependencies": {
@@ -34,10 +35,10 @@
3435
"typescript": "^1.8.9"
3536
},
3637
"devDependencies": {
37-
"mocha": "^2.3.3",
38+
"mocha": "^3.0.0",
3839
"rimraf": "^2.5.4",
39-
"rollup": "^0.25.7",
40-
"rollup-plugin-typescript": "^0.5.0"
40+
"rollup": "^0.34.3",
41+
"rollup-plugin-buble": "^0.12.1"
4142
},
4243
"repository": {
4344
"type": "git",

rollup.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import typescript from 'rollup-plugin-typescript';
1+
import buble from 'rollup-plugin-buble';
22

33
export default {
4-
entry: 'src/index.ts',
4+
entry: 'src/index.js',
55

66
external: [
77
'compare-versions',
@@ -14,6 +14,6 @@ export default {
1414
],
1515

1616
plugins: [
17-
typescript()
17+
buble()
1818
]
1919
};

src/fixExportClass.ts renamed to src/fixExportClass.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ import * as tippex from 'tippex';
3131
// export { A };
3232
//
3333
// The solution is to replace the previous export syntax with the latter.
34-
export default function fix ( code: string, id: string ): string {
34+
export default function fix ( code, id ) {
3535

3636
// Erase comments, strings etc. to avoid erroneous matches for the Regex.
3737
const cleanCode = getErasedCode( code, id );
3838

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

4242
while ( match = re.exec( cleanCode ) ) {
4343
// To keep source maps intact, replace non-whitespace characters with spaces.
@@ -61,15 +61,15 @@ export default function fix ( code: string, id: string ): string {
6161
return code;
6262
}
6363

64-
function getErasedCode ( code: string, id: string ): string {
64+
function getErasedCode ( code, id ) {
6565
try {
6666
return tippex.erase( code );
6767
} catch (e) {
6868
throw new Error( `rollup-plugin-typescript: ${ e.message }; when processing: '${ id }'` );
6969
}
7070
}
7171

72-
function erase ( code: string, start: number, length: number ): string {
72+
function erase ( code, start, length ) {
7373
const end = start + length;
7474

7575
return code.slice( 0, start ) +

src/index.ts renamed to src/index.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ import compareVersions from 'compare-versions';
1111

1212
import { endsWith } from './string';
1313
import fixExportClass from './fixExportClass';
14-
14+
/*
1515
interface Options {
1616
tsconfig?: boolean;
1717
include?: string | string[];
1818
exclude?: string | string[];
1919
typescript?: typeof ts;
2020
module?: string;
2121
}
22-
22+
*/
2323
const resolveHost = {
24-
directoryExists ( dirPath: string ): boolean {
24+
directoryExists ( dirPath ) {
2525
try {
2626
return statSync( dirPath ).isDirectory();
2727
} catch ( err ) {
2828
return false;
2929
}
3030
},
31-
fileExists ( filePath: string ): boolean {
31+
fileExists ( filePath ) {
3232
try {
3333
return statSync( filePath ).isFile();
3434
} catch ( err ) {
@@ -37,12 +37,12 @@ const resolveHost = {
3737
}
3838
};
3939

40-
function goodErrors ( diagnostic: ts.Diagnostic ): boolean {
40+
function goodErrors ( diagnostic ) {
4141
// All errors except `Cannot compile modules into 'es6' when targeting 'ES5' or lower.`
4242
return diagnostic.code !== 1204;
4343
}
4444

45-
function getDefaultOptions(): any {
45+
function getDefaultOptions() {
4646
return {
4747
noEmitHelpers: true,
4848
module: 'es2015',
@@ -53,7 +53,7 @@ function getDefaultOptions(): any {
5353
// Gratefully lifted from 'look-up', due to problems using it directly:
5454
// https://github.com/jonschlinkert/look-up/blob/master/index.js
5555
// MIT Licenced
56-
function findFile( cwd: string, filename: string ): string {
56+
function findFile( cwd, filename ) {
5757
let fp = cwd ? ( cwd + '/' + filename ) : filename;
5858

5959
if ( existsSync( fp ) ) {
@@ -74,7 +74,7 @@ function findFile( cwd: string, filename: string ): string {
7474
return null;
7575
}
7676

77-
function compilerOptionsFromTsConfig( typescript: typeof ts ): ts.CompilerOptions {
77+
function compilerOptionsFromTsConfig( typescript ) {
7878
const cwd = process.cwd();
7979

8080
const tsconfig = typescript.readConfigFile( findFile( cwd, 'tsconfig.json' ), path => readFileSync( path, 'utf8' ) );
@@ -84,7 +84,7 @@ function compilerOptionsFromTsConfig( typescript: typeof ts ): ts.CompilerOption
8484
return tsconfig.config.compilerOptions;
8585
}
8686

87-
function adjustCompilerOptions( typescript: typeof ts, options: any ) {
87+
function adjustCompilerOptions( typescript, options ) {
8888
// Set `sourceMap` to `inlineSourceMap` if it's a boolean
8989
// under the assumption that both are never specified simultaneously.
9090
if ( typeof options.inlineSourceMap === 'boolean' ) {
@@ -104,7 +104,7 @@ function adjustCompilerOptions( typescript: typeof ts, options: any ) {
104104
}
105105
}
106106

107-
export default function typescript ( options: Options ) {
107+
export default function typescript ( options ) {
108108
options = assign( {}, options || {} );
109109

110110
const filter = createFilter(
@@ -115,7 +115,7 @@ export default function typescript ( options: Options ) {
115115
delete options.exclude;
116116

117117
// Allow users to override the TypeScript version used for transpilation.
118-
const typescript: typeof ts = options.typescript || ts;
118+
const typescript = options.typescript || ts;
119119

120120
delete options.typescript;
121121

@@ -149,19 +149,21 @@ export default function typescript ( options: Options ) {
149149
const compilerOptions = parsed.options;
150150

151151
return {
152-
resolveId ( importee: string, importer: string ): string {
152+
resolveId ( importee, importer ) {
153153
// Handle the special `typescript-helpers` import itself.
154154
if ( importee === 'typescript-helpers' ) {
155155
return path.resolve( __dirname, '../src/typescript-helpers.js' );
156156
}
157157

158158
if ( !importer ) return null;
159159

160-
var result: ts.ResolvedModuleWithFailedLookupLocations;
160+
var result;
161+
162+
importer = importer.split('\\').join('/');
161163

162164
if ( compareVersions( typescript.version, '1.8.0' ) < 0 ) {
163165
// Suppress TypeScript warnings for function call.
164-
result = (typescript as any).nodeModuleNameResolver( importee, importer, resolveHost );
166+
result = typescript.nodeModuleNameResolver( importee, importer, resolveHost );
165167
} else {
166168
result = typescript.nodeModuleNameResolver( importee, importer, compilerOptions, resolveHost );
167169
}
@@ -177,7 +179,7 @@ export default function typescript ( options: Options ) {
177179
return null;
178180
},
179181

180-
transform ( code: string, id: string ): { code: string, map: any } {
182+
transform ( code, id ) {
181183
if ( !filter( id ) ) return null;
182184

183185
const transformed = typescript.transpileModule( fixExportClass( code, id ), {
@@ -208,7 +210,7 @@ export default function typescript ( options: Options ) {
208210
});
209211

210212
if ( fatalError ) {
211-
throw new Error( `There were TypeScript errors transpiling "${id}"` );
213+
throw new Error( `There were TypeScript errors transpiling` );
212214
}
213215

214216
return {
@@ -217,7 +219,7 @@ export default function typescript ( options: Options ) {
217219
`\nimport { __assign, __awaiter, __extends, __decorate, __metadata, __param } from 'typescript-helpers';`,
218220

219221
// Rollup expects `map` to be an object so we must parse the string
220-
map: JSON.parse(transformed.sourceMapText as string)
222+
map: JSON.parse(transformed.sourceMapText)
221223
};
222224
}
223225
};

src/string.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function endsWith ( str, tail ) {
2+
return !tail.length || str.slice( -tail.length ) === tail;
3+
}

src/string.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe( 'rollup-plugin-typescript', function () {
8282

8383
it( 'reports diagnostics and throws if errors occur during transpilation', function () {
8484
return bundle( 'sample/syntax-error/missing-type.ts' ).catch( function ( error ) {
85-
assert.ok( error.message.indexOf( 'There were TypeScript errors' ) === 0, 'Should reject erroneous code.' );
85+
assert.ok( error.message.indexOf( 'There were TypeScript errors transpiling' ) !== -1, 'Should reject erroneous code.' );
8686
});
8787
});
8888

tsconfig.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)