2016-11-12 4 views
0

だから、私はプロジェクトがそうのような構造している示していますWebPACKのすべてではないsourcemapsはtypescriptです

Root 
| index.html 
| package.json 
| tree.txt 
| tsconfig.json 
| webpack.config.js 
| 
+---.vscode 
|  settings.json 
|  tasks.json 
|  
+---app 
| | main.js 
| | main.js.map 
| | main.ts 
| | test.js 
| | test.js.map 
| | test.ts 
| | 
| +---components 
| |  app.component.js 
| |  app.component.js.map 
| |  app.component.ts 
| |  
| \---modules 
|   app.module.js 
|   app.module.js.map 
|   app.module.ts 
|   
\---node_modules 
    | 
    *SNIP* 

私の問題は私のmain.tsのsourcemapは、実際のクロムのdevのツールではtypescriptです、app.moduleとして示されますということです、 app.componentとtestはコンパイルされたjavascriptとして表示されます。

webpack typescriptに関するその他の問題は、babel loader固有のもの、ブレークポイントの配置に関する問題、またはソースマップがまったく生成されないことです。

私のTSconfig:

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "sourceMap": true, 
     "watch": true, 
     "compileOnSave": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": false, 
     "noImplicitAny": false 
    }, 
    "exclude": [ 
     "node_modules", 
     "typings/browser", 
     "typings/browser.d.ts" 
    ], 
    "atom": { 
     "rewriteTsconfig": false 
    }, 
    "typeRoots": [ 
     "./node_modules/@types" 
    ], 
    "types": [ 
     "core-js" 
    ] 
} 

マイwebpack.config.js:main.tsため

const config = { 
    entry: { 
     app: "./app/main.ts" 
    }, 
    output: { 
     filename: "./bundle.js", 
     path: "./" 
    }, 
    devtool: "source-map", 
    module: { 
     loaders: [ 
      { 
       test: /\.ts$/, 
       loaders: ["awesome-typescript-loader", "angular2-template-loader"] 
      } 
     ] 
    }, 
    resolve: { 
     extentions: ["", ".ts", ".js"] 
    } 
} 

module.exports = config; 

クロームのdevのツールの出力:テスト用

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { AppModule } from './modules/app.module'; 
import { test } from "./test"; 
const platform = platformBrowserDynamic(); 
platform.bootstrapModule(AppModule); 
alert(test.msg) 


// WEBPACK FOOTER // 
// ./~/angular2-template-loader!./app/main.ts 

クロームのdevのツールの出力.js:

"use strict"; 
var test = (function() { 
    function test() { 
    } 
    test.msg = "test"; 
    return test; 
}()); 
exports.test = test; 
//# sourceMappingURL=test.js.map 


////////////////// 
// WEBPACK FOOTER 
// ./app/test.js 
// module id = 25 
// module chunks = 0 

すべての個々の.mapファイルのソースは、スクリプトのtsバージョンを指しています。

のWebPACK-DEV-serverコマンドの出力:

webpack-dev-server -d 
http://localhost:8080/webpack-dev-server/ 
webpack result is served from/
content is served from C:\Users\Joseph Goodley\Desktop\stockmonitor\frontend 
Hash: b3331cfe915060534a0f 
Version: webpack 1.13.3 
Time: 7618ms 
      Asset  Size Chunks    Chunk Names 
    ./bundle.js 1.54 MB  0 [emitted] app 
./bundle.js.map 1.75 MB  0 [emitted] app 
chunk {0} ./bundle.js, ./bundle.js.map (app) 1.49 MB [rendered] 
    [0] ./app/main.ts 326 bytes {0} [built] 
    [1] ./~/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js 6.89 kB {0} [built] 
    [2] ./~/@angular/compiler/bundles/compiler.umd.js 825 kB {0} [built] 
    [3] ./~/@angular/core/bundles/core.umd.js 386 kB {0} [built] 
    [4] ./~/rxjs/Subject.js 5.33 kB {0} [built] 
    [5] ./~/rxjs/Observable.js 6.04 kB {0} [built] 
    [6] ./~/rxjs/util/root.js 471 bytes {0} [built] 
    [7] ./~/rxjs/util/toSubscriber.js 707 bytes {0} [built] 
    [8] ./~/rxjs/Subscriber.js 8.87 kB {0} [built] 
    [9] ./~/rxjs/util/isFunction.js 148 bytes {0} [built] 
    [10] ./~/rxjs/Subscription.js 5.99 kB {0} [built] 
    [11] ./~/rxjs/util/isArray.js 146 bytes {0} [built] 
    [12] ./~/rxjs/util/isObject.js 151 bytes {0} [built] 
    [13] ./~/rxjs/util/tryCatch.js 422 bytes {0} [built] 
    [14] ./~/rxjs/util/errorObject.js 177 bytes {0} [built] 
    [15] ./~/rxjs/util/UnsubscriptionError.js 1.07 kB {0} [built] 
    [16] ./~/rxjs/Observer.js 193 bytes {0} [built] 
    [17] ./~/rxjs/symbol/rxSubscriber.js 270 bytes {0} [built] 
    [18] ./~/rxjs/symbol/observable.js 631 bytes {0} [built] 
    [19] ./~/rxjs/util/ObjectUnsubscribedError.js 955 bytes {0} [built] 
    [20] ./~/rxjs/SubjectSubscription.js 1.4 kB {0} [built] 
    [21] ./~/@angular/platform-browser/bundles/platform-browser.umd.js 120 kB {0} [built] 
    [22] ./~/@angular/common/bundles/common.umd.js 121 kB {0} [built] 
    [23] ./app/modules/app.module.js 1.42 kB {0} [built] 
    [24] ./app/components/app.component.js 1.22 kB {0} [built] 
    [25] ./app/test.js 175 bytes {0} [built] 
webpack: bundle is now VALID. 

私はしかし、私は、さらにちょうど実行しているのWebPACK --debugは、バンドルを生成する理由はわかりません、それは[23-24]上のjsファイルを建物のことに注意してくださいjsファイルを指すソースもある.js.mapファイル。

この問題はかなりの間私を悩ませています。だからシンプルなことがあれば謝ります。

ありがとうございました!

更新:

問題は、私はそれらをwebpacking前にTSをコンパイルしてることだろうか?私は、コンパイルされたファイルなしで実行中のWebPACKをしようとしましたが、今では私のTSファイルを見つけることができません。

./app/main.ts 
Module not found: Error: Cannot resolve 'file' or 'directory' ./modules/app.module in C:\--\app 
resolve file 
    C:\--\app\modules\app.module doesn't exist 
    C:\--\app\modules\app.module.webpack.js doesn't exist 
    C:\--\app\modules\app.module.web.js doesn't exist 
    C:\--\app\modules\app.module.js doesn't exist 
    C:\--\app\modules\app.module.json doesn't exist 
resolve directory 
    C:\--\app\modules\app.module doesn't exist (directory default file) 
    C:\--\app\modules\app.module\package.json doesn't exist (directory description file) 
[C:\--\app\modules\app.module] 
[C:\--\app\modules\app.module.webpack.js] 
[C:\--\app\modules\app.module.web.js] 
[C:\--\app\modules\app.module.js] 
[C:\--\app\modules\app.module.json] 
@ ./app/main.ts 3:19-50 

それは私の.TSファイルを解決することはないのはなぜ?

答えて

1

問題が見つかりました。私package.configインサイド

は「extentions」は、残念ながら私は、構文の問題を示すエラーがなかった「拡張」されている必要があります。

0

あなたが言ったように、エラーはあなたのwebpack.config.jsの中にあります。 Webpack 2以降は、無効な設定オブジェクトがあるときにエラーメッセージが表示されるため、Webpackのバージョンをアップグレードすると、将来これらの問題を回避するのに役立ちます。

webpackをアップグレードしない場合は、このパッケージを使用して、自動的に構成を検証することができます。https://github.com/js-dxtools/webpack-validator

関連する問題