0

我需要为我的代码创建一个 Hammer 的别名。我在 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/*"]
}

但是在geo.js中我仍然遇到错误,我有'require(Hammer)'。我错过了什么?

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
4

1 回答 1

0

我找到了一个答案,因为在我的情况下,每次调用 Jupyter 实验室构建时,调用程序 (JupyterLab) 都会创建一个新的 webpack 配置。现在,我不得不将 Hammer 嵌入到 GeoJS 中(在 webpack 配置中将 Hammer 作为外部组件移除)。

于 2017-08-23T14:16:12.720 回答