2016-10-07 11 views
14

मेरे पास एक कोणीय 2 प्रोजेक्ट है जिसे मैं वेबपैक के साथ संकुचित/संकलित करता हूं।वेबपैक के साथ tslint-loader 2.1.0-beta.25

मैं वेबपैक के साथ tslink लोडर का उपयोग करता हूं इसलिए मेरे पास webpack.config.js में संबंधित कॉन्फ़िगरेशन है।

module.exports = { 
... 
tslint: { 
    configuration: { 
     rules: { 
      quotemark: [true, "double"] 
     } 
    }, 

    // tslint errors are displayed by default as warnings 
    // set emitErrors to true to display them as errors 
    emitErrors: false, 

    // tslint does not interrupt the compilation by default 
    // if you want any file with tslint errors to fail 
    // set failOnHint to true 
    failOnHint: true, 

    // name of your formatter (optional) 
    formatter: "", 

    // path to directory containing formatter (optional) 
    formattersDirectory: "node_modules/tslint-loader/formatters/", 

    // These options are useful if you want to save output to files 
    // for your continuous integration server 
    fileOutput: { 
     // The directory where each file"s report is saved 
     dir: "./webpack-log/", 

     // The extension to use for each report"s filename. Defaults to "txt" 
     ext: "xml", 

     // If true, all files are removed from the report directory at the beginning of run 
     clean: true, 

     // A string to include at the top of every report file. 
     // Useful for some report formats. 
     header: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<checkstyle version=\"5.7\">", 

     // A string to include at the bottom of every report file. 
     // Useful for some report formats. 
     footer: "</checkstyle>" 
    } 
}, 
... 
preLoaders: [ 
     { 
      test: /\.ts$/, 
      loader: "tslint" 
     } 
    ], 
} 
} 

मैं webpack 1.13.1 2.1.0-beta.25 के लिए अद्यतन और tslint विन्यास npm run build की जटिलता प्रक्रिया टूट जाता है।

मैं loaders

module: { 
     .... 
     { 
      test: /\.ts$/, 
      loader: 'tslint', 
      exclude: /(node_modules)/, 
      enforce: 'pre' 
     }, 
    ], 
} 

है कि नहीं पर्याप्त कारण मैं अभी भी त्रुटि

For loader options: webpack 2 no longer allows custom properties in configuration. 
Loaders should be updated to allow passing options via loader options in module.rules. 

तो मैं tslint विन्यास के लिए कदम और कहीं और यह जगह चाहिए पाने के लिए preLoaders निर्देश बदल दिया है। थोड़े यहाँ खो गए। इसलिए इस मुद्दे के बारे में किसी भी जानकारी की सराहना की जाएगी।

धन्यवाद!

उत्तर

53

जो दूसरों बीटा v2.1 में webpack 2 में preloaders साथ कोई समस्या है के लिए -beta.23 प्री/पोस्टलोडर्स के साथ ब्रेकिंग बदलाव हैं।

पहले "लोडर" अनुभाग का नाम बदलकर "नियम" कर दिया जाना चाहिए। पूर्व/पोस्ट लोडर अब नियमों के तहत परिभाषित किया गया है।

मेरे मामले में मैं एक प्रीलोडर के रूप में tslint का उपयोग कर रहा था। नियमों के लिए प्री/पोस्टलोडर जोड़ने के लिए enforce मूल्य या तो pre या post के साथ संपत्ति जोड़ें। GitHub पर रिलीज में

module: { 
    rules: [ 
     { 
      enforce: 'pre', 
      test: /\.tsx?$/, 
      loader: 'tslint', 
      exclude: /(node_modules)/, 
     }, 
     { 
      test: /\.tsx?$/, 
      loaders: ['awesome-typescript-loader'], 
      exclude: /(node_modules)/ 
     } 
    ] 
} 

और जानकारी: Webpack v2.1.0-beta.23

रिहाई की जानकारी में वहाँ भी एक pull request कि आवश्यक परिवर्तन webpack कॉन्फ़िग फ़ाइल में v2.1.0-beta.23 को v2.1.0-beta.22 से जा रहा से पता चलता करने के लिए एक कड़ी है। वहां आप देख सकते हैं कि आपको लोडरऑप्शन प्लगइन की भी आवश्यकता है।

plugins: [ 
    new webpack.LoaderOptionsPlugin({ 
     options: { 
      tslint: { 
       emitErrors: true, 
       failOnHint: true 
      } 
     } 
    }) 
] 
+0

बहुत बढ़िया answer.Can मैं कोष्टक के बिना node_modules का उपयोग करें? धन्यवाद। – skiabox

2

ठीक .. तो मैं बस के नीचे tslint परिभाषा को स्थानांतरित करने की जरूरत:

plugins: [ 
    new LoaderOptionsPlugin({ 
     options: { 
      tslint: { 
      ... 

और घोषित

const LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); 
0

आप एक प्लगइन जोड़ने के लिए नहीं करना चाहते हैं, तो आप कुछ इस तरह कर सकते हैं,

module: { 
    rules: [ 
    { 
     enforce: 'pre', 
     test: /\.ts$/, 
     loader: 'tslint-loader?' + JSON.stringify({ 
     emitErrors: true, 
     failOnHint: true 
     }) 
    } 
    ] 
} 
संबंधित मुद्दे