-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to favor configure by callback
Remove options and add callback for configuraiton * Add new loader util for typescript. * Refactor public API signature.
- Loading branch information
Showing
5 changed files
with
67 additions
and
41 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
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
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
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
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,50 @@ | ||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const loaderFeatures = require('../loader-features'); | ||
const babelLoader = require('./babel'); | ||
|
||
/** | ||
* @param {WebpackConfig} webpackConfig | ||
* @return {Array} of loaders to use for TypeScript | ||
*/ | ||
module.exports = { | ||
getLoaders(webpackConfig) { | ||
loaderFeatures.ensureLoaderPackagesExist('typescript'); | ||
|
||
// some defaults | ||
let config = { | ||
transpileOnly: false, | ||
happyPackMode: false, | ||
logInfoToStdOut: false, | ||
logLevel: 'info', | ||
silent: true, | ||
}; | ||
|
||
// allow for ts-loader config to be controlled | ||
webpackConfig.tsConfigurationCallback.apply( | ||
// use config as the this variable | ||
config, | ||
[config] | ||
); | ||
|
||
// use ts alongside with babel | ||
// @see https://github.com/TypeStrong/ts-loader/blob/master/README.md#babel | ||
let loaders = babelLoader.getLoaders(webpackConfig); | ||
return loaders.concat([ | ||
{ | ||
loader: 'ts-loader', | ||
// @see https://github.com/TypeStrong/ts-loader/blob/master/README.md#available-options | ||
options: config | ||
} | ||
]); | ||
} | ||
}; |