Il s'avère qu'il n'y a aucun problème avec ts-loader, mais il doit être associé à angulaire2-template-loader. Je n'ai pas eu d'autre choix que de revenir à Awesome-typescript-loader, et une erreur a été signalée. S'il vous plaît, aidez-moi à jeter un œil. Si vous avez des questions, dites-le-moi, j'attendrai en ligne.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/bindCallback.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/bindNodeCallback.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/combineLatest.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/concat.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/defer.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/dom/ajax.d.ts:2:15
Invalid module name in augmentation, module '../../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/dom/webSocket.d.ts:2:15
Invalid module name in augmentation, module '../../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/empty.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/forkJoin.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/from.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromEvent.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromEventPattern.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
ERROR in [default] /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/rxjs/add/observable/fromPromise.d.ts:2:15
Invalid module name in augmentation, module '../../Observable' cannot be found.
Ce qui suit est mon fichier tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true
// "outDir": ""
},
"buildOnSave": false,
"compileOnSave": false,
"exclude": [
"node_modules"
],
"awesomeTypescriptLoaderOptions": {
"useWebpackText": true
}
}
Voici mon fichier de configuration webpack :
/**
* 开发环境webpack配置
*/
const path = require('path');
module.exports = {
entry: {
app: './src/main.ts',
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['', '.ts', '.js', '.json']
},
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader'],
exclude: /(node_modules | libs)/
},
{
test: /.less$/,
loader: 'less',
exclude: /(node_modules | libs)/
},
{
test: /.html$/,
loader: 'raw-loader'
}
]
}
}
Raison :
La dernière version 2.x de Awesome-typescript-loader n'est compatible qu'avec la version Typescript 2.x (la version officielle actuelle n'est que jusqu'à 1.8).
Solution :
Option 1 : Mettre à niveau TypeScript vers la version d'aperçu
Option 2 : Utilisez la version 1.x de Awesome-typescript-loader
La solution a été trouvée. Vous devez mettre à jour TypeScript vers la dernière version.
Référence :
https://github.com/s-panferov/awesome-typescript-loader/issues/179