[英]Typescript and webpack alias
I need to create an alias for Hammer for my code. 我需要为我的代码创建Hammer的别名。 I have added paths in my tsconfig as shown below: 我在tsconfig中添加了路径,如下所示:
{
"compilerOptions": {
"declaration": true,
"noImplicitAny": false ,
"noEmitOnError": true,
"noUnusedLocals": false ,
"noUnusedParameters": false ,
"module": "commonjs",
"moduleResolution": "node",
"target": "ES5",
"outDir": "./lib",
"lib": ["ES5", "ES2015.Promise", "DOM", "ES2015.Collection", "es2016"],
"jsx": "react",
"types": [],
"baseUrl": ".",
"paths": {
"Hammer": ["hammerjs/hammer.js"]
}
},
"include": ["typings/index.d.ts","src/*"]
}
But I am still getting an error when in geo.js, I have 'require(Hammer)'. 但是在geo.js中,我有一个'require(Hammer)'时仍然遇到错误。 What I am missing? 我缺少什么?
ERROR in ./~/geojs/geo.js
Module not found: Error: Can't resolve 'Hammer' in '/home/chaudhary/tools/jupyterlab/mydev/share/jupyter/lab/staging/node_modules/geojs'
@ ./~/geojs/geo.js 3:27-44
@ ./~/@jupyterlab/geojson-extension/lib/index.js
@ ./build/index.out.js
I found an answer as in my case the calling program (JupyterLab) was creating a new webpack config everytime Jupyter lab build was invoked. 我找到了一个答案,因为在我的情况下,每次调用Jupyter实验室版本时,调用程序(JupyterLab)都会创建一个新的webpack配置。 For now, I had to embed Hammer into GeoJS (removed Hammer as externals in webpack config). 现在,我不得不将Hammer嵌入到GeoJS中(在Webpack配置中将Hammer删除为外部组件)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.