【问题标题】:Typescript and webpack aliasTypescript 和 webpack 别名
【发布时间】:2018-01-31 01:58:36
【问题描述】:

我需要为我的代码创建一个 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

【问题讨论】:

标签: typescript webpack jupyter-lab


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 2020-05-28
    • 1970-01-01
    • 2021-03-30
    • 2016-08-02
    相关资源
    最近更新 更多