This repository has been archived by the owner on Dec 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
6bd83ff
commit 1436114
Showing
67 changed files
with
939 additions
and
5,075 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 |
---|---|---|
|
@@ -10,4 +10,5 @@ src/test/output | |
.vagrant | ||
Vagrantfile | ||
issues | ||
.idea | ||
.idea | ||
.test |
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
sudo: false | ||
language: node_js | ||
before_install: | ||
- curl -o- -L https://yarnpkg.com/install.sh | bash | ||
- export PATH=$HOME/.yarn/bin:$PATH | ||
before_script: | ||
- npm i | ||
- npm run compile | ||
- yarn i | ||
- yarn run build | ||
node_js: | ||
- "7" |
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,3 @@ | ||
var loader = require('./dist'); | ||
|
||
module.exports = loader; |
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 |
---|---|---|
|
@@ -6,14 +6,14 @@ | |
"typings": "./dist/index.d.ts", | ||
"scripts": { | ||
"prepublish": "npm run build", | ||
"test": "mocha dist/test --harmony-async-await", | ||
"watch": "npm run watch:ts", | ||
"watch:ts": "npm run build:ts -- --watch --diagnostics", | ||
"prebuild": "npm run lint", | ||
"compile": "tsc --pretty", | ||
"build": "rm -rf dist && tsc -p prod --pretty", | ||
"build": "rm -rf dist && tsc --pretty", | ||
"lint": "tslint src/*.ts", | ||
"release": "standard-version" | ||
"release": "standard-version", | ||
"test": "mocha --timeout 10000 dist/__test__" | ||
}, | ||
"author": "Stanislav Panferov <[email protected]> (http://panferov.me/)", | ||
"repository": { | ||
|
@@ -33,34 +33,32 @@ | |
"homepage": "https://github.com/s-panferov/awesome-typescript-loader", | ||
"dependencies": { | ||
"colors": "^1.1.2", | ||
"enhanced-resolve": "^2.3.0", | ||
"enhanced-resolve": "^3.0.3", | ||
"loader-utils": "^0.2.16", | ||
"lodash": "^4.13.1", | ||
"object-assign": "^4.1.0", | ||
"source-map-support": "^0.4.0" | ||
"lodash": "^4.17.4", | ||
"object-assign": "^4.1.1", | ||
"source-map-support": "^0.4.11" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^3.4.34", | ||
"@types/colors": "^0.6.33", | ||
"@types/lodash": "^4.14.43", | ||
"@types/mocha": "^2.2.32", | ||
"@types/node": "^6.0.46", | ||
"@types/sinon": "^1.16.31", | ||
"babel-core": "^6.20.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"bluebird": "^3.4.1", | ||
"@types/colors": "^1.1.1", | ||
"@types/lodash": "^4.14.51", | ||
"@types/mocha": "^2.2.38", | ||
"@types/node": "^7.0.4", | ||
"@types/sinon": "^1.16.34", | ||
"bluebird": "^3.4.7", | ||
"chai": "^3.5.0", | ||
"empty-module": "0.0.2", | ||
"fs-extra": "^2.0.0", | ||
"git-hooks": "^1.0.2", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^3.2.0", | ||
"ps-node": "^0.1.1", | ||
"rimraf": "^2.5.0", | ||
"sinon": "^1.17.4", | ||
"standard-version": "^4.0.0", | ||
"temp": "^0.8.3", | ||
"tslint": "^4.0.2", | ||
"typescript": "^2.1.4", | ||
"webpack": "2.1.0-beta.25" | ||
"tslint": "^4.4.2", | ||
"typescript": "^2.1.5", | ||
"webpack": "2.2.0" | ||
} | ||
} |
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,58 @@ | ||
import { | ||
clear, src, webpackConfig, tsconfig, install, | ||
watch, checkOutput, expectErrors, query, run | ||
} from './utils'; | ||
|
||
run(__filename, async function() { | ||
clear(); | ||
const index = src('index.ts', ` | ||
class HiThere { | ||
constructor(a: number, b: string) { | ||
const t = a + b; | ||
} | ||
} | ||
`); | ||
|
||
install('babel-core', 'babel-preset-es2015'); | ||
tsconfig(); | ||
|
||
const watcher = await watch(webpackConfig(query({ | ||
useBabel: true, | ||
babelOptions: { | ||
"presets": ["es2015"] | ||
} | ||
}))); | ||
|
||
await watcher.wait(); | ||
|
||
expectErrors(0); | ||
checkOutput('index.js', ` | ||
var HiThere = function HiThere(a, b) { | ||
_classCallCheck(this, HiThere); | ||
var t = a + b; | ||
} | ||
`); | ||
|
||
index.update(() => ` | ||
function sum(...items: number[]) { | ||
return items.reduce((a,b) => a + b, 0); | ||
} | ||
`); | ||
|
||
await watcher.wait(); | ||
|
||
expectErrors(0); | ||
checkOutput('index.js', ` | ||
function sum() { | ||
for(var _len = arguments.length, | ||
items = Array(_len), | ||
_key = 0; | ||
_key < _len; | ||
_key++ | ||
) { | ||
items[_key] = arguments[_key]; | ||
} | ||
return items.reduce(function(a,b){ return a + b; }, 0); | ||
} | ||
`); | ||
}); |
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,57 @@ | ||
import { | ||
clear, src, webpackConfig, tsconfig, | ||
watch, checkOutput, expectErrors, run | ||
} from './utils'; | ||
|
||
run(__filename, async function() { | ||
clear(); | ||
const index = src('index.ts', ` | ||
export { default as sum } from './utils/sum' | ||
`); | ||
|
||
src('utils/sum.ts', ` | ||
export default function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
`); | ||
|
||
tsconfig({ | ||
declaration: true | ||
}); | ||
|
||
const watcher = watch(webpackConfig()); | ||
|
||
await watcher.wait(); | ||
|
||
expectErrors(0); | ||
|
||
checkOutput('src/index.d.ts', ` | ||
export { default as sum } from './utils/sum' | ||
`); | ||
|
||
checkOutput('src/utils/sum.d.ts', ` | ||
export default function sum(a: number, b: number): number | ||
`); | ||
|
||
src('utils/mul.ts', ` | ||
export default function mul(a: number, b: number) { | ||
return a * b; | ||
} | ||
`); | ||
|
||
index.update(() => ` | ||
export { default as sum } from './utils/sum' | ||
export { default as mul } from './utils/mul' | ||
`); | ||
|
||
await watcher.wait(); | ||
|
||
checkOutput('src/utils/mul.d.ts', ` | ||
export default function mul(a: number, b: number): number | ||
`); | ||
|
||
checkOutput('src/index.d.ts', ` | ||
export { default as sum } from './utils/sum'; | ||
export { default as mul } from './utils/mul'; | ||
`); | ||
}); |
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,31 @@ | ||
import { | ||
clear, src, webpackConfig, tsconfig, | ||
compile, checkOutput, expectErrors, run | ||
} from './utils'; | ||
|
||
run(__filename, async function() { | ||
clear(); | ||
src('index.ts', ` | ||
function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
sum('test', 1); | ||
`); | ||
|
||
tsconfig(); | ||
|
||
await compile(webpackConfig()); | ||
|
||
expectErrors(1, [ | ||
`Argument of type '"test"' is not assignable to parameter of type 'number'` | ||
]); | ||
|
||
checkOutput('index.js', ` | ||
function sum(a, b) { | ||
return a + b; | ||
} | ||
sum('test', 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,39 @@ | ||
import { | ||
clear, src, webpackConfig, expectErrors, | ||
tsconfig, compile, install, entry, run | ||
} from './utils'; | ||
|
||
run(__filename, async function() { | ||
clear(); | ||
install( | ||
'react', | ||
'react-dom', | ||
'@types/react', | ||
'@types/react-dom' | ||
); | ||
|
||
src('index.tsx', ` | ||
import * as React from 'react' | ||
import * as ReactDOM from 'react-dom' | ||
import App from './app' | ||
ReactDOM.render(<App title='Test' />, document.body) | ||
`); | ||
|
||
src('app.tsx', ` | ||
import * as React from 'react' | ||
export default class App extends React.Component<{title: string}, void> { | ||
render() { | ||
return <div>{ this.props.title }</div> | ||
} | ||
} | ||
`); | ||
|
||
tsconfig({ | ||
jsx: 'react' | ||
}); | ||
|
||
await compile(webpackConfig(entry('index.tsx'))); | ||
|
||
expectErrors(0); | ||
}); |
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,47 @@ | ||
import { | ||
clear, src, webpackConfig, tsconfig, | ||
watch, expectErrors, xrun | ||
} from './utils'; | ||
|
||
xrun(__filename, async function() { | ||
clear(); | ||
const index = src('index.ts', ` | ||
import sum from './sum' | ||
import mul from './mul' | ||
sum(1, 1) | ||
mul(1, 1) | ||
`); | ||
|
||
src('sum.ts', ` | ||
export default function sum(a: number, b: number) { | ||
return a + b; | ||
} | ||
`); | ||
|
||
const mul = src('mul.ts', ` | ||
// function with error | ||
export default function mul(a: number, b: number) { | ||
return a * c; | ||
} | ||
`); | ||
|
||
tsconfig(); | ||
const watcher = await watch(webpackConfig()); | ||
|
||
await watcher.wait(); | ||
|
||
expectErrors(1, [ | ||
`Cannot find name 'c'` | ||
]); | ||
|
||
index.update(() => ` | ||
import sum from './sum' | ||
sum(1, 1) | ||
`); | ||
|
||
mul.remove(); | ||
|
||
await watcher.wait(); | ||
expectErrors(0); | ||
}); |
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,27 @@ | ||
import { | ||
clear, src, webpackConfig, tsconfig, | ||
compile, checkOutput, expectErrors, run | ||
} from './utils'; | ||
|
||
run(__filename, async function() { | ||
clear(); | ||
src('index.ts', ` | ||
class HiThere { | ||
constructor(a: number, b: string) { | ||
const t = a + b; | ||
} | ||
} | ||
`); | ||
|
||
tsconfig(); | ||
await compile(webpackConfig()); | ||
|
||
expectErrors(0); | ||
checkOutput('index.js', ` | ||
class HiThere { | ||
constructor(a, b) { | ||
const t = a + b; | ||
} | ||
} | ||
`); | ||
}); |
Oops, something went wrong.