【发布时间】:2017-08-21 21:52:35
【问题描述】:
我从 webpack 收到以下错误。
./wwwroot/js/admin/infrastructure/typeaheadComponent.ts 中的错误 未找到模块:错误:无法在...中解析“提前输入”
我已经安装了以下
npm install typeahead.js
npm install @types/typeahead
我的打字稿如下,使用node模块解析。
import { module } from "angular";
import "typeahead";
// necessary to import typeahead into JQuery, as otherwise
// typeahead below is not defined.
class TypeAheadController {
foo(e) {
$(e).typeahead(...)
}
}
这会生成如下的javascript:
"use strict";
var angular_1 = require("angular");
require("typeahead");
var TypeAheadController = (function () { ...
我的 webpack.config.js 如下:
module.exports = {
context: __dirname,
entry: [
"./app.ts",
"./tab.ts",
"./client/clientService.ts",
"./client/clientSearchComponent.ts",
"./infrastructure/messageComponent.ts",
"./infrastructure/typeaheadComponent.ts",
"./url.ts"],
output: {
filename: "./wwwroot/js/admin/admin.js"
},
devtool: "source-map",
module: {
rules: [
{ test: /\.ts$/, use: 'ts-loader' }
]
}
};
导入到 gulp 任务中。
如何指定typeahead位于node_modules/typeahead.js/dist/typeahead.bundle.js
【问题讨论】:
标签: javascript typescript webpack webpack-2