-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1806 from rollup/ts-refactoring
[Finished] TypeScript conversion
- Loading branch information
Showing
310 changed files
with
10,315 additions
and
7,164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*.ts] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"typescript.format.insertSpaceBeforeFunctionParenthesis": true, | ||
"typescript.format.insertSpaceAfterConstructor": true, | ||
"typescript.format.enable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
declare module 'minimist'; | ||
declare module 'help.md' { | ||
let str: string; | ||
export default str; | ||
} | ||
declare module 'package.json'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/// <reference path="./index.d.ts" /> | ||
|
||
import minimist from 'minimist'; | ||
import help from 'help.md'; | ||
import { version } from 'package.json'; | ||
import run from './run/index.js'; | ||
|
||
const command = minimist(process.argv.slice(2), { | ||
alias: { | ||
// Aliases | ||
strict: 'useStrict', | ||
|
||
// Short options | ||
c: 'config', | ||
d: 'indent', | ||
e: 'external', | ||
f: 'output.format', | ||
g: 'globals', | ||
h: 'help', | ||
i: 'input', | ||
l: 'legacy', | ||
m: 'sourcemap', | ||
n: 'name', | ||
o: 'output.file', | ||
v: 'version', | ||
w: 'watch' | ||
} | ||
}); | ||
|
||
if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) { | ||
console.log(`\n${help.replace('__VERSION__', version)}\n`); // eslint-disable-line no-console | ||
} else if (command.version) { | ||
console.log(`rollup version ${version}`); // eslint-disable-line no-console | ||
} else { | ||
try { | ||
require('source-map-support').install(); | ||
} catch (err) { | ||
// do nothing | ||
} | ||
|
||
run(command); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import chalk from 'chalk'; | ||
import relativeId from '../../src/utils/relativeId.js'; | ||
import { RollupError } from '../../src/utils/error'; | ||
|
||
if (!process.stderr.isTTY) chalk.enabled = false; | ||
|
||
// log to stderr to keep `rollup main.js > bundle.js` from breaking | ||
export const stderr = console.error.bind(console); // eslint-disable-line no-console | ||
|
||
export function handleError (err: RollupError, recover = false) { | ||
let description = err.message || err; | ||
if (err.name) description = `${err.name}: ${description}`; | ||
const message = | ||
((<{ plugin?: string }>err).plugin ? `(${(<{ plugin?: string }>err).plugin} plugin) ${description}` : description) || err; | ||
|
||
stderr(chalk.bold.red(`[!] ${chalk.bold(message.toString())}`)); | ||
|
||
// TODO should this be "err.url || (err.file && err.loc.file) || err.id"? | ||
if (err.url) { | ||
stderr(chalk.cyan(err.url)); | ||
} | ||
|
||
if (err.loc) { | ||
stderr( | ||
`${relativeId(err.loc.file || err.id)} (${err.loc.line}:${ | ||
err.loc.column | ||
})` | ||
); | ||
} else if (err.id) { | ||
stderr(relativeId(err.id)); | ||
} | ||
|
||
if (err.frame) { | ||
stderr(chalk.dim(err.frame)); | ||
} else if (err.stack) { | ||
stderr(chalk.dim(err.stack)); | ||
} | ||
|
||
stderr(''); | ||
|
||
if (!recover) process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module "ansi-escapes"; |
22 changes: 12 additions & 10 deletions
22
bin/src/run/alternateScreen.js → bin/src/run/alternateScreen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
/// <reference path="./alternateScreen.d.ts" /> | ||
|
||
import ansiEscape from 'ansi-escapes'; | ||
import { stderr } from '../logging.js'; | ||
|
||
const SHOW_ALTERNATE_SCREEN = '\u001B[?1049h'; | ||
const HIDE_ALTERNATE_SCREEN = '\u001B[?1049l'; | ||
|
||
export default function alternateScreen ( enabled ) { | ||
export default function alternateScreen (enabled: boolean) { | ||
if (!enabled) { | ||
let needAnnounce = true; | ||
return { | ||
open() {}, | ||
close() {}, | ||
reset( heading ) { | ||
if ( needAnnounce ) { | ||
stderr( heading ); | ||
open () { }, | ||
close () { }, | ||
reset (heading: string) { | ||
if (needAnnounce) { | ||
stderr(heading); | ||
needAnnounce = false; | ||
} | ||
} | ||
}; | ||
} | ||
|
||
return { | ||
open() { | ||
open () { | ||
process.stderr.write(SHOW_ALTERNATE_SCREEN); | ||
}, | ||
close() { | ||
close () { | ||
process.stderr.write(HIDE_ALTERNATE_SCREEN); | ||
}, | ||
reset( heading ) { | ||
stderr( `${ansiEscape.eraseScreen}${ansiEscape.cursorTo(0, 0)}${heading}` ); | ||
reset (heading: string) { | ||
stderr(`${ansiEscape.eraseScreen}${ansiEscape.cursorTo(0, 0)}${heading}`); | ||
} | ||
}; | ||
} |
Oops, something went wrong.