मैं अपने टाइपस्क्रिप्ट अनुप्रयोगों में Fuse का उपयोग करने का प्रयास कर रहा हूं। मैं import * as fuselib from 'fuse.js';
के साथ मॉड्यूल टाइपिंग आयात कर रहा हूं। यह tsc
के साथ ठीक संकलित करता है। जब मैं webpack --config config/webpack.prod.js --progress --profile --bail
का उपयोग कर प्रोजेक्ट का निर्माण करता हूं तो समस्या मैं चल रहा हूं।टाइपस्क्रिप्ट कंपाइलर नहीं होने पर वेबपैक मॉड्यूल को खोजने में विफल क्यों होता है?
मुझे त्रुटि Cannot find module 'fuse.js'
प्राप्त होती है। Fuse टाइपिंग here मिल सकती है। मेरे संकलित जेएस को देखते हुए, मुझे fuse.js
शब्द नहीं मिल रहा है, इसलिए मुझे लगता है कि वेबपैक नाम को उलझ रहा है। मैंने UglifyJsPlugin
में कीवर्ड fuse.js
को अनदेखा करने का प्रयास किया, लेकिन इससे मदद नहीं मिली।
मेरा वेबपैक कॉन्फ़िगरेशन काफी मानक है।
webpack.prod.js
var webpack = require('webpack');
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = webpackMerge(commonConfig, {
devtool: 'source-map',
output: {
path: helpers.root('dist'),
publicPath: '/',
filename: '[name].[hash].js',
chunkFilename: '[id].[hash].chunk.js'
},
htmlLoader: {
minimize: false // workaround for ng2
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
mangle: {
keep_fnames: true,
except: ['fuse.js']
}
}),
new ExtractTextPlugin('[name].[hash].css'),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
});
webpack.common.js
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve: {
extensions: ['', '.js', '.ts', '.tsx'],
modulesDirectories: ['src', 'node_modules']
},
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader', 'angular2-router-loader']
},
{
test: /\.html$/,
loader: 'html'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw'
}
]
},
plugins: [
// for materialize-css
new webpack.ProvidePlugin({
"window.jQuery": "jquery",
"window._": "lodash",
_: "lodash"
}),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
};
मैं आदेश बनाने के लिए Webpack मॉड्यूल fuse.js
देखने में क्या याद आ रही है?
क्या आपने इसे पैकेज.जेसन में जोड़ा और एनपीएम इंस्टॉल किया? –
मैंने किया, प्रविष्टि '" fuse.js "है:" 2.6.1 "'। – onetwothree
इसके विवरण में वर्कअराउंड के साथ https://github.com/krisk/Fuse/pull/124 भी देखें। – Arjan